Skip to content

Commit

Permalink
Add check for the number of tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Dec 19, 2024
1 parent 9305ba2 commit a1ca4d2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/shared-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,25 @@ jobs:

- name: Build and run unit tests
if: ${{ inputs.vulnerability_scan_only == 'false' }}
run: mvn -B clean compile test
working-directory: ${{ inputs.working_dir }}
run: |
mvn -B clean compile test | tee build.log
tests_run=$(cat build.log | grep "Tests run:" | tail -n 1 | sed 's/.*Tests run: \([0-9]*\).*/\1/')
echo "DEBUG: tests_run = $tests_run"
if [ -z "$tests_run" ]; then
echo "WARNING: Could not determine the number of tests run."
tests_run=0
fi
if [ "$tests_run" -eq 0 ]; then
echo "ERROR: No tests were run!"
exit 1
fi
echo "INFO: $tests_run tests were run!"
- name: Generate code coverage
if: ${{ inputs.vulnerability_scan_only == 'false' }}
Expand Down

0 comments on commit a1ca4d2

Please sign in to comment.