Skip to content

Commit eab9368

Browse files
committed
fix: publish wiki test statuses incrementally
1 parent 11c6573 commit eab9368

2 files changed

Lines changed: 34 additions & 15 deletions

File tree

.github/workflows/tests.yml

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
name: Run Tests
8181
runs-on: ubuntu-latest
8282
strategy:
83+
fail-fast: false
8384
matrix: ${{ fromJson(needs.resolve_php.outputs.test-matrix) }}
8485
env:
8586
TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
@@ -119,6 +120,31 @@ jobs:
119120
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
120121
run: composer dev-tools tests -- --coverage=.dev-tools/coverage --min-coverage=${{ steps.minimum-coverage.outputs.value }}
121122

123+
- name: Publish required test status
124+
if: ${{ always() && inputs.publish-required-statuses }}
125+
env:
126+
GH_TOKEN: ${{ github.token }}
127+
TARGET_SHA: ${{ github.sha }}
128+
TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
129+
TEST_CONTEXT: Run Tests (${{ matrix.php-version }})
130+
TEST_RESULT: ${{ job.status }}
131+
run: |
132+
if [ "${TEST_RESULT}" = "success" ]; then
133+
state="success"
134+
description="Workflow-dispatched PHPUnit job passed."
135+
else
136+
state="failure"
137+
description="Workflow-dispatched PHPUnit job result: ${TEST_RESULT}."
138+
fi
139+
140+
gh api \
141+
--method POST \
142+
"repos/${GITHUB_REPOSITORY}/statuses/${TARGET_SHA}" \
143+
-f state="${state}" \
144+
-f context="${TEST_CONTEXT}" \
145+
-f description="${description}" \
146+
-f target_url="${TARGET_URL}"
147+
122148
dependency-health:
123149
needs: resolve_php
124150
name: Dependency Health
@@ -184,30 +210,22 @@ jobs:
184210
if: ${{ always() && inputs.publish-required-statuses }}
185211
name: Publish Required Test Statuses
186212
needs:
187-
- tests
213+
- resolve_php
188214
runs-on: ubuntu-latest
189215
steps:
190-
- name: Mirror required test matrix contexts
216+
- name: Publish pending required test statuses
191217
env:
192218
GH_TOKEN: ${{ github.token }}
193219
TARGET_SHA: ${{ github.sha }}
194220
TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
195-
TESTS_RESULT: ${{ needs.tests.result }}
221+
TEST_MATRIX: ${{ needs.resolve_php.outputs.test-matrix }}
196222
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
223+
php -r "foreach (json_decode(getenv('TEST_MATRIX'), true, 512, JSON_THROW_ON_ERROR)['php-version'] as \$version) { echo \$version, PHP_EOL; }" | while IFS= read -r php_version; do
206224
gh api \
207225
--method POST \
208226
"repos/${GITHUB_REPOSITORY}/statuses/${TARGET_SHA}" \
209-
-f state="${state}" \
210-
-f context="${context}" \
211-
-f description="${description}" \
227+
-f state="pending" \
228+
-f context="Run Tests (${php_version})" \
229+
-f description="Workflow-dispatched PHPUnit job is pending." \
212230
-f target_url="${TARGET_URL}"
213231
done

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
- Keep the reports workflow permission warning loop shell-safe for paths containing backslashes (#244)
1818
- 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)
19+
- Publish pending and per-version required PHPUnit statuses for workflow-dispatched test runs so wiki pointer commits do not wait for an all-matrix aggregate status (#230)
1920
- Ignore intentional Composer Dependency Analyser shadow dependency findings by default while adding `dependencies --show-shadow-dependencies` for audits (#233)
2021
- 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)
2122
- Mirror workflow-dispatched wiki pointer test results into required `Run Tests` commit statuses so branch protection recognizes bot-authored pointer commits (#230)

0 commit comments

Comments
 (0)