Skip to content

Commit 979cc87

Browse files
[ci] Fix actionlint finding in reports workflow (#245)
* fix: satisfy actionlint in reports workflow * Update wiki submodule pointer for PR #245 * fix: publish wiki test statuses incrementally * docs: clarify workflow-dispatched test statuses --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 60a6b76 commit 979cc87

5 files changed

Lines changed: 43 additions & 21 deletions

File tree

.github/wiki

Submodule wiki updated from 716f76b to 6176cf7

.github/workflows/reports.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595

9696
- name: Fix permissions
9797
run: |
98-
chmod -c -R +rX "${REPORTS_TARGET}/" | while read line; do
98+
chmod -c -R +rX "${REPORTS_TARGET}/" | while IFS= read -r line; do
9999
echo "::warning title=Invalid file permissions automatically fixed::$line"
100100
done
101101

.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Fixed
1616

17+
- Keep the reports workflow permission warning loop shell-safe for paths containing backslashes (#244)
1718
- 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)
1820
- Ignore intentional Composer Dependency Analyser shadow dependency findings by default while adding `dependencies --show-shadow-dependencies` for audits (#233)
1921
- 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)
2022
- Mirror workflow-dispatched wiki pointer test results into required `Run Tests` commit statuses so branch protection recognizes bot-authored pointer commits (#230)

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ 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
109109
required ``Run Tests`` matrix checks. Because manually dispatched workflow check
110110
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.
111+
test run first publishes pending commit statuses for the resolved PHP matrix and
112+
then lets each matrix job publish its own final status. The status contexts use
113+
the same required-check names, such as ``Run Tests (8.3)``, ``Run Tests (8.4)``,
114+
and ``Run Tests (8.5)``. Test workflow concurrency cancels older in-progress
115+
runs for the same pull request so the newest commit owns the required check
116+
contexts.
115117

116118
The predictable-conflict workflow MAY also refresh pull request branches when
117119
the only conflicts are ``.github/wiki`` pointer drift and/or ``CHANGELOG.md``

0 commit comments

Comments
 (0)