Fix the equality check in coverage calculation #8
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: Build and Test | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
java-version: [ 22 ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java-version }} | |
distribution: temurin | |
- name: Cache Maven artifacts | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Cache node | |
uses: actions/cache@v3 | |
with: | |
path: web-bundle/node | |
key: ${{ runner.os }}-node-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os}}-node- | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: web-bundle/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/pom.xml', '**/package.json') }} | |
restore-keys: | | |
${{ runner.os}}-node_modules- | |
- name: Build ${{ matrix.java-version }} | |
run: mvn -B clean verify | |
- name: Get JaCoCo Coverage | |
id: COVERAGE | |
run: | | |
coverage1=$(python3 config/coverage.py core/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE1=$coverage1" >> $GITHUB_ENV | |
coverage2=$(python3 config/coverage.py reader-gtfs/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE2=$coverage2" >> $GITHUB_ENV | |
coverage3=$(python3 config/coverage.py web/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE3=$coverage3" >> $GITHUB_ENV | |
coverage4=$(python3 config/coverage.py web-api/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE4=$coverage4" >> $GITHUB_ENV | |
coverage5=$(python3 config/coverage.py navigation/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE5=$coverage5" >> $GITHUB_ENV | |
coverage6=$(python3 config/coverage.py client-hc/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE6=$coverage6" >> $GITHUB_ENV | |
- name: Fail if coverage has not improved. | |
run: | | |
threshold1=83.75 | |
threshold2=46.63 | |
threshold3=20.45 | |
threshold4=37.53 | |
threshold5=81.89 | |
threshold6=52.88 | |
if (( $(echo "$COVERAGE1 - $threshold1 > 0.1" | bc -l) )); then | |
echo "New coverage for the module core - $COVERAGE1%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE2 - $threshold2 > 0.1" | bc -l) )); then | |
echo "New coverage for the module reader-gtfs - $COVERAGE2%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE3 - $threshold3 > 0.1" | bc -l) )); then | |
echo "New coverage for module web - $COVERAGE3%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE4 - $threshold4 > 0.1" | bc -l) )); then | |
echo "New coverage for module web-api - $COVERAGE4%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE5 - $threshold5 > 0.1" | bc -l) )); then | |
echo "New coverage for module navigation - $COVERAGE5%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE6 - $threshold6 > 0.1" | bc -l) )); then | |
echo "New coverage for module client-hc - $COVERAGE6%. Coverage is improved!" | |
else | |
echo "Coverage is not improved." | |
exit 1 | |
fi |