-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
tools/ci: Fix commit message checking when PR branch HEAD behind master. #16114
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
tools/ci: Fix commit message checking when PR branch HEAD behind master. #16114
Conversation
@andrewleech I just saw you tackled this exact problem in #12658, but I think there are still some scenarios where it still checks the wrong commits. |
92d11ce
to
09de917
Compare
Thanks, this looks good to me, and your testing is thorough! As you noted, do we also need to update the related logic in |
Code size report:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #16114 +/- ##
=======================================
Coverage 98.57% 98.57%
=======================================
Files 164 164
Lines 21345 21345
=======================================
Hits 21040 21040
Misses 305 305 ☔ View full report in Codecov by Sentry. |
That looks great @projectgus , thanks for the clear description both here and in the script. Oh the existing comment did mention the merge and try to exclude it, regardless I like the look of your changes and testing. |
Yeah, I hadn't realised either until I looked at this. There is a way to tell the GitHub checkout action to check out the PR branch HEAD instead of the merge commit, but this actually gives us more work in this case because we still don't know what the merge base is, and we need this to know which commits to check! Whereas having the dummy merge commit (in this case) means we have all of the git history we need without needing to fetch anything new.
I looked at this yesterday and thought it was OK, but I just looked again and I think there's a bug: it currently compares the PR branch's merge base against the generated merge commit. So that means any changes merged on master which aren't in the PR branch are included in the size comparison. I think it should either compare the merge base with the PR branch HEAD, or compare the generated merge commit with the master branch. Probably the second one as that's exactly what the code size increase would be if the PR was merged. Will submit another PR for this. |
Fixes the problem noted at micropython#15547 (comment) which is that, because default CI HEAD for a PR is a (generated) merge commit into the master branch's current HEAD, then if the PR branch isn't fully rebased then the commit check runs against commits from master as well! Also drops running this check on push, the pull_request event is triggered by default on open and update ("synchronized" event), which probably covers the cases where this check should run. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
09de917
to
9591b0a
Compare
Summary
Fixes the subtle problem noted here - workflow log here. Specifically, default CI HEAD for a PR is a (generated) merge commit into the master branch's current HEAD. If the PR branch isn't fully rebased (i.e. is one or more commits behind latest mater) then the commit check runs against commits from master as well!
Also drops running this check on push, the pull_request event is triggered by default on open and update, so that should cover all cases where this check needs to run.
Testing
I made this PR branch the default branch in my fork and opened a series of dummy PRs:
This work was funded through GitHub Sponsors.