Skip to content

Commit 7bbaf78

Browse files
committed
ci: skip incompatible stubs based on PHP version lookup
- Define minimum PHP version per stub (e.g. PHPUnit v12 needs PHP >=8.3) - Skip composer install for stubs incompatible with matrix PHP version - Use composer install (lock file) instead of composer update - Use sort -V for correct version ordering (v9, v10, v11, v12)
1 parent 233cfe1 commit 7bbaf78

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

.github/workflows/tests.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,36 @@ jobs:
6363

6464
- name: Install Composer dependencies (PHPUnit stubs)
6565
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 }}
6669
for dir in $(ls -d ${{ env.PHPUNIT_PROJECT }}/v*/ | sort -V); do
67-
echo "::group::Installing $(basename "$dir")"
68-
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress --ignore-platform-reqs) || true
69-
echo "::endgroup::"
70+
stub=$(basename "$dir")
71+
min=${MIN_PHP[$stub]:-99}
72+
if php -r "exit(version_compare('$PHP','$min','>=') ? 0 : 1);"; then
73+
echo "::group::Installing $stub (PHP >= $min)"
74+
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true
75+
echo "::endgroup::"
76+
else
77+
echo "Skipping $stub (requires PHP >= $min, have $PHP)"
78+
fi
7079
done
7180
7281
- name: Install Composer dependencies (Pest stubs)
7382
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 }}
7486
for dir in $(ls -d ${{ env.PEST_PROJECT }}/v*/ | sort -V); do
75-
echo "::group::Installing $(basename "$dir")"
76-
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress --ignore-platform-reqs) || true
77-
echo "::endgroup::"
87+
stub=$(basename "$dir")
88+
min=${MIN_PHP[$stub]:-99}
89+
if php -r "exit(version_compare('$PHP','$min','>=') ? 0 : 1);"; then
90+
echo "::group::Installing $stub (PHP >= $min)"
91+
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true
92+
echo "::endgroup::"
93+
else
94+
echo "Skipping $stub (requires PHP >= $min, have $PHP)"
95+
fi
7896
done
7997
8098
- name: Install Dependencies

0 commit comments

Comments
 (0)