Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: not updating branch - mergeable_state: clean #47

Closed
rokroskar opened this issue Jan 30, 2020 · 10 comments
Closed

question: not updating branch - mergeable_state: clean #47

rokroskar opened this issue Jan 30, 2020 · 10 comments

Comments

@rokroskar
Copy link

Thanks for this super useful action!

In trying to set it up I've hit an issue that I can't seem to resolve. From what I understand, the action should update the branch if needed via a merge commit or a rebase. The branch rules on the repo require that the branches are up-to-date before merging. In a PR, the branch is not up-to-date, but the github API returns mergeable_state: clean for the PR so the action doesn't do an update with the message No update necessary, mergeable_state: clean - the PR obviously now can't be merged because it's not up-to-date and no further action is taken. How should this be resolved?

@pascalgn
Copy link
Owner

I'm not 100 % sure. It might be an issue with GitHub, but it could also be an issue with automerge-action.

You could

@rokroskar
Copy link
Author

I think in the case I described above it perhaps was somehow an error from the github API. I've now got another PR that is correctly reported as "behind", but the automerge action never seems to enter the merge function. All I see in the logs is "Failed to merge... waiting for review" and "Getting latest PR data". Does the PR need to be approved for the branch to be updated?

@pascalgn
Copy link
Owner

pascalgn commented Feb 3, 2020

Do you see any message Updating PR #...? I think the branch should be updated even if the PR is not yet approved.

Is the PR from a branch in the same repository or from a fork? If it's a fork, the issues described in #46 might apply to you

@rokroskar
Copy link
Author

No, I don't see that message, that's what surprised me because before it always got to that point and then followed with "mergeable_state clean". It's not a fork.

@pascalgn
Copy link
Owner

pascalgn commented Feb 5, 2020

If possible, could you maybe try running the action locally?

You will need a personal access token.

Then clone the repository, create a file .env in the repository, like

GITHUB_TOKEN="123abc..."
URL="https://github.com/pascalgn/repository-name/pull/123"

and finally run yarn it (or npm run it).

Maybe it can give more insight into the issue.

@rokroskar
Copy link
Author

Well, that definitely produces different behavior. Running it locally I have

INFO  Event name: pull_request
INFO  Updating PR #743 Test automerge
INFO  Merge succeeded, new HEAD: test-automerge 8e7d8923f741f7a25b5c708ba30f444572f1cfc9
INFO  Merging PR #743 Test automerge
INFO  Current PR status: mergeable_state: behind
INFO  Retrying after 2000 ms ... (1/3)
INFO  PR is probably ready: mergeable_state: unknown

whereas the github action gives

INFO  Event name: pull_request
INFO  Updating PR #743 Test automerge
INFO  No update done due to PR mergeable_state unknown
INFO  Merging PR #743 Test automerge
INFO  PR is probably ready: mergeable_*** unknown
INFO  Failed to merge PR: Required status check "continuous-integration/travis-ci" is expected.
INFO  Retrying after 60000 ms ... (1/120)

Obviously the configuration is different so the eventual failure is different. But my expectation would be that they both update the PR in the same way?

@olivierlefloch
Copy link
Contributor

I have the same issue – the action clearly reports mergeable_state: clean instead of behind:

(using 7854d3b, latest as of 2020/02/06)

INFO  Event name: pull_request
INFO  Updating PR #9 Latest version
INFO  No update necessary, mergeable_state: clean
INFO  Merging PR #9 Latest version
INFO  PR is probably ready: mergeable_state: clean
INFO  Failed to merge PR: Required status check "Run Lint" is expected.

Running the action locally does not seem to encounter the same issue:

$ yarn it
yarn run v1.21.1
$ node it/it.js
INFO  Event name: pull_request
INFO  Updating PR #9 Latest version
INFO  Merge succeeded, new HEAD: olivier/latest_version f3deab8c667d530b49f305b510d1460abdd3f0b9
INFO  Skipping PR merge, required label missing: it-merge
✨  Done in 1.83s.

After adding tracing however, it seems the initial payload, that gets used by default if present:

if (pullRequest.mergeable_state) {
return pullRequest.mergeable_state;

claims that it has

     mergeable: true,
     mergeable_state: 'clean',

even though forcibly requesting its status (which the CLI run would do) would return the correct behind status. This does seem to be a Github bug, but perhaps retrieving the status from the API in all cases could avoid this issue?

@pascalgn
Copy link
Owner

pascalgn commented Feb 8, 2020

@olivierlefloch Thanks for the investigation! I created PR #52 for this. You can try out the changes using

    steps:
      - name: automerge
        uses: "pascalgn/automerge-action@493bb4288832f19203691042e34cd8f1a889c1d0"

Let us know how it goes! 👍

@rokroskar
Copy link
Author

rokroskar commented Feb 9, 2020

Hey @pascalgn I just tried with your PR - I've got a PR that needs to update the branch before it can be merged. The log of the automerge-action shows that on the first iteration the API returns mergeable_state: unknown so the action doesn't try to update the branch - but on the second run through mergeable_state: behind at which point it should I suppose update the branch but it does not. Unfortunately I can't produce mergeable_state: clean again :/

@pascalgn
Copy link
Owner

I think this is still not fixed, but the error is quite hard to reproduce and it's a long time since there was any activity here. I will close this issue for now, but if you have any new information or need any help, feel free to reopen this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants