-
Notifications
You must be signed in to change notification settings - Fork 937
git-commit-checks: comment on PR with error(s) #10632
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
Conversation
|
Can one of the admins verify this patch? |
|
ok to test |
|
Before it's merged, should this be |
|
Per https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target and https://securitylab.github.com/research/github-actions-preventing-pwn-requests/, I think we're ok to change ...unless the PR is changing the github action itself. But I think that's always a problem for |
08d0430 to
515e9aa
Compare
|
Okay, the event trigger has been changed to |
|
@Joe-Downs Interesting. Why isn't this action being run on this PR? "Git commit checker" is still stuck at "Expected" -- it hasn't been run. |
|
Hmm. That's strange. This stackoverflow discussion seems to suggest it's just a thing that happens with Actions sometimes, and re-triggering them should fix it. This GH community discussion mentions renaming action names different than what's in the branch protection rules can cause this. We didn't rename the action, but maybe it's because of the trigger change? I'll look into this and see if I can find a definitive answer |
|
I'm going to guess that it's some kind of weirdness with changing the trigger of an existing Action. E.g., it's getting treated as a "new" action (and therefore it won't run until it exists in the base)...? Let me know what you find. |
|
@Joe-Downs A further thought occurs to me: we have the "Git commit checker" CI test marked as "required" here in the main Open MPI repo. Does changing the trigger from Also, what does it mean for all the PRs that are already open but not yet merged? Can you do some tests on your own fork to figure out what will happen? And also figure out what we need to do here on the main Open MPI repo to bring this CI test change in with minimal disruption to already-existing PRs? |
|
I don't think it's related to any branch protection rules. I had the same I think your initial thought of it being related to changing triggers is correct. It appears that GitHub treats it as a new action. I force pushed the old Additionally, last night, I merged the original PR in my fork, and did some testing with the new Commit Checker code in The offending code: def get_github_pr():
g = Github(GITHUB_TOKEN)
repo = g.get_repo(GITHUB_REPOSITORY)
# Extract the PR number from GITHUB_REF
match = re.search("/(\d+)/", GITHUB_REF)
pr_num = int(match.group(1))
pr = repo.get_pull(pr_num)
return prI tried some debugging, by adding a print statement to see what |
|
@Joe-Downs A thought: can you have this PR set this hook to run on both Can you try this on your fork to see if this two-step scheme works? |
d69be15 to
b4f9788
Compare
This adds comments onto the pull request containing what caused the commit checks to fail, if any, and suggests fixes to the user. If no errors are raised, no comment is made. GitHub says there's a limit of 65536 characters on comments. If the bot's comment is over that limit, it will truncate the comment to fit, and add a message explaining where the remaining errors can be found. Unfortunately, the GitHub API doesn't seem to provide a job's unique ID for linking to a job run (this is different than an action run: ".../runs/..." vs ".../actions/runs/...", respectively), so we can't directly link to the error messages printed to the console. Additionally, to create this link, two new environment variables are used: GITHUB_RUN_ID and GITHUB_SERVER_URL. Because we need the PR object twice, check_github_pr_description() was also changed to have the PR object passed into it; the PR object is gotten with a new function, get_github_pr(). The GitHub action configuration was changed to run on pull_request_target, instead of pull_request. This allows the action to be run in the context of the base of the PR, rather than in the context of the merge commit. Therefore, the action is run even if the PR has merge conflicts. Because of how the branch contexts are different between pull_request and pull_request_target, other parts of the Python script had to change to reflect these differences. Signed-off-by: Joe Downs <joe@dwns.dev>
b4f9788 to
4b0ce7e
Compare
jsquyres
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Joe-Downs and I worked on this today (sorry for all the push notifications!). We did all the testing on a fork, and think that the code is now correct. To make comments on a PR, we needed to change the Github Action trigger from pull_request to pull_request_target, so Github won't actually run it on this PR (since it's a "new" Action). Therefore, we won't be able to satisfy the "Required" CI action on this one PR. Once this PR is merged, it will be fine for all existing and future Open MPI PRs -- it will use the new code from this PR.
Bottom line: I'm going to merge this PR even though we haven't satisfied the "Required" "Git commit checker" test. But it will be fine for all existing and future Open MPI PRs.
|
@jsquyres Welp, looks like we have a problem with the Commit Checker. In PR #10663, the bot ran, but had an error. Notably this: My assumption is that our solution that worked for branches on one repo doesn't work across forks. I will do some testing to confirm what happened, and hopefully I'll be able to fix this. In the meantime, I converted PRs #10660, #10661, and #10662 into drafts so they don't get merged before it's fixed. |
This adds comments onto the pull request containing what caused the commit checks to fail, if any, and suggests fixes to the user. If no errors are raised, no comment is made.
GitHub says there's a limit of 65536 characters on comments. If the bot's comment is over that limit, it will truncate the comment to fit, and add a message explaining where the remaining errors can be found. Unfortunately, the GitHub API doesn't seem to provide a job's unique ID for linking to a job run (this is different than an action run: ".../runs/..." vs ".../actions/runs/...", respectively), so we can't directly link to the error messages printed to the console. Additionally, to create this link, two new environment variables are used: GITHUB_RUN_ID and GITHUB_SERVER_URL.
Because we need the PR object twice, check_github_pr_description() was also changed to have the PR object passed into it; the PR object is gotten with a new function, get_github_pr().
Signed-off-by: Joe Downs joe@dwns.dev
Here's an example comment that this Github Action PR change will emit when there are problems with commits: