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

fix: Fix GitHub pull request mergeability for multiple required workflow runs #5057

Merged
merged 21 commits into from
Nov 19, 2024

Conversation

ajax-ryzhyi-r
Copy link
Contributor

@ajax-ryzhyi-r ajax-ryzhyi-r commented Nov 4, 2024

what

This PR modifies the mergeability evaluation logic for GitHub pull requests by evaluating the latest workflow check run (by comparing runNumber's) instead of the first one returned from the GitHub API.

why

There is an issue described in detail in #5048 where Atlantis treats a PR as unmergeable when there are multiple required GiHub Actions workflow runs for the last commit of the branch and the first of them is failed atlantis responds with the error Apply Failed: Pull request must be mergeable before running apply. when attempting to use the atlantis apply command.

Upon investigating this issue, I discovered that GitHub returns all checkRuns in chronological order when Atlantis retrieves a pull request's last commit mergeability status. However, Atlantis iterates through these checkRuns and retrieves the first checkRun instead of the last one, which represents the current status.

tests

  • I have tested my changes by running this fix in our Atlantis setup and everything works as expected
  • I have updated automated tests to cover these cases

references

Fixes the issue discussed in comments of #5048

@ajax-ryzhyi-r ajax-ryzhyi-r requested review from a team as code owners November 4, 2024 12:47
@ajax-ryzhyi-r ajax-ryzhyi-r requested review from chenrui333, nitrocode and X-Guardian and removed request for a team November 4, 2024 12:47
@github-actions github-actions bot added go Pull requests that update Go code provider/github labels Nov 4, 2024
@dosubot dosubot bot added the bug Something isn't working label Nov 4, 2024
@X-Guardian
Copy link
Contributor

Hi @ajax-ryzhyi-r, you have some spurious file changes in this PR that aren't relevant to your change. Can you revert them please? (Adding EOF LFs t files you haven't changed.)

server/events/vcs/github_client.go Outdated Show resolved Hide resolved
server/events/vcs/github_client.go Outdated Show resolved Hide resolved
server/events/vcs/github_client.go Outdated Show resolved Hide resolved
server/events/vcs/github_client.go Outdated Show resolved Hide resolved
server/events/vcs/github_client.go Outdated Show resolved Hide resolved
Signed-off-by: Roman Ryzhyi <[email protected]>
Signed-off-by: Roman Ryzhyi <[email protected]>
@nitrocode
Copy link
Member

cc @ajax-ryzhyi-r if you can address the above comments, this pr has a higher chance of getting into the next release which should be fairly soon

@ajax-ryzhyi-r
Copy link
Contributor Author

cc @ajax-ryzhyi-r if you can address the above comments, this pr has a higher chance of getting into the next release which should be fairly soon

@nitrocode I've already addressed all the comments above. If there's anything else I need to fix, please let me know

@lukemassa
Copy link
Contributor

cc @ajax-ryzhyi-r if you can address the above comments, this pr has a higher chance of getting into the next release which should be fairly soon

@nitrocode I've already addressed all the comments above. If there's anything else I need to fix, please let me know

If you could click "Resolved" for the issues that you've addressed just to confirm there's nothing left.

It looks like there might still be some end-of-line issues, for example https://github.com/runatlantis/atlantis/pull/5057/files#diff-adec0aa1d9d8bb750060e06ba970ea7ae5817c8517d94a862da133a95e1d2466R95, if you could take a look?

Otherwise the logic makes sense to me, I'm going to see if I can replicate the issue and confirm the new code fix

@ajax-ryzhyi-r
Copy link
Contributor Author

cc @ajax-ryzhyi-r if you can address the above comments, this pr has a higher chance of getting into the next release which should be fairly soon

@nitrocode I've already addressed all the comments above. If there's anything else I need to fix, please let me know

If you could click "Resolved" for the issues that you've addressed just to confirm there's nothing left.

It looks like there might still be some end-of-line issues, for example https://github.com/runatlantis/atlantis/pull/5057/files#diff-adec0aa1d9d8bb750060e06ba970ea7ae5817c8517d94a862da133a95e1d2466R95, if you could take a look?

Otherwise the logic makes sense to me, I'm going to see if I can replicate the issue and confirm the new code fix

I cannot hide comments with "Resolved" status which I don't own ;)

EOF related changes in the files I've edited appear to be legitimate due to the .editorconfig settings in this repository -https://github.com/runatlantis/atlantis/blob/main/.editorconfig#L7

server/events/vcs/github_client.go Outdated Show resolved Hide resolved
server/events/vcs/github_client.go Show resolved Hide resolved
@X-Guardian
Copy link
Contributor

@henriklundstrom, can you resolve the conversations that you started if you happy with the responses, and then we can get this PR merged.

@X-Guardian X-Guardian added the waiting-on-response Waiting for a response from the user label Nov 16, 2024
@henriklundstrom
Copy link
Contributor

@henriklundstrom, can you resolve the conversations that you started if you happy with the responses, and then we can get this PR merged.

@X-Guardian I actually can not! But I can say here that I'm happy with all of them, and let's proceed.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 19, 2024
@X-Guardian X-Guardian enabled auto-merge (squash) November 19, 2024 09:34
@X-Guardian X-Guardian merged commit b975301 into runatlantis:main Nov 19, 2024
34 checks passed
@X-Guardian
Copy link
Contributor

X-Guardian commented Nov 19, 2024

Thanks for your work on this @ajax-ryzhyi-r & @henriklundstrom . Can you test it using one of the following dev images: dev-debian-b975301 or dev-alpine-b975301

terakoya76 pushed a commit to terakoya76/atlantis that referenced this pull request Dec 31, 2024
kvanzuijlen pushed a commit to kvanzuijlen/atlantis that referenced this pull request Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code lgtm This PR has been approved by a maintainer provider/github waiting-on-response Waiting for a response from the user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants