Skip to content

Commit 79825b0

Browse files
test cov
1 parent 67070ee commit 79825b0

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: Java CI with Code Coverage
22

3+
4+
35
on:
46
push:
57
branches:
68
- feat/CS-36689-compare-merge-branch
9+
710
jobs:
811
build-and-test:
912
runs-on: ubuntu-latest
@@ -12,36 +15,40 @@ jobs:
1215
- name: Checkout code
1316
uses: actions/checkout@v2
1417

15-
- name: Set up JDK 11
18+
- name: Set up JDK 17
1619
uses: actions/setup-java@v2
1720
with:
18-
java-version: 11
21+
java-version: 17
1922

2023
- name: Build with Maven
2124
run: mvn clean package
2225

2326
- name: Run Tests with JaCoCo
24-
run: mvn jacoco:prepare-agent jacoco:report
27+
run: mvn jacoco:prepare-agent test jacoco:report
2528

26-
- name: Publish JaCoCo Report
27-
uses: PavanMudigonda/jacoco-reporter@v4.8
28-
29-
- name: Fail if Coverage Below Threshold
30-
id: coverage_check
29+
- name: Check Code Coverage
3130
run: |
3231
total_lines=$(xmllint --xpath 'string(//counter[@type="LINE"]/@covered)' target/site/jacoco/jacoco.xml)
3332
total_lines=${total_lines:-0}
3433
total_missed=$(xmllint --xpath 'string(//counter[@type="LINE"]/@missed)' target/site/jacoco/jacoco.xml)
3534
total_missed=${total_missed:-0}
36-
total_percentage=$(awk "BEGIN { pc=100*${total_lines}/${total_lines} } { printf \"%f\", pc }")
37-
echo "::set-output name=coverage_percentage::$total_percentage"
38-
if (( $(bc <<< "$total_percentage < 70.0") )); then
39-
echo "Coverage is below 80% - failing the build."
35+
total_percentage=$(awk "BEGIN { pc=100*${total_lines}/(${total_lines}+${total_missed}) } { printf \"%f\", pc }")
36+
echo "Total Coverage Percentage: $total_percentage"
37+
if (( $(bc <<< "$total_percentage < 80.0") )); then
38+
echo "Code Coverage is below 80% - failing the build."
4039
exit 1
40+
else
41+
echo "Code Coverage is satisfactory - proceeding with the build."
4142
fi
4243
4344
- name: Upload Code Coverage Report
4445
uses: actions/upload-artifact@v2
4546
with:
4647
name: code-coverage-report
4748
path: target/site/jacoco
49+
50+
- name: Deploy to GitHub Pages
51+
uses: peaceiris/actions-gh-pages@v3
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
publish_dir: target/site/jacoco

0 commit comments

Comments
 (0)