Add a small gap between the threshold and the coverage #5
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: Maven tests | |
on: | |
pull_request: | |
push: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4 | |
with: | |
java-version: '21' | |
distribution: 'zulu' | |
cache: maven | |
- name: Run Maven tests | |
run: | | |
mvn clean install -DskipTests | |
modules=("dubbo-common" | |
"dubbo-serialization/dubbo-serialization-hessian2" | |
"dubbo-serialization/dubbo-serialization-fastjson2" | |
"dubbo-remoting/dubbo-remoting-api" | |
"dubbo-metrics/dubbo-metrics-api" | |
"dubbo-config/dubbo-config-api") | |
for module in "${modules[@]}"; do | |
echo "Running tests for $module" | |
mvn -B verify -Pjacoco -f $module/pom.xml | |
done | |
- name: Get JaCoCo Coverage | |
id: COVERAGE | |
run: | | |
coverage1=$(python3 config/coverage.py dubbo-common/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE1=$coverage1" >> $GITHUB_ENV | |
coverage2=$(python3 config/coverage.py dubbo-serialization/dubbo-serialization-hessian2/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE2=$coverage2" >> $GITHUB_ENV | |
coverage3=$(python3 config/coverage.py dubbo-serialization/dubbo-serialization-fastjson2/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE3=$coverage3" >> $GITHUB_ENV | |
coverage4=$(python3 config/coverage.py dubbo-remoting/dubbo-remoting-api/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE4=$coverage4" >> $GITHUB_ENV | |
coverage5=$(python3 config/coverage.py dubbo-metrics/dubbo-metrics-api/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE5=$coverage5" >> $GITHUB_ENV | |
coverage6=$(python3 config/coverage.py dubbo-config/dubbo-config-api/target/site/jacoco/jacoco.csv) | |
echo "COVERAGE6=$coverage6" >> $GITHUB_ENV | |
- name: Fail if coverage has not improved. | |
run: | | |
threshold1=65.38 | |
threshold2=56.79 | |
threshold3=68.38 | |
threshold4=53.44 | |
threshold5=34.24 | |
threshold6=74.58 | |
if (( $(echo "$COVERAGE1 - $threshold1 > 0.1" | bc -l) )); then | |
echo "New coverage for the module dubbo-common - $COVERAGE1%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE2 - $threshold2 > 0.1" | bc -l) )); then | |
echo "New coverage for the module dubbo-serialization-hessian2 - $COVERAGE2%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE3 - $threshold3 > 0.1" | bc -l) )); then | |
echo "New coverage for the module dubbo-serialization-fastjson2 - $COVERAGE3%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE4 - $threshold4 > 0.1" | bc -l) )); then | |
echo "New coverage for the module dubbo-remoting-api - $COVERAGE4%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE5 - $threshold5 > 0.1" | bc -l) )); then | |
echo "New coverage for the module dubbo-metrics-api - $COVERAGE5%. Coverage is improved!" | |
elif (( $(echo "$COVERAGE6 - $threshold6 > 0.1" | bc -l) )); then | |
echo "New coverage for the module dubbo-config-api - $COVERAGE6%. Coverage is improved!" | |
else | |
echo "Coverage is not improved." | |
exit 1 | |
fi |