Skip to content

Commit 6dc2242

Browse files
committed
new workflow
1 parent 9f0a743 commit 6dc2242

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

.github/workflows/jacoco-badge.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 }}

.github/workflows/main.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ jobs:
3636
- name: Run Tests with Gradle
3737
run: ./gradlew test
3838

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-
4839
- name: Publish Test Results
4940
uses: actions/upload-artifact@v4
5041
with:

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ jar.enabled = true
4343

4444
jacocoTestReport {
4545
reports {
46-
csv.required = true
46+
xml.required = true
47+
csv.required = false
4748
}
4849
}
4950

0 commit comments

Comments
 (0)