diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9acde76..b6116fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,6 @@ jobs: - name: Checkout LFS objects run: git lfs checkout - - name: Cache local Maven repository uses: actions/cache@v4 with: @@ -52,8 +51,11 @@ jobs: echo "cx-mac binary does not exist"; exit 1; fi - - name: Run tests with Maven - run: mvn -B test --file pom.xml + - name: Install xmllint + run: sudo apt-get install -y libxml2-utils + + - name: Run tests with JaCoCo + run: mvn test jacoco:report env: CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID}} CX_CLIENT_SECRET: ${{ secrets.CX_CLIENT_SECRET}} @@ -61,6 +63,19 @@ jobs: CX_TENANT: ${{ secrets.CX_TENANT }} CX_APIKEY: ${{ secrets.CX_APIKEY }} + - name: Print total coverage percentage + run: | + COVERED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@covered)" target/site/jacoco/jacoco.xml) + MISSED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@missed)" target/site/jacoco/jacoco.xml) + TOTAL_LINES=$((COVERED_LINES + MISSED_LINES)) + COVERAGE_PERCENTAGE=$(echo "scale=2; $COVERED_LINES / $TOTAL_LINES * 100" | bc) + echo "Total coverage percentage: $COVERAGE_PERCENTAGE%" + + - name: Upload JaCoCo coverage report + uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 #v4 + with: + name: jacoco-coverage-report + path: target/site/jacoco - name: Build with Maven run: mvn -B verify -DskipTests -Dgpg.skip --file pom.xml diff --git a/pom.xml b/pom.xml index 58aaaa0..dafdd06 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,31 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.8 + + + + prepare-agent + + + + report + test + + report + + + + **/src/main/java/** + + + + + + com.github.spotbugs spotbugs-maven-plugin