fix: make reusable workflow resilient to missing test runners

Detect whether pest, phpunit, or pint are installed before running them.
Repos without test runners will skip gracefully instead of failing with
"No such file or directory".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-02-23 04:55:04 +00:00
parent 9604b08d61
commit d231c72661
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -48,12 +48,23 @@ jobs:
- name: Run Pint
if: inputs.pint
run: vendor/bin/pint --test
run: |
if [ -f vendor/bin/pint ]; then
vendor/bin/pint --test
else
echo "Pint not installed, skipping"
fi
- name: Run tests
run: |
FLAGS="--ci"
if [ "${{ inputs.coverage }}" = "true" ]; then
FLAGS="$FLAGS --coverage"
if [ -f vendor/bin/pest ]; then
FLAGS="--ci"
if [ "${{ inputs.coverage }}" = "true" ]; then
FLAGS="$FLAGS --coverage"
fi
vendor/bin/pest $FLAGS
elif [ -f vendor/bin/phpunit ]; then
vendor/bin/phpunit
else
echo "No test runner found (pest or phpunit), skipping tests"
fi
vendor/bin/pest $FLAGS