fix(ci): test failures should fail the build (#3019)

The 'Check if tests exist' step was actually running tests with
continue-on-error: true. If tests failed, it would set has-tests=false
and skip the actual test step, making CI appear green even with failing tests.

Simplified to use 'npm test --if-present' which:
- Runs tests if a test script exists (and fails if tests fail)
- Does nothing and exits 0 if no test script exists
- Removes the need for the complex check logic

Fixes the issue where PR #3014 had failing tests but CI was green.
This commit is contained in:
adam jones
2025-11-17 21:41:31 +00:00
committed by GitHub
parent ec5357226a
commit 28a313206c

View File

@@ -41,21 +41,9 @@ jobs:
working-directory: src/${{ matrix.package }}
run: npm ci
- name: Check if tests exist
id: check-tests
working-directory: src/${{ matrix.package }}
run: |
if npm run test --silent 2>/dev/null; then
echo "has-tests=true" >> $GITHUB_OUTPUT
else
echo "has-tests=false" >> $GITHUB_OUTPUT
fi
continue-on-error: true
- name: Run tests
if: steps.check-tests.outputs.has-tests == 'true'
working-directory: src/${{ matrix.package }}
run: npm test
run: npm test --if-present
build:
needs: [detect-packages, test]