Skip to content

Commit 0b58b33

Browse files
cliffhallclaude
andcommitted
ci: report dispatched CI runs on the PR as commit statuses
A workflow_dispatch run's checks attach to the head commit but are left out of its status rollup, which is what a pull request reads: a probe commit with 29 successful dispatched check runs had a rollup of null. So a version PR would have shown no CI at all. On a dispatch, each CI workflow now posts a pending commit status at the start and the run's result at the end, which the rollup does include. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 2ffe79f commit 0b58b33

5 files changed

Lines changed: 132 additions & 9 deletions

File tree

‎.claude/skills/release/SKILL.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,11 @@ Then, on the PR:
179179
would not survive; this is the exception `AGENTS.md` names.
180180
2. **Wait for its CI to pass.** The workflow token's push starts no workflow,
181181
so the Version Packages workflow dispatches the TypeScript and Python
182-
workflows on `changeset-release/v2/main` after each update; their checks
183-
report on the PR's head commit. Closing and reopening the PR does not start
184-
them (that fires `pull_request`; they run on `push`). If none appear, run
185-
them by hand:
182+
workflows on `changeset-release/v2/main` after each update. A PR does not
183+
list dispatched checks, so the result shows as two commit statuses,
184+
`TypeScript (dispatched)` and `Python (dispatched)`. Closing and reopening
185+
the PR does not start them (that fires `pull_request`; they run on `push`).
186+
If neither status appears, run them by hand:
186187
`gh workflow run typescript.yml --ref changeset-release/v2/main` (and
187188
`python.yml`).
188189
3. **Read it**: each bump matches the semver policy in `RELEASING.md`, each
@@ -203,7 +204,7 @@ gh workflow run prepare-python-release.yml --repo modelcontextprotocol/servers \
203204
It opens a PR that starts with `Closes #N`, on a branch named
204205
`v2/chore/<N>-python-calver-<date>`, labeled `v2`, and dispatches the
205206
TypeScript and Python workflows on that branch, as the Version Packages
206-
workflow does. Wait for that CI to pass, check that each stamped package really
207+
workflow does. Wait for its two `(dispatched)` statuses to pass, check that each stamped package really
207208
changed, and a maintainer merges it.
208209
No PR means no Python server has a shipped change since its last stamp.
209210

‎.github/workflows/prepare-python-release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
echo "Generated by the **Prepare Python Release** workflow. Nothing is published until a maintainer publishes a GitHub Release."
109109
echo
110110
echo "> [!NOTE]"
111-
echo "> A push made with the workflow token starts no CI, so the workflow dispatched the TypeScript and Python workflows on this branch. Their checks report on the head commit. To run them again: \`gh workflow run python.yml --ref $BRANCH\` (and \`typescript.yml\`)."
111+
echo "> A push made with the workflow token starts no CI, so the workflow dispatched the TypeScript and Python workflows on this branch. Their results show on this PR as the \`TypeScript (dispatched)\` and \`Python (dispatched)\` statuses. To run them again: \`gh workflow run python.yml --ref $BRANCH\` (and \`typescript.yml\`)."
112112
} > "$RUNNER_TEMP/pr-body.md"
113113
# A second run on the same day force-updates the branch, and may
114114
# stamp a different set of packages; the open PR's body is rewritten

‎.github/workflows/python.yml‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ on:
99
# that automation opens (Version Packages, Prepare Python Release) get no
1010
# push run. Their workflows dispatch this one on the PR's branch instead
1111
# (#5110): `workflow_dispatch` is the one event that token can start, and its
12-
# run reports its checks on the branch's head commit, which the PR shows.
12+
# run's checks attach to the branch's head commit. The rollup a PR reads
13+
# leaves dispatched checks out, so the `dispatch-status` jobs below report
14+
# the run as a commit status instead.
1315
workflow_dispatch:
1416

1517
# Superseded runs on the same ref are cancelled (e.g. rapid amend-pushes),
@@ -180,3 +182,62 @@ jobs:
180182
with:
181183
name: dist-${{ matrix.package }}
182184
path: src/${{ matrix.package }}/dist/
185+
186+
# A dispatched run's checks attach to the branch's head commit but are left
187+
# out of its status rollup, which is what a pull request reads (verified on
188+
# #5110: 29 successful dispatched check runs, a rollup of null). So on a
189+
# dispatch, which is how a version PR opened by automation gets CI, these two
190+
# jobs mirror the run onto the commit as a status, which the rollup does
191+
# include: pending at the start, then the result of every job above. A push
192+
# run reports through its own checks and skips both.
193+
dispatch-status-pending:
194+
name: Report the dispatched run as pending
195+
if: github.event_name == 'workflow_dispatch'
196+
timeout-minutes: 5
197+
runs-on: ubuntu-latest
198+
permissions:
199+
statuses: write
200+
steps:
201+
- name: Set the commit status to pending
202+
env:
203+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
204+
run: |
205+
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
206+
-f state=pending -f context="Python (dispatched)" \
207+
-f description="Dispatched run in progress" \
208+
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
209+
210+
# `!cancelled()`: a run superseded by a newer dispatch posts nothing, and the
211+
# newer run reports instead. A job skipped by its own `if:` counts as passed.
212+
dispatch-status:
213+
name: Report the dispatched run's result
214+
if: github.event_name == 'workflow_dispatch' && !cancelled()
215+
needs:
216+
[
217+
dispatch-status-pending,
218+
detect-packages,
219+
script-tests,
220+
test,
221+
coverage,
222+
test-windows,
223+
build,
224+
]
225+
timeout-minutes: 5
226+
runs-on: ubuntu-latest
227+
permissions:
228+
statuses: write
229+
steps:
230+
- name: Set the commit status to the run's result
231+
env:
232+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
233+
NEEDS: ${{ toJSON(needs) }}
234+
run: |
235+
if jq -e 'all(.[]; .result == "success" or .result == "skipped")' <<<"$NEEDS" >/dev/null; then
236+
STATE=success DESCRIPTION="Every job passed"
237+
else
238+
STATE=failure DESCRIPTION="A job failed; open the run for details"
239+
fi
240+
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
241+
-f state="$STATE" -f context="Python (dispatched)" \
242+
-f description="$DESCRIPTION" \
243+
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"

‎.github/workflows/typescript.yml‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ on:
99
# that automation opens (Version Packages, Prepare Python Release) get no
1010
# push run. Their workflows dispatch this one on the PR's branch instead
1111
# (#5110): `workflow_dispatch` is the one event that token can start, and its
12-
# run reports its checks on the branch's head commit, which the PR shows.
12+
# run's checks attach to the branch's head commit. The rollup a PR reads
13+
# leaves dispatched checks out, so the `dispatch-status` jobs below report
14+
# the run as a commit status instead.
1315
workflow_dispatch:
1416

1517
# Superseded runs on the same ref are cancelled (e.g. rapid amend-pushes),
@@ -206,3 +208,62 @@ jobs:
206208
207209
- name: Boot every server
208210
run: npm run smoke
211+
212+
# A dispatched run's checks attach to the branch's head commit but are left
213+
# out of its status rollup, which is what a pull request reads (verified on
214+
# #5110: 29 successful dispatched check runs, a rollup of null). So on a
215+
# dispatch, which is how a version PR opened by automation gets CI, these two
216+
# jobs mirror the run onto the commit as a status, which the rollup does
217+
# include: pending at the start, then the result of every job above. A push
218+
# run reports through its own checks and skips both.
219+
dispatch-status-pending:
220+
name: Report the dispatched run as pending
221+
if: github.event_name == 'workflow_dispatch'
222+
timeout-minutes: 5
223+
runs-on: ubuntu-latest
224+
permissions:
225+
statuses: write
226+
steps:
227+
- name: Set the commit status to pending
228+
env:
229+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
230+
run: |
231+
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
232+
-f state=pending -f context="TypeScript (dispatched)" \
233+
-f description="Dispatched run in progress" \
234+
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
235+
236+
# `!cancelled()`: a run superseded by a newer dispatch posts nothing, and the
237+
# newer run reports instead. A job skipped by its own `if:` counts as passed.
238+
dispatch-status:
239+
name: Report the dispatched run's result
240+
if: github.event_name == 'workflow_dispatch' && !cancelled()
241+
needs:
242+
[
243+
dispatch-status-pending,
244+
root-guards,
245+
detect-packages,
246+
validate,
247+
coverage,
248+
test-windows,
249+
smoke,
250+
]
251+
timeout-minutes: 5
252+
runs-on: ubuntu-latest
253+
permissions:
254+
statuses: write
255+
steps:
256+
- name: Set the commit status to the run's result
257+
env:
258+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
259+
NEEDS: ${{ toJSON(needs) }}
260+
run: |
261+
if jq -e 'all(.[]; .result == "success" or .result == "skipped")' <<<"$NEEDS" >/dev/null; then
262+
STATE=success DESCRIPTION="Every job passed"
263+
else
264+
STATE=failure DESCRIPTION="A job failed; open the run for details"
265+
fi
266+
gh api "repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \
267+
-f state="$STATE" -f context="TypeScript (dispatched)" \
268+
-f description="$DESCRIPTION" \
269+
-f target_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"

‎RELEASING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ node scripts/prepare-python-release.mjs # prints one "name: old -> new" line
3939
### PRs opened by these workflows
4040

4141
> [!NOTE]
42-
> Both workflows push their PR's branch with the workflow token, and a push made with that token starts no workflow, so each one then dispatches the TypeScript and Python workflows on that branch (`workflow_dispatch` is the one event the token can start). Their checks report on the PR's head commit; wait for them to pass before merging. Closing and reopening the PR does not start them: that fires `pull_request`, and those workflows run on `push`. To run them again by hand: `gh workflow run typescript.yml --ref <branch>` (and `python.yml`). The Version Packages PR's body is rewritten on every push to `v2/main`, so it is tied to the release issue by a comment (`Part of #N`) instead of a body line. The repository setting **Settings → Actions → General → Allow GitHub Actions to create and approve pull requests** must be on, or the workflows fail at the step that opens the PR.
42+
> Both workflows push their PR's branch with the workflow token, and a push made with that token starts no workflow, so each one then dispatches the TypeScript and Python workflows on that branch (`workflow_dispatch` is the one event the token can start). A PR does not list dispatched checks, so each dispatched run also reports itself on the PR's head commit as a status, `TypeScript (dispatched)` and `Python (dispatched)`; wait for both to pass before merging. Closing and reopening the PR does not start them: that fires `pull_request`, and those workflows run on `push`. To run them again by hand: `gh workflow run typescript.yml --ref <branch>` (and `python.yml`). The Version Packages PR's body is rewritten on every push to `v2/main`, so it is tied to the release issue by a comment (`Part of #N`) instead of a body line. The repository setting **Settings → Actions → General → Allow GitHub Actions to create and approve pull requests** must be on, or the workflows fail at the step that opens the PR.
4343
4444
## How publishing works
4545

0 commit comments

Comments
 (0)