Skip to content

Commit 25ba940

Browse files
authored
fix(ci): make composer check:strict able to fail on tests (#16)
test:unit and test:all ended in ./vendor/bin/phpunit --colors=always || echo 'No PHP test suite in this repo ... skipping...' so phpunit's exit status was discarded unconditionally. The message was true today (this repo is a Python ExApp wrapper with no PHP test suite) but the mechanism was not conditional on it: any real test failure, now or after a test suite is added, would have been swallowed the same way. Replaced with a guard on the actual precondition, so an absent suite is a visible stated fact and a present-but-failing suite fails the gate: if [ -f phpunit.xml ] || [ -f phpunit.xml.dist ]; then ./vendor/bin/phpunit --colors=always; else echo 'SKIPPED: no phpunit.xml ...'; fi Positive control, measured on this tree in a PHP 8.3.32 container with a freshly installed vendor/, injecting a phpunit.xml plus one deliberately failing test: old composer.json + failing test -> check:strict exit 0 (swallowed) new composer.json + failing test -> check:strict exit 1, naming test:all new composer.json, test removed -> check:strict exit 0, loud SKIPPED Tooling only.
1 parent a1e9206 commit 25ba940

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"phpmetrics:violations": "./vendor/bin/phpmetrics --violations-xml=phpmetrics/violations.xml phpcs-custom-sniffs",
2626
"psalm": "./vendor/bin/psalm --threads=1 --no-cache",
2727
"phpstan": "./vendor/bin/phpstan analyse --memory-limit=1G",
28-
"test:unit": "./vendor/bin/phpunit --colors=always || echo 'No PHP test suite in this repo (no phpunit.xml, no tests/) - skipping...'",
29-
"test:all": "./vendor/bin/phpunit --colors=always || echo 'No PHP test suite in this repo (no phpunit.xml, no tests/) - skipping...'",
28+
"test:unit": "if [ -f phpunit.xml ] || [ -f phpunit.xml.dist ]; then ./vendor/bin/phpunit --colors=always; else echo 'SKIPPED: no phpunit.xml in this repo - there is no PHP test suite to run'; fi",
29+
"test:all": "if [ -f phpunit.xml ] || [ -f phpunit.xml.dist ]; then ./vendor/bin/phpunit --colors=always; else echo 'SKIPPED: no phpunit.xml in this repo - there is no PHP test suite to run'; fi",
3030
"check": "E=0; for CMD in lint phpcs psalm test:unit; do echo; echo \"=== $CMD ===\"; composer $CMD || E=1; done; echo; if [ $E -eq 0 ]; then echo \"ALL CHECKS PASSED\"; else echo \"SOME CHECKS FAILED (see above)\"; fi; exit $E",
3131
"check:full": "E=0; for CMD in lint phpcs psalm phpstan test:all; do echo; echo \"=== $CMD ===\"; composer $CMD || E=1; done; echo; if [ $E -eq 0 ]; then echo \"ALL CHECKS PASSED\"; else echo \"SOME CHECKS FAILED (see above)\"; fi; exit $E",
3232
"check:strict": "E=0; for CMD in lint phpcs phpmd psalm phpstan test:all; do echo; echo \"=== $CMD ===\"; composer $CMD || E=1; done; echo; if [ $E -eq 0 ]; then echo \"ALL CHECKS PASSED\"; else echo \"SOME CHECKS FAILED (see above)\"; fi; exit $E",

0 commit comments

Comments
 (0)