Skip to content

Commit 6f359b3

Browse files
committed
ci: move PHP version lookup to env for readability
1 parent 7bbaf78 commit 6f359b3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ jobs:
2727
GITHUB_ACTIONS: true
2828
PHPUNIT_PROJECT: src/PHPUnit/__tests__/fixtures/phpunit-stub
2929
PEST_PROJECT: src/PHPUnit/__tests__/fixtures/pest-stub
30+
# Minimum PHP version per stub (used to skip incompatible installs)
31+
PHPUNIT_MIN_PHP: v9=7.3 v10=8.1 v11=8.2 v12=8.3
32+
PEST_MIN_PHP: v2=8.2 v3=8.2 v4=8.3
3033

3134
steps:
3235
- name: Checkout
@@ -63,35 +66,31 @@ jobs:
6366

6467
- name: Install Composer dependencies (PHPUnit stubs)
6568
run: |
66-
# PHPUnit minimum PHP version lookup
67-
declare -A MIN_PHP=([v9]=7.3 [v10]=8.1 [v11]=8.2 [v12]=8.3)
68-
PHP=${{ matrix.php }}
69+
declare -A MIN_PHP=(${{ env.PHPUNIT_MIN_PHP }})
6970
for dir in $(ls -d ${{ env.PHPUNIT_PROJECT }}/v*/ | sort -V); do
7071
stub=$(basename "$dir")
7172
min=${MIN_PHP[$stub]:-99}
72-
if php -r "exit(version_compare('$PHP','$min','>=') ? 0 : 1);"; then
73+
if php -r "exit(version_compare('${{ matrix.php }}','$min','>=') ? 0 : 1);"; then
7374
echo "::group::Installing $stub (PHP >= $min)"
7475
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true
7576
echo "::endgroup::"
7677
else
77-
echo "Skipping $stub (requires PHP >= $min, have $PHP)"
78+
echo "Skipping $stub (requires PHP >= $min, have ${{ matrix.php }})"
7879
fi
7980
done
8081
8182
- name: Install Composer dependencies (Pest stubs)
8283
run: |
83-
# Pest minimum PHP version lookup
84-
declare -A MIN_PHP=([v2]=8.2 [v3]=8.2 [v4]=8.3)
85-
PHP=${{ matrix.php }}
84+
declare -A MIN_PHP=(${{ env.PEST_MIN_PHP }})
8685
for dir in $(ls -d ${{ env.PEST_PROJECT }}/v*/ | sort -V); do
8786
stub=$(basename "$dir")
8887
min=${MIN_PHP[$stub]:-99}
89-
if php -r "exit(version_compare('$PHP','$min','>=') ? 0 : 1);"; then
88+
if php -r "exit(version_compare('${{ matrix.php }}','$min','>=') ? 0 : 1);"; then
9089
echo "::group::Installing $stub (PHP >= $min)"
9190
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true
9291
echo "::endgroup::"
9392
else
94-
echo "Skipping $stub (requires PHP >= $min, have $PHP)"
93+
echo "Skipping $stub (requires PHP >= $min, have ${{ matrix.php }})"
9594
fi
9695
done
9796

0 commit comments

Comments
 (0)