File tree Expand file tree Collapse file tree 3 files changed +49
-10
lines changed Expand file tree Collapse file tree 3 files changed +49
-10
lines changed Original file line number Diff line number Diff line change
1
+ name : Generate JaCoCo Coverage Badge
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ pull_request :
8
+ branches :
9
+ - master
10
+
11
+ jobs :
12
+ generate-badge :
13
+ runs-on : ubuntu-latest
14
+
15
+ steps :
16
+ - name : Checkout Repository
17
+ uses : actions/checkout@v4
18
+
19
+ - name : Set up JDK 17
20
+ uses : actions/setup-java@v4
21
+ with :
22
+ java-version : ' 17'
23
+ distribution : ' temurin'
24
+
25
+ - name : Build and Test with Gradle
26
+ run : ./gradlew clean test jacocoTestReport
27
+
28
+ - name : Generate Coverage Badge
29
+ uses : cicirello/jacoco-badge-generator@v1
30
+ with :
31
+ jacoco-report-path : ' build/reports/jacoco/test/jacocoTestReport.xml'
32
+ badge-path : ' README.md' # Path to your README.md
33
+ badge-position : ' TOP' # Position in README (e.g., TOP, BOTTOM)
34
+ coverage-badges :
35
+ low : ' red'
36
+ medium : ' yellow'
37
+ high : ' brightgreen'
38
+
39
+ - name : Commit and Push Changes
40
+ run : |
41
+ git config --local user.name "github-actions[bot]"
42
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
43
+ git add README.md
44
+ git commit -m "Update JaCoCo coverage badge [ci skip]" || echo "No changes to commit"
45
+ git push
46
+ env :
47
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 36
36
- name : Run Tests with Gradle
37
37
run : ./gradlew test
38
38
39
- - name : Run Test Coverage
40
- run : ./gradlew jacocoTestReport
41
-
42
- - name : Generate JaCoCo Badge
43
- uses : cicirello/jacoco-badge-generator@v2
44
- with :
45
- generate-branches-badge : true
46
- jacoco-csv-file : build/reports/jacoco/test/jacocoTestReport.csv
47
-
48
39
- name : Publish Test Results
49
40
uses : actions/upload-artifact@v4
50
41
with :
Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ jar.enabled = true
43
43
44
44
jacocoTestReport {
45
45
reports {
46
- csv. required = true
46
+ xml. required = true
47
+ csv. required = false
47
48
}
48
49
}
49
50
You can’t perform that action at this time.
0 commit comments