Skip to content

Commit 4d66306

Browse files
committed
[ci] Keep required tests reporting after wiki pointer commits (#230)
1 parent 58e2022 commit 4d66306

4 files changed

Lines changed: 90 additions & 8 deletions

File tree

.github/workflows/tests.yml

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ on:
2626
type: number
2727
default: -1
2828
pull_request:
29-
paths:
30-
- 'src/**'
31-
- 'tests/**'
32-
- 'composer.json'
33-
- 'composer.lock'
34-
- '.github/actions/**'
35-
- '.github/workflows/tests.yml'
29+
types: [opened, synchronize, reopened]
3630
push:
3731
branches: [ "main" ]
3832

@@ -41,7 +35,7 @@ permissions:
4135

4236
concurrency:
4337
group: ${{ github.event_name == 'pull_request' && format('tests-pr-{0}', github.event.pull_request.number) || format('tests-{0}', github.ref) }}
44-
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
38+
cancel-in-progress: false
4539

4640
env:
4741
FORCE_COLOR: '1'
@@ -54,9 +48,13 @@ jobs:
5448
php-version: ${{ steps.resolve.outputs.php-version }}
5549
php-version-source: ${{ steps.resolve.outputs.php-version-source }}
5650
test-matrix: ${{ steps.resolve.outputs.test-matrix }}
51+
run-tests: ${{ steps.scope.outputs.run-tests }}
52+
test-scope-reason: ${{ steps.scope.outputs.reason }}
5753

5854
steps:
5955
- uses: actions/checkout@v6
56+
with:
57+
fetch-depth: 0
6058
- name: Checkout dev-tools workflow action source
6159
uses: actions/checkout@v6
6260
with:
@@ -70,6 +68,47 @@ jobs:
7068
id: resolve
7169
uses: ./.dev-tools-actions/.github/actions/php/resolve-version
7270

71+
- name: Resolve test workflow scope
72+
id: scope
73+
shell: bash
74+
env:
75+
BASE_SHA: ${{ github.event.pull_request.base.sha || '' }}
76+
run: |
77+
set -euo pipefail
78+
79+
if [ "${GITHUB_EVENT_NAME}" != "pull_request" ]; then
80+
{
81+
echo "run-tests=true"
82+
echo "reason=non-pull-request-event"
83+
} >> "$GITHUB_OUTPUT"
84+
85+
exit 0
86+
fi
87+
88+
git fetch --no-tags --depth=1 origin "${BASE_SHA}"
89+
git diff --name-only "${BASE_SHA}...HEAD" > changed-files.txt
90+
91+
run_tests=false
92+
while IFS= read -r changed_file; do
93+
case "${changed_file}" in
94+
src/*|tests/*|composer.json|composer.lock|.github/actions/*|.github/workflows/tests.yml|resources/github-actions/tests.yml)
95+
run_tests=true
96+
break
97+
;;
98+
esac
99+
done < changed-files.txt
100+
101+
if [ "${run_tests}" = "true" ]; then
102+
reason="test-sensitive-pr-diff"
103+
else
104+
reason="no-test-sensitive-pr-diff"
105+
fi
106+
107+
{
108+
echo "run-tests=${run_tests}"
109+
echo "reason=${reason}"
110+
} >> "$GITHUB_OUTPUT"
111+
73112
tests:
74113
needs: resolve_php
75114
name: Run Tests
@@ -80,7 +119,9 @@ jobs:
80119
TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
81120
steps:
82121
- uses: actions/checkout@v6
122+
if: needs.resolve_php.outputs.run-tests == 'true'
83123
- name: Checkout dev-tools workflow action source
124+
if: needs.resolve_php.outputs.run-tests == 'true'
84125
uses: actions/checkout@v6
85126
with:
86127
repository: php-fast-forward/dev-tools
@@ -90,6 +131,7 @@ jobs:
90131
.github/actions
91132
92133
- name: Setup PHP and install dependencies
134+
if: needs.resolve_php.outputs.run-tests == 'true'
93135
uses: ./.dev-tools-actions/.github/actions/php/setup-composer
94136
with:
95137
php-version: ${{ matrix.php-version }}
@@ -99,21 +141,29 @@ jobs:
99141
install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
100142

101143
- name: Composer Audit
144+
if: needs.resolve_php.outputs.run-tests == 'true'
102145
env:
103146
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
104147
run: composer audit
105148

106149
- name: Resolve minimum coverage
150+
if: needs.resolve_php.outputs.run-tests == 'true'
107151
id: minimum-coverage
108152
run: echo "value=${INPUT_MIN_COVERAGE:-80}" >> "$GITHUB_OUTPUT"
109153
env:
110154
INPUT_MIN_COVERAGE: ${{ inputs.min-coverage }}
111155

112156
- name: Run PHPUnit tests
157+
if: needs.resolve_php.outputs.run-tests == 'true'
113158
env:
114159
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
115160
run: composer dev-tools tests -- --coverage=.dev-tools/coverage --min-coverage=${{ steps.minimum-coverage.outputs.value }}
116161

162+
- name: Mark tests intentionally skipped
163+
if: needs.resolve_php.outputs.run-tests != 'true'
164+
run: |
165+
echo "No test-sensitive PR diff detected; required test context completed without running PHPUnit."
166+
117167
dependency-health:
118168
needs: resolve_php
119169
name: Dependency Health
@@ -122,7 +172,9 @@ jobs:
122172
TESTS_ROOT_VERSION: ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
123173
steps:
124174
- uses: actions/checkout@v6
175+
if: needs.resolve_php.outputs.run-tests == 'true'
125176
- name: Checkout dev-tools workflow action source
177+
if: needs.resolve_php.outputs.run-tests == 'true'
126178
uses: actions/checkout@v6
127179
with:
128180
repository: php-fast-forward/dev-tools
@@ -132,17 +184,24 @@ jobs:
132184
.github/actions
133185
134186
- name: Setup PHP and install dependencies
187+
if: needs.resolve_php.outputs.run-tests == 'true'
135188
uses: ./.dev-tools-actions/.github/actions/php/setup-composer
136189
with:
137190
php-version: ${{ needs.resolve_php.outputs.php-version }}
138191
root-version: ${{ env.TESTS_ROOT_VERSION }}
139192
install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
140193

141194
- name: Run dependency health check
195+
if: needs.resolve_php.outputs.run-tests == 'true'
142196
env:
143197
COMPOSER_ROOT_VERSION: ${{ env.TESTS_ROOT_VERSION }}
144198
run: composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || -1 }}
145199

200+
- name: Mark dependency health intentionally skipped
201+
if: needs.resolve_php.outputs.run-tests != 'true'
202+
run: |
203+
echo "No test-sensitive PR diff detected; dependency health completed without running dependency analysis."
204+
146205
summarize:
147206
if: ${{ always() }}
148207
name: Summarize Test Workflow
@@ -170,6 +229,8 @@ jobs:
170229
- Workflow PHP version: `${{ needs.resolve_php.outputs.php-version }}`
171230
- PHP version source: `${{ needs.resolve_php.outputs.php-version-source }}`
172231
- Test matrix: `${{ needs.resolve_php.outputs.test-matrix }}`
232+
- Test-sensitive diff: `${{ needs.resolve_php.outputs.run-tests }}`
233+
- Test scope reason: `${{ needs.resolve_php.outputs.test-scope-reason }}`
173234
- Minimum coverage threshold: `${{ inputs.min-coverage || 80 }}`
174235
- Dependency health `max-outdated`: `${{ inputs.max-outdated || -1 }}`
175236
- Tests job result: `${{ needs.tests.result }}`

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Keep Composer autoload, Rector, and ECS from traversing nested fixture `vendor` directories when the composer-plugin consumer fixture has installed dependencies (#179)
2525
- Skip LICENSE generation cleanly when a consumer composer manifest omits or leaves the `license` field empty (#227)
2626
- Run nested DevTools subprocesses without forcing PTY, fixing aggregate commands in non-interactive environments (#171)
27+
- Keep required PHPUnit matrix checks reporting after workflow-managed `.github/wiki` pointer commits by moving PR test-skip decisions inside the tests workflow, queueing same-PR test runs, and aligning the packaged consumer test wrapper (#230)
2728

2829
## [1.20.0] - 2026-04-23
2930

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ should either allow the workflow token to update PR branches or require authors
9696
to refresh generated pointers manually. The preferred path is to allow bot
9797
updates on PR branches while keeping ``main`` protected.
9898

99+
Required test checks must still report for workflow-managed pointer commits.
100+
The tests workflow therefore triggers on every pull request update and resolves
101+
whether the effective pull request diff contains test-sensitive files inside the
102+
workflow itself. If the latest commit only refreshes ``.github/wiki`` and the
103+
pull request has no source, test, Composer, test-workflow, packaged test-wrapper,
104+
or local-action changes, the required ``Run Tests`` matrix jobs complete with an
105+
intentional skip message instead of leaving branch protection waiting for
106+
missing checks. If the pull request does include test-sensitive changes, the
107+
matrix runs even when the newest commit is only the generated wiki pointer.
108+
109+
Test workflow concurrency queues runs for the same pull request instead of
110+
canceling in-progress jobs. This prevents the wiki-pointer run from canceling a
111+
source-change run and then completing with a lightweight skip before the real
112+
validation has reported.
113+
99114
At a high level, the workflows need permission to read repository contents,
100115
write generated preview commits, update pull request comments, and publish Pages
101116
content. Keep those permissions scoped to the workflow jobs that actually need

resources/github-actions/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: "Fast Forward Test Suite"
22

33
on:
44
push:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
510
workflow_dispatch:
611
inputs:
712
max-outdated:

0 commit comments

Comments
 (0)