test github action #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
pull_request: | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
# choosing to run a reduced set of LTS, current, and next, to balance coverage and execution time | |
java: [17] | |
fail-fast: false | |
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: 'zulu' | |
cache: 'maven' | |
- name: Maven Compile | |
run: mvn -X compile -B --file pom.xml | |
- name: Maven Verify | |
run: mvn -X verify -B --file pom.xml | |
- name: Get JaCoCo Coverage | |
id: coverage | |
run: | | |
coverage=$(python3 config/coverage.py target/site/jacoco/jacoco.csv) | |
echo "COVERAGE=$coverage" >> $GITHUB_ENV | |
- name: Fail if coverage has not improved. | |
run: | | |
coverage=$COVERAGE | |
threshold=90.41 | |
if (( $(echo "$coverage <= $threshold" | bc -l) )); then | |
echo "Coverage has not improved." | |
exit 1 | |
else | |
echo "New coverage: $coverage%" | |
fi |