kodiak icon indicating copy to clipboard operation
kodiak copied to clipboard

wip: experiment with rebase update strategy

Open JohannesRudolph opened this issue 4 years ago • 3 comments

JohannesRudolph avatar Apr 06 '20 08:04 JohannesRudolph

Deploy request for kodiak-docs accepted.

Accepted with commit 98aded06fd49bf17e3bd99dd98ac4fd903dc1647

https://app.netlify.com/sites/kodiak-docs/deploys/5e8aee340ac1ab0006b10cce

netlify[bot] avatar Apr 06 '20 08:04 netlify[bot]

I've taken a look at how we might best solve #150 - take this as an "inspiration" and not a complete PR (I'm not a pythonist...)

As far as I understand kodiak's bot, it doesn't run a git binary locally, and it probably shouldn't. There's no rebase available via GitHub's API unfortuantely, see e.g. https://github.com/tibdex/github-rebase for a discussion and workaround.

However there's github actions 🎉

So my idea is basically to add a update.method configuration that we can set to label and kodiak will simply label PRs that require an update, e.g. with automerge_needs_update.

Then we use an action like this to update the PR, at which point kodiak will get triggered again:

name: meshbot

on:
  pull_request:
    branches:
      - develop
    types:
      - labeled

jobs:
  update-pr:
    runs-on: ubuntu-latest
    if: contains(github.event.pull_request.labels.*.name, 'automerge')
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.ref }} # explicilty checkout PR branch head, not a merge commit, see https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
      - name: "Rebase PR onto base branch"
        id: rebase
        run: |
          # configure username
          git config --global user.email "[email protected]"
          git config --global user.name "meshbot"

          echo "fetching develop branch"
          git fetch --no-tags --prune origin develop

          # rebase
          git rebase origin/develop
          git push --force-with-lease
      - name: Remove automerge_needs_rebase label
        id: remove
        run: # todo, maybe use github-script to implement this

I think this nicely combines flexibilty without adding too much to kodiak. What do you think?

JohannesRudolph avatar Apr 06 '20 09:04 JohannesRudolph

@JohannesRudolph Thanks for making this PR!

Using GitHub Actions is a neat trick. I also think the API solution from https://github.com/tibdex/github-rebase could be interesting if it doesn't require too many API calls.

I can probably work on this PR after #325 is merged and the corresponding updates are made to the bot.

chdsbd avatar Apr 07 '20 02:04 chdsbd

I will close this PR as I have no intention any more of finishing it (as outlined above). Others have taken up on this, feel free to build on (or ignore) the ideas I presented here.

JohannesRudolph avatar Aug 15 '22 10:08 JohannesRudolph