-
Notifications
You must be signed in to change notification settings - Fork 293
fix(ci): keep successful external sweep dispatch green / 修复 CI:避免通知失败覆盖扫描调度成功 #2455
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
🟡 The fix only wraps
issues.createCommentin try/catch, but thelistWorkflowRunspolling loop just above it (also running after the successfulcreateWorkflowDispatch) is left unwrapped. If that call throws (transient 5xx, secondary rate limit, network blip), the step still fails uncaught despite the sweep already being dispatched — the same failure class this PR sets out to fix. Consider wrapping the polling loop (or the whole post-dispatch block) the same way for full coverage.Extended reasoning...
This PR's stated goal is to ensure "a notification-policy failure cannot make an already-dispatched sweep appear unsuccessful," and it achieves that for one specific call:
github.rest.issues.createComment(now wrapped in try/catch at the end of the script). However, thegithub.rest.actions.listWorkflowRunspolling loop that runs immediately aftercreateWorkflowDispatchsucceeds — and before the comment call — is not given the same protection.Code path:
createWorkflowDispatchsucceeds (line ~109, the irreversible action that starts the e2e run), then the script enters a loop that pollslistWorkflowRunsup to 15 times to resolvedispatchedRunfor the run-link comment. This loop already tolerates the "run not found" case gracefully — if no matching run turns up after 15 attempts,dispatchedRunstaysundefinedand the code falls back to a generic workflow link. But that graceful handling only covers a benign not-found outcome, not an actual API failure. IflistWorkflowRunsitself rejects (a transient 5xx, a secondary rate limit, or a network blip), theawaitthrows inside the loop, propagates uncaught, and the wholegithub-scriptstep fails — exactly the "green dispatch, red job" scenario this PR was written to eliminate.Why the existing fix doesn't prevent it: the new try/catch block only surrounds the
createCommentcall, which executes after this loop. Anything that throws during the loop itself never reaches that try/catch, so it's outside the scope of the current fix even though it shares the identical failure class (a non-dispatch API call failing after the dispatch already succeeded).Step-by-step reproduction of the gap:
createWorkflowDispatch— this succeeds and the e2e run is now queued/running.listWorkflowRunsto find the new run's URL for the notification comment.await github.rest.actions.listWorkflowRuns(...)throws. There is no try/catch around it, so the exception unwinds out of the loop and out of the script.github-scriptstep fails, the job goes red — even though the sweep was already successfully dispatched in step 1 — reproducing the precise inconsistency (successful dispatch, failed-looking job) that this PR's description calls out as the bug being fixed.Impact: this is a genuine gap relative to the PR's own stated invariant, but it's a lower-probability trigger than the deterministic 403 this PR was written to fix (that 403 was on the comment endpoint specifically, due to a permissions mismatch that's now corrected).
listWorkflowRunsonly needsactions: read/write, which this workflow already has, so it won't hit the same permissions failure — it would need an actual transient GitHub API error to fail. The consequence is also contained: a misleading red job status that could at worst prompt a maintainer to remove/re-add the sweep label and trigger a redundant dispatch, not data loss or a broken sweep.Suggested fix: wrap the polling loop (or the entire post-dispatch block from after
createWorkflowDispatchthrough the comment) in the same try/catch-and-core.warningpattern already used for the comment call, so any post-dispatch API failure is treated as best-effort and doesn't flip the job status.