Skip to content

Commit

Permalink
Extract scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Dec 23, 2024
1 parent dc4cc72 commit 6bac3f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 34 deletions.
18 changes: 1 addition & 17 deletions .github/workflows/shared-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/shared-publish-to-maven-versioned.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
19 changes: 19 additions & 0 deletions scripts/compile_java_test_and_verify.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 6bac3f5

Please sign in to comment.