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

Announce in Slack if automerge fails because PR is not mergeable #1873

Merged
merged 5 commits into from
Mar 18, 2021

Conversation

roryabraham
Copy link
Contributor

@roryabraham roryabraham commented Mar 18, 2021

Fixing failed workflow run: https://github.com/Expensify/Expensify.cash/runs/2143920797?check_suite_focus=true

The mergeable_state of a PR is mix of whether it is mergeable and has all its PR checks completed and passed. While checks are still running, the mergeable_state is unstable. Both mergeable and mergeable_state are determined asynchronously in Github using background jobs.

So we have a custom Javascript action to poll continually until the mergeability of a PR is settled. This PR adds a slack announcement in the case that an automerge PR is created that's not mergeable (should not happen, hence the slack announcement). We also could poll and wait for the mergeable_state to be settled, but frankly we don't care about that field, since we skip all the checks on the automerge PRs anyways. So this PR also removes the checks we had in place for mergeable_state, which caused the automerge workflow to silently fail unnecessarily.

@roryabraham roryabraham self-assigned this Mar 18, 2021
@roryabraham roryabraham marked this pull request as ready for review March 18, 2021 22:29
@roryabraham roryabraham requested a review from a team as a code owner March 18, 2021 22:29
@roryabraham roryabraham requested a review from AndrewGable March 18, 2021 22:29
@botify botify requested review from Gonals and thienlnam and removed request for a team March 18, 2021 22:29
@@ -26,6 +26,28 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}

# This Slack step is duplicated in all workflows, if you make a change to this step, make sure to update all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove all the other instances? Can we exit the job here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rearranged so we fail the workflow then this announce step happens. However, I think we should leave the other announce steps in case the 3rd-party auto-approve and auto-merge actions fail for some other reason we're not aware of.

@@ -26,6 +26,31 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}

- name: Fail workflow if PR is not mergeable
if: ${{ steps.isPullRequestMergeable.outputs.IS_MERGEABLE }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ?

Suggested change
if: ${{ steps.isPullRequestMergeable.outputs.IS_MERGEABLE }}
if: ${{ steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }}

Also do you know if this exit 1 will stop all the other jobs from running and so therefore we don't need the if: checks for == 'true'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the conditional!

Also do you know if this exit 1 will stop all the other jobs from running and so therefore we don't need the if: checks for == 'true'?

Yeah, I think this is true.

@AndrewGable
Copy link
Contributor

Merging to get deploys working!

@AndrewGable AndrewGable merged commit 9c7b54e into master Mar 18, 2021
@AndrewGable AndrewGable deleted the Rory-FailAutomergeLoudly branch March 18, 2021 22:58
@botify
Copy link

botify commented Mar 18, 2021

@AndrewGable looks like this was merged without passing tests. Please add a note explaining why this was done or remove the Emergency label if this is not an emergency.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2021
@roryabraham
Copy link
Contributor Author

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

Successfully merging this pull request may close these issues.

3 participants