Skip to content

Commit d6e865f

Browse files
[ci] Mirror dispatched wiki tests as required statuses (#236)
* [ci] Mirror dispatched wiki tests as required statuses * Update wiki submodule pointer for PR #236 --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a1b837f commit d6e865f

6 files changed

Lines changed: 63 additions & 7 deletions

File tree

.github/wiki

Submodule wiki updated from 005922a to d8aa7ba

.github/workflows/tests.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313
required: false
1414
type: number
1515
default: -1
16+
publish-required-statuses:
17+
description: Mirror required test matrix checks as commit statuses for workflow-dispatched runs.
18+
required: false
19+
type: boolean
20+
default: false
1621
workflow_dispatch:
1722
inputs:
1823
min-coverage:
@@ -25,13 +30,19 @@ on:
2530
required: false
2631
type: number
2732
default: -1
33+
publish-required-statuses:
34+
description: Mirror required test matrix checks as commit statuses for workflow-dispatched runs.
35+
required: false
36+
type: boolean
37+
default: false
2838
pull_request:
2939
types: [opened, synchronize, reopened]
3040
push:
3141
branches: [ "main" ]
3242

3343
permissions:
3444
contents: read
45+
statuses: write
3546

3647
concurrency:
3748
group: ${{ github.event_name == 'pull_request' && format('tests-pr-{0}', github.event.pull_request.number) || format('tests-{0}', github.ref) }}
@@ -168,3 +179,35 @@ jobs:
168179
- Dependency health `max-outdated`: `${{ inputs.max-outdated || -1 }}`
169180
- Tests job result: `${{ needs.tests.result }}`
170181
- Dependency health result: `${{ needs.dependency-health.result }}`
182+
183+
publish_required_statuses:
184+
if: ${{ always() && inputs.publish-required-statuses }}
185+
name: Publish Required Test Statuses
186+
needs:
187+
- tests
188+
runs-on: ubuntu-latest
189+
steps:
190+
- name: Mirror required test matrix contexts
191+
env:
192+
GH_TOKEN: ${{ github.token }}
193+
TARGET_SHA: ${{ github.sha }}
194+
TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
195+
TESTS_RESULT: ${{ needs.tests.result }}
196+
run: |
197+
if [ "${TESTS_RESULT}" = "success" ]; then
198+
state="success"
199+
description="Workflow-dispatched PHPUnit matrix passed."
200+
else
201+
state="failure"
202+
description="Workflow-dispatched PHPUnit matrix result: ${TESTS_RESULT}."
203+
fi
204+
205+
for context in "Run Tests (8.3)" "Run Tests (8.4)" "Run Tests (8.5)"; do
206+
gh api \
207+
--method POST \
208+
"repos/${GITHUB_REPOSITORY}/statuses/${TARGET_SHA}" \
209+
-f state="${state}" \
210+
-f context="${context}" \
211+
-f description="${description}" \
212+
-f target_url="${TARGET_URL}"
213+
done

.github/workflows/wiki-preview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
env:
117117
GH_TOKEN: ${{ github.token }}
118118
HEAD_REF: ${{ github.event.pull_request.head.ref }}
119-
run: gh workflow run tests.yml --ref "${HEAD_REF}" -f max-outdated=-1
119+
run: gh workflow run tests.yml --ref "${HEAD_REF}" -f max-outdated=-1 -f publish-required-statuses=true
120120

121121
- uses: ./.dev-tools-actions/.github/actions/summary/write
122122
with:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Keep required PHPUnit matrix checks reporting after workflow-managed `.github/wiki` pointer commits by running the pull-request test workflow without top-level path filters and aligning the packaged consumer test wrapper (#230)
1313
- Ignore intentional Composer Dependency Analyser shadow dependency findings by default while adding `dependencies --show-shadow-dependencies` for audits (#233)
1414
- Dispatch the required test workflow after wiki preview automation updates a pull-request `.github/wiki` pointer, avoiding permanently pending required checks on bot-authored pointer commits (#230)
15+
- Mirror workflow-dispatched wiki pointer test results into required `Run Tests` commit statuses so branch protection recognizes bot-authored pointer commits (#230)
1516

1617
## [1.21.0] - 2026-04-24
1718

docs/advanced/branch-protection-and-bot-commits.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,12 @@ does not start another ``pull_request`` or ``push`` workflow run for commits
106106
pushed with the built-in workflow token. After the wiki preview workflow commits
107107
a parent-repository pointer update, it explicitly dispatches ``tests.yml`` for
108108
the pull request head branch so the newest bot-authored commit receives the
109-
required ``Run Tests`` matrix checks. Test workflow concurrency cancels older
110-
in-progress runs for the same pull request so the newest commit owns the
111-
required check contexts.
109+
required ``Run Tests`` matrix checks. Because manually dispatched workflow check
110+
runs are not always treated as pull-request required checks, that dispatched
111+
test run also mirrors the matrix result into commit statuses named
112+
``Run Tests (8.3)``, ``Run Tests (8.4)``, and ``Run Tests (8.5)``. Test workflow
113+
concurrency cancels older in-progress runs for the same pull request so the
114+
newest commit owns the required check contexts.
112115

113116
At a high level, the workflows need permission to read repository contents,
114117
write generated preview commits, update pull request comments, and publish Pages
@@ -122,8 +125,10 @@ The reusable workflows default to read-only repository access and grant write
122125
permissions at the job level when generated content must be pushed or pull
123126
requests must be updated.
124127

125-
``tests.yml`` only needs ``contents: read`` because it checks out code, installs
126-
dependencies, and runs PHPUnit.
128+
``tests.yml`` needs ``contents: read`` because it checks out code, installs
129+
dependencies, and runs PHPUnit. It also declares ``statuses: write`` so
130+
workflow-dispatched test runs can mirror required matrix contexts onto
131+
bot-authored wiki pointer commits.
127132

128133
``reports.yml`` keeps ``contents: write`` on jobs that publish or clean
129134
``gh-pages`` content. The pull request preview comment runs as a separate job

resources/github-actions/tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ on:
1414
required: false
1515
type: number
1616
default: -1
17+
publish-required-statuses:
18+
description: Mirror required test matrix checks as commit statuses for workflow-dispatched runs.
19+
required: false
20+
type: boolean
21+
default: false
1722

1823
permissions:
1924
contents: read
25+
statuses: write
2026

2127
jobs:
2228
tests:
2329
uses: php-fast-forward/dev-tools/.github/workflows/tests.yml@main
2430
with:
2531
max-outdated: ${{ inputs.max-outdated || -1 }}
32+
publish-required-statuses: ${{ inputs.publish-required-statuses || false }}
2633
secrets: inherit

0 commit comments

Comments
 (0)