From 33245088d28ad245835ebd354595a9874d73f028 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Sun, 2 Aug 2026 23:43:18 +0200 Subject: [PATCH] fix(ci): make composer check:strict able to fail on tests 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. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6272975..d397cb4 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "phpmetrics:violations": "./vendor/bin/phpmetrics --violations-xml=phpmetrics/violations.xml phpcs-custom-sniffs", "psalm": "./vendor/bin/psalm --threads=1 --no-cache", "phpstan": "./vendor/bin/phpstan analyse --memory-limit=1G", - "test:unit": "./vendor/bin/phpunit --colors=always || echo 'No PHP test suite in this repo (no phpunit.xml, no tests/) - skipping...'", - "test:all": "./vendor/bin/phpunit --colors=always || echo 'No PHP test suite in this repo (no phpunit.xml, no tests/) - skipping...'", + "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", + "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", "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", "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", "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",