4848 php-version : ${{ steps.resolve.outputs.php-version }}
4949 php-version-source : ${{ steps.resolve.outputs.php-version-source }}
5050 test-matrix : ${{ steps.resolve.outputs.test-matrix }}
51- run-tests : ${{ steps.scope.outputs.run-tests }}
52- test-scope-reason : ${{ steps.scope.outputs.reason }}
5351
5452 steps :
5553 - uses : actions/checkout@v6
56- with :
57- fetch-depth : 0
5854 - name : Checkout dev-tools workflow action source
5955 uses : actions/checkout@v6
6056 with :
6864 id : resolve
6965 uses : ./.dev-tools-actions/.github/actions/php/resolve-version
7066
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-
11267 tests :
11368 needs : resolve_php
11469 name : Run Tests
11974 TESTS_ROOT_VERSION : ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
12075 steps :
12176 - uses : actions/checkout@v6
122- if : needs.resolve_php.outputs.run-tests == 'true'
12377 - name : Checkout dev-tools workflow action source
124- if : needs.resolve_php.outputs.run-tests == 'true'
12578 uses : actions/checkout@v6
12679 with :
12780 repository : php-fast-forward/dev-tools
13184 .github/actions
13285
13386 - name : Setup PHP and install dependencies
134- if : needs.resolve_php.outputs.run-tests == 'true'
13587 uses : ./.dev-tools-actions/.github/actions/php/setup-composer
13688 with :
13789 php-version : ${{ matrix.php-version }}
@@ -141,29 +93,21 @@ jobs:
14193 install-options : --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
14294
14395 - name : Composer Audit
144- if : needs.resolve_php.outputs.run-tests == 'true'
14596 env :
14697 COMPOSER_ROOT_VERSION : ${{ env.TESTS_ROOT_VERSION }}
14798 run : composer audit
14899
149100 - name : Resolve minimum coverage
150- if : needs.resolve_php.outputs.run-tests == 'true'
151101 id : minimum-coverage
152102 run : echo "value=${INPUT_MIN_COVERAGE:-80}" >> "$GITHUB_OUTPUT"
153103 env :
154104 INPUT_MIN_COVERAGE : ${{ inputs.min-coverage }}
155105
156106 - name : Run PHPUnit tests
157- if : needs.resolve_php.outputs.run-tests == 'true'
158107 env :
159108 COMPOSER_ROOT_VERSION : ${{ env.TESTS_ROOT_VERSION }}
160109 run : composer dev-tools tests -- --coverage=.dev-tools/coverage --min-coverage=${{ steps.minimum-coverage.outputs.value }}
161110
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-
167111 dependency-health :
168112 needs : resolve_php
169113 name : Dependency Health
@@ -172,9 +116,7 @@ jobs:
172116 TESTS_ROOT_VERSION : ${{ github.event_name == 'pull_request' && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
173117 steps :
174118 - uses : actions/checkout@v6
175- if : needs.resolve_php.outputs.run-tests == 'true'
176119 - name : Checkout dev-tools workflow action source
177- if : needs.resolve_php.outputs.run-tests == 'true'
178120 uses : actions/checkout@v6
179121 with :
180122 repository : php-fast-forward/dev-tools
@@ -184,24 +126,17 @@ jobs:
184126 .github/actions
185127
186128 - name : Setup PHP and install dependencies
187- if : needs.resolve_php.outputs.run-tests == 'true'
188129 uses : ./.dev-tools-actions/.github/actions/php/setup-composer
189130 with :
190131 php-version : ${{ needs.resolve_php.outputs.php-version }}
191132 root-version : ${{ env.TESTS_ROOT_VERSION }}
192133 install-options : --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
193134
194135 - name : Run dependency health check
195- if : needs.resolve_php.outputs.run-tests == 'true'
196136 env :
197137 COMPOSER_ROOT_VERSION : ${{ env.TESTS_ROOT_VERSION }}
198138 run : composer dev-tools dependencies -- --max-outdated=${{ inputs.max-outdated || -1 }}
199139
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-
205140 summarize :
206141 if : ${{ always() }}
207142 name : Summarize Test Workflow
@@ -229,8 +164,6 @@ jobs:
229164 - Workflow PHP version: `${{ needs.resolve_php.outputs.php-version }}`
230165 - PHP version source: `${{ needs.resolve_php.outputs.php-version-source }}`
231166 - 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 }}`
234167 - Minimum coverage threshold: `${{ inputs.min-coverage || 80 }}`
235168 - Dependency health `max-outdated`: `${{ inputs.max-outdated || -1 }}`
236169 - Tests job result: `${{ needs.tests.result }}`
0 commit comments