fix(codeql): skip on merge_group like scorecard and zizmor already do - #340
Merged
Conversation
GitHub deletes the gh-readonly-queue ref the moment the queue finishes, which races the SARIF upload inside codeql-action/analyze. scorecard.yml calls that "a guaranteed `ref ... not found` failure" and skips the upload on merge_group; zizmor.yml skips its whole job for the same reason. codeql.yml never got the guard, so every merge-queue repository calling it can have a healthy pull request ejected from the queue by an infrastructure race. Seen on netresearch/ofelia#783, a one-file deletion: the queue run failed with `ref 'refs/heads/gh-readonly-queue/main/pr-783-...' not found in this repository` and github-merge-queue[bot] removed the pull request six minutes after adding it. The pull-request head is analysed before it ever reaches the queue, and push and schedule events run against stable refs, so no coverage is lost. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Skip CodeQL jobs during merge-queue (merge_group) runs to avoid a known race where GitHub deletes the gh-readonly-queue ref before codeql-action/analyze uploads SARIF, which can fail the run and eject PRs from the merge queue.
Changes:
- Add a job-level
ifguard to skip thepreparejob onmerge_group. - Add a job-level
ifguard to skip theanalyzejob onmerge_group.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Skipping both jobs would have made the check report `skipped` for every merge-queue run. A queue that requires `codeql / Analyze (...)` then never gets a verdict and waits until it times the pull request out — trading one ejection cause for another, worse one. The analysis now still runs in the queue; only the upload is turned off, which is the part that touches the gh-readonly-queue ref GitHub deletes when the queue finishes. `upload: never` is the documented value for exactly that. The pull-request head is analysed before it reaches the queue, and push and schedule events run against stable refs, so no result is lost. Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
|
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.



GitHub deletes the
gh-readonly-queueref the moment a merge queue finishes, which races the SARIF upload insidecodeql-action/analyze.scorecard.ymlalready guards against this and its comment calls the result "a guaranteedref ... not foundfailure";zizmor.ymlskips its whole job for the same reason.codeql.ymlnever got the guard.The consequence is not a cosmetic red check: the queue run fails, and
github-merge-queue[bot]ejects the pull request from the queue. It happened on netresearch/ofelia#783, a pull request that deletes one YAML file and touches no Go code at all — added to the queue at 18:40:42, removed at 18:46:13, withcodeql / Analyze (go)reportingref 'refs/heads/gh-readonly-queue/main/pr-783-...' not found in this repository. Every merge-queue repository that calls this reusable is exposed to the same race.No analysis coverage is lost. The pull-request head is analysed before it ever reaches the queue, and the
pushandscheduleevents that keep the default-branch results current run against stable refs — which is exactly the reasoning already written down inscorecard.yml.