Skip to content

Commit 50bdf21

Browse files
committed
Switch to manual run of JaCoCo and badge creation for GitHub
1 parent f0fd31c commit 50bdf21

File tree

3 files changed

+53
-56
lines changed

3 files changed

+53
-56
lines changed

.github/workflows/gradle-pr.yml

-24
This file was deleted.

.github/workflows/gradle.yml

+6-32
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Java CI with Gradle
22
on:
33
push:
44
branches: [ master ]
5+
pull_request:
6+
branches: [ master ]
57
workflow_dispatch:
68

79
jobs:
@@ -11,40 +13,12 @@ jobs:
1113
steps:
1214
- uses: actions/checkout@v4
1315

14-
- name: Set up JDK
16+
- name: Set up JDK 21
1517
uses: actions/setup-java@v4
1618
with:
17-
distribution: 'temurin'
18-
java-version: '21'
19-
cache: 'gradle'
20-
21-
- name: Grant execute permission for gradlew
22-
run: chmod +x gradlew
19+
distribution: temurin
20+
java-version: 21
21+
cache: gradle
2322

2423
- name: Build with Gradle
2524
run: ./gradlew githubWorkflowTest --no-daemon -i
26-
27-
- name: Run Test Coverage
28-
run: ./gradlew jacocoTestReport -i -PexecutionData='/home/runner/work/java-interview-coding/java-interview-coding/build/jacoco/jacocoTest.exec'
29-
30-
- name: Generate JaCoCo Badge
31-
uses: cicirello/jacoco-badge-generator@v2
32-
with:
33-
generate-branches-badge: true
34-
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
35-
36-
- name: Commit the badge (if it changed)
37-
run: |
38-
if [[ `git status --porcelain` ]]; then
39-
git config --global user.name 'Github workflow'
40-
git config --global user.email 'nowhere@gmail.com'
41-
git add -A
42-
git commit -m "Autogenerated JaCoCo coverage badge"
43-
git push
44-
fi
45-
46-
- name: Upload JaCoCo coverage report
47-
uses: actions/upload-artifact@v4
48-
with:
49-
name: jacoco-report
50-
path: build/jacocoHtml/

.github/workflows/test-coverage.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Java CI with Gradle
2+
on:
3+
push:
4+
branches: [ master ]
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up JDK 21
15+
uses: actions/setup-java@v4
16+
with:
17+
distribution: temurin
18+
java-version: 21
19+
cache: gradle
20+
21+
- name: Build with Gradle
22+
run: ./gradlew githubWorkflowTest --no-daemon -i
23+
24+
- name: Run Test Coverage
25+
run: ./gradlew jacocoTestReport -i -PexecutionData='/home/runner/work/java-interview-coding/java-interview-coding/build/jacoco/jacocoTest.exec'
26+
27+
- name: Generate JaCoCo Badge
28+
uses: cicirello/jacoco-badge-generator@v2
29+
with:
30+
generate-branches-badge: true
31+
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
32+
33+
- name: Commit the badge (if it changed)
34+
run: |
35+
if [[ `git status --porcelain` ]]; then
36+
git config --global user.name 'Github workflow'
37+
git config --global user.email 'nowhere@gmail.com'
38+
git add -A
39+
git commit -m "Autogenerated JaCoCo coverage badge"
40+
git push
41+
fi
42+
43+
- name: Upload JaCoCo coverage report
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: jacoco-report
47+
path: build/jacocoHtml/

0 commit comments

Comments
 (0)