Skip to content

Commit 306f031

Browse files
Enhance GitHub Actions workflow for unit testing: add JaCoCo report generation and verification steps, ensuring coverage reports are created and validating their existence before badge generation.
1 parent d128d84 commit 306f031

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.github/workflows/unit-testing.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,31 @@ jobs:
3333
- name: Run unit tests with coverage (excluding integration tests)
3434
run: |
3535
echo "Running unit tests only (excluding *IT.java files)..."
36-
mvn clean test -Dtest='!*IT' jacoco:report -Dgpg.skip=true
37-
echo "Unit tests completed"
38-
continue-on-error: true
36+
mvn clean test -Dtest='!*IT' -Dgpg.skip=true
37+
echo "Tests completed, generating JaCoCo report..."
38+
mvn jacoco:report -Dgpg.skip=true
39+
echo "✅ Unit tests and coverage report completed"
40+
41+
- name: Verify JaCoCo reports generated
42+
run: |
43+
echo "Checking for JaCoCo reports..."
44+
if [ ! -f "target/site/jacoco/jacoco.xml" ]; then
45+
echo "❌ Error: jacoco.xml not found"
46+
exit 1
47+
fi
48+
if [ ! -f "target/site/jacoco/jacoco.csv" ]; then
49+
echo "⚠️ Warning: jacoco.csv not found (badge generation will be skipped)"
50+
fi
51+
echo "✅ JaCoCo XML report found"
52+
ls -lh target/site/jacoco/
3953
4054
- name: Generate JaCoCo Badge
4155
id: jacoco
4256
uses: cicirello/jacoco-badge-generator@v2
57+
if: hashFiles('target/site/jacoco/jacoco.csv') != ''
58+
continue-on-error: true
4359
with:
60+
jacoco-csv-file: target/site/jacoco/jacoco.csv
4461
badges-directory: .github/badges
4562
generate-branches-badge: true
4663
generate-summary: true

0 commit comments

Comments
 (0)