Skip to content

Commit 38b24d9

Browse files
Update GitHub Actions workflow for unit testing: modify JaCoCo report paths and adjust test execution parameters to ensure accurate coverage reporting and validation.
1 parent be5827b commit 38b24d9

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

.github/workflows/unit-testing.yml

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,58 +33,52 @@ jobs:
3333
- name: Run unit tests (excluding integration tests)
3434
run: |
3535
echo "Running unit tests only (excluding *IT.java files)..."
36-
mvn clean test -Dtest='!*IT' -Dgpg.skip=true
36+
echo "Note: Surefire plugin has skipTests=true by default, overriding with -DskipTests=false"
37+
mvn clean test -DskipTests=false -Dtest='Test*' -Dgpg.skip=true
3738
continue-on-error: false
3839

39-
- name: Generate JaCoCo coverage report
40-
run: |
41-
echo "Generating JaCoCo report..."
42-
mvn jacoco:report -Dgpg.skip=true
43-
echo "✅ Coverage report generated"
44-
if: always()
45-
4640
- name: Verify JaCoCo reports generated
4741
run: |
4842
echo "Checking for JaCoCo reports..."
4943
echo "Current directory: $(pwd)"
5044
echo "Target directory contents:"
5145
ls -la target/ || echo "No target directory found"
52-
if [ -d "target/site/jacoco" ]; then
46+
if [ -d "target/jacoco-ut" ]; then
5347
echo "JaCoCo directory contents:"
54-
ls -lh target/site/jacoco/
48+
ls -lh target/jacoco-ut/
5549
fi
56-
if [ ! -f "target/site/jacoco/jacoco.xml" ]; then
57-
echo "❌ Error: jacoco.xml not found"
50+
if [ ! -f "target/jacoco-ut/jacoco.xml" ]; then
51+
echo "❌ Error: jacoco.xml not found in target/jacoco-ut/"
5852
echo "This usually means tests didn't run or JaCoCo plugin isn't configured correctly"
5953
exit 1
6054
fi
61-
if [ ! -f "target/site/jacoco/jacoco.csv" ]; then
55+
if [ ! -f "target/jacoco-ut/jacoco.csv" ]; then
6256
echo "⚠️ Warning: jacoco.csv not found (badge generation will be skipped)"
6357
fi
64-
echo "✅ JaCoCo XML report found"
58+
echo "✅ JaCoCo XML report found in target/jacoco-ut/"
6559
if: always()
6660

6761
- name: Generate JaCoCo Badge
6862
id: jacoco
6963
uses: cicirello/jacoco-badge-generator@v2
70-
if: hashFiles('target/site/jacoco/jacoco.csv') != ''
64+
if: hashFiles('target/jacoco-ut/jacoco.csv') != ''
7165
continue-on-error: true
7266
with:
73-
jacoco-csv-file: target/site/jacoco/jacoco.csv
67+
jacoco-csv-file: target/jacoco-ut/jacoco.csv
7468
badges-directory: .github/badges
7569
generate-branches-badge: true
7670
generate-summary: true
7771

7872
- name: Check coverage thresholds
7973
id: coverage-check
80-
if: hashFiles('target/site/jacoco/jacoco.xml') != ''
74+
if: hashFiles('target/jacoco-ut/jacoco.xml') != ''
8175
run: |
8276
echo "Checking coverage thresholds (unit tests only)..."
8377
# Extract coverage percentages from JaCoCo XML report (using sed for cross-platform compatibility)
84-
INSTRUCTION_COVERAGE=$(sed -n 's/.*type="INSTRUCTION".*covered="\([0-9]*\)".*/\1/p' target/site/jacoco/jacoco.xml | tail -1)
85-
INSTRUCTION_MISSED=$(sed -n 's/.*type="INSTRUCTION".*missed="\([0-9]*\)".*/\1/p' target/site/jacoco/jacoco.xml | tail -1)
86-
BRANCH_COVERAGE=$(sed -n 's/.*type="BRANCH".*covered="\([0-9]*\)".*/\1/p' target/site/jacoco/jacoco.xml | tail -1)
87-
BRANCH_MISSED=$(sed -n 's/.*type="BRANCH".*missed="\([0-9]*\)".*/\1/p' target/site/jacoco/jacoco.xml | tail -1)
78+
INSTRUCTION_COVERAGE=$(sed -n 's/.*type="INSTRUCTION".*covered="\([0-9]*\)".*/\1/p' target/jacoco-ut/jacoco.xml | tail -1)
79+
INSTRUCTION_MISSED=$(sed -n 's/.*type="INSTRUCTION".*missed="\([0-9]*\)".*/\1/p' target/jacoco-ut/jacoco.xml | tail -1)
80+
BRANCH_COVERAGE=$(sed -n 's/.*type="BRANCH".*covered="\([0-9]*\)".*/\1/p' target/jacoco-ut/jacoco.xml | tail -1)
81+
BRANCH_MISSED=$(sed -n 's/.*type="BRANCH".*missed="\([0-9]*\)".*/\1/p' target/jacoco-ut/jacoco.xml | tail -1)
8882
8983
# Calculate percentages
9084
INSTRUCTION_TOTAL=$((INSTRUCTION_COVERAGE + INSTRUCTION_MISSED))
@@ -138,7 +132,7 @@ jobs:
138132
if: always()
139133
with:
140134
paths: |
141-
${{ github.workspace }}/target/site/jacoco/jacoco.xml
135+
${{ github.workspace }}/target/jacoco-ut/jacoco.xml
142136
token: ${{ secrets.GITHUB_TOKEN }}
143137
min-coverage-overall: 90
144138
min-coverage-changed-files: 80
@@ -150,7 +144,7 @@ jobs:
150144
if: always()
151145
with:
152146
name: jacoco-report
153-
path: target/site/jacoco/
147+
path: target/jacoco-ut/
154148

155149
- name: Fail if coverage thresholds not met
156150
if: steps.coverage-check.outputs.threshold_met == 'false'

0 commit comments

Comments
 (0)