Skip to content

Commit 90089b8

Browse files
cliffhallclaude
andcommitted
fix(ci): a superseded dispatched run posts no pending status
typescript.yml and python.yml posted their `(dispatched)` pending status without checking for a newer dispatched run on the commit, so a re-run (which keeps its run ID) or a late-starting older run reset the newer run's result to pending, and its own result job then stayed silent and left it there. Both pending jobs now run the result job's newer-run check, as dco.yml and everything-mcp-diff.yml already do (#5222), and the stub-gh test covers all four workflows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 82acf2a commit 90089b8

3 files changed

Lines changed: 27 additions & 8 deletions

File tree

‎.github/workflows/python.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,23 @@ jobs:
197197
runs-on: ubuntu-latest
198198
permissions:
199199
statuses: write
200+
# To look for a newer dispatched run of this workflow on the commit.
201+
actions: read
200202
steps:
201203
- name: Set the commit status to pending
202204
env:
203205
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206+
GH_REPO: ${{ github.repository }}
204207
run: |
208+
# A re-run keeps its run ID, so a newer run means this one is
209+
# superseded and the status is no longer its to set (#5223).
210+
NEWER=$(gh run list --workflow python.yml --event workflow_dispatch \
211+
--commit "$GITHUB_SHA" --json databaseId \
212+
--jq "[.[] | select(.databaseId > $GITHUB_RUN_ID)] | length") || NEWER=0
213+
if [ "${NEWER:-0}" -gt 0 ]; then
214+
echo "Superseded by a newer dispatched run, which reports instead"
215+
exit 0
216+
fi
205217
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
206218
-f state=pending -f context="Python (dispatched)" \
207219
-f description="Dispatched run in progress" \

‎.github/workflows/typescript.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,23 @@ jobs:
230230
runs-on: ubuntu-latest
231231
permissions:
232232
statuses: write
233+
# To look for a newer dispatched run of this workflow on the commit.
234+
actions: read
233235
steps:
234236
- name: Set the commit status to pending
235237
env:
236238
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
239+
GH_REPO: ${{ github.repository }}
237240
run: |
241+
# A re-run keeps its run ID, so a newer run means this one is
242+
# superseded and the status is no longer its to set (#5223).
243+
NEWER=$(gh run list --workflow typescript.yml --event workflow_dispatch \
244+
--commit "$GITHUB_SHA" --json databaseId \
245+
--jq "[.[] | select(.databaseId > $GITHUB_RUN_ID)] | length") || NEWER=0
246+
if [ "${NEWER:-0}" -gt 0 ]; then
247+
echo "Superseded by a newer dispatched run, which reports instead"
248+
exit 0
249+
fi
238250
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
239251
-f state=pending -f context="TypeScript (dispatched)" \
240252
-f description="Dispatched run in progress" \

‎scripts/version-pr-ci.test.mjs‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ const workflow = (name) => parse(read(`.github/workflows/${name}`));
3636

3737
// `trigger` is the event the workflow runs on when a person pushes; the
3838
// workflow token's version of that event starts no run, hence the dispatch.
39-
// `pendingChecksNewer`: the pending job, like the result job, stays silent
40-
// when a newer dispatched run exists (#5222); the CI workflows' pending jobs
41-
// do not yet (#5223).
4239
const CI = [
4340
{
4441
file: "typescript.yml",
@@ -50,13 +47,11 @@ const CI = [
5047
file: "dco.yml",
5148
context: "DCO (dispatched)",
5249
trigger: "pull_request",
53-
pendingChecksNewer: true,
5450
},
5551
{
5652
file: "everything-mcp-diff.yml",
5753
context: "Everything diff (dispatched)",
5854
trigger: "pull_request",
59-
pendingChecksNewer: true,
6055
},
6156
];
6257
// The Python stamps touch none of the Everything diff's paths, so its
@@ -206,11 +201,11 @@ for (const { file } of CI) {
206201
);
207202
}
208203

209-
for (const { file } of CI.filter((c) => c.pendingChecksNewer)) {
204+
for (const { file } of CI) {
210205
const pending = workflow(file).jobs["dispatch-status-pending"];
211206

212-
// A superseded run's pending job (a late start, or a re-run, which keeps
213-
// its run ID) must not reset the newer run's result to pending: its own
207+
// #5222, #5223: a superseded run's pending job (a late start, or a re-run,
208+
// which keeps its run ID) must not reset the newer run's result to pending: its own
214209
// result job would stay silent and leave it there.
215210
test(
216211
`${file}: a superseded run posts no pending status`,

0 commit comments

Comments
 (0)