Set GitHub commit status on the built commit - #1555
Open
JuanitoFatas wants to merge 1 commit into
Open
JuanitoFatas wants to merge 1 commit into
JuanitoFatas wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1543.
What happened
Danger asked the GitHub API "what is the PR head?" right when it ran. Then it posted the status there.
So if you pushed commit A, then B, and the build for A started late, A's result landed on B. (And a slow build could overwrite B's real status with A's result.)
The fix
A CI source can now tell Danger which commit it built (
commit_sha). Danger posts the status on that commit. If the CI source doesn't know, Danger falls back to the PR head, same as today.pull_request.head.shafrom the event payload. NotGITHUB_SHAand notgit rev-parse HEAD. Onpull_requestevents, both of those are the test merge commit, which isn't part of the PR. A status there never shows up on the PR.BUILDKITE_PULL_REQUEST_HEAD_COMMIT, thenBUILDKITE_COMMIT. Merge commit builds put the PR head inBUILDKITE_PULL_REQUEST_HEAD_COMMIT. I only accept a full hex SHA, becauseBUILDKITE_COMMITcan be the symbolicHEADbefore checkout.Only the status moves. The diff and the inline comment
commit_idstill use the PR head from the API, so inline comments stay lined up with the diff.