diff --git a/.github/workflows/shared-build-and-test.yaml b/.github/workflows/shared-build-and-test.yaml index 1507cd1d..470e141a 100644 --- a/.github/workflows/shared-build-and-test.yaml +++ b/.github/workflows/shared-build-and-test.yaml @@ -40,23 +40,7 @@ jobs: if: ${{ inputs.vulnerability_scan_only == 'false' }} 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!" + bash uid2-shared-actions/scripts/compile_java_test_and_verify.sh - name: Generate code coverage if: ${{ inputs.vulnerability_scan_only == 'false' }} diff --git a/.github/workflows/shared-publish-to-maven-versioned.yaml b/.github/workflows/shared-publish-to-maven-versioned.yaml index 90ba569f..aa33e34c 100644 --- a/.github/workflows/shared-publish-to-maven-versioned.yaml +++ b/.github/workflows/shared-publish-to-maven-versioned.yaml @@ -113,25 +113,11 @@ jobs: - name: Compile if: ${{ inputs.publish_to_maven != true }} + env: + EXTRA_FLAGS: "-s settings.xml -Dgpg.passphrase=\"${{ secrets.GPG_PASSPHRASE }}\"" run: | cd ./${{ inputs.working_dir }} - mvn -B -s settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" 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!" + bash uid2-shared-actions/scripts/compile_java_test_and_verify.sh - name: Commit pom.xml and version.json if: ${{ steps.checkRelease.outputs.is_release != 'true' }} diff --git a/scripts/compile_java_test_and_verify.sh b/scripts/compile_java_test_and_verify.sh new file mode 100644 index 00000000..a42614f3 --- /dev/null +++ b/scripts/compile_java_test_and_verify.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +mvn -B $EXTRA_FLAGS 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!" \ No newline at end of file