Skip to content

Commit e6d9906

Browse files
committed
chore(ci): improve Java CI workflow
1 parent 19123e5 commit e6d9906

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

.github/workflows/maven.yml

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,71 @@ on:
1010
branches: [ master ]
1111

1212
jobs:
13-
14-
compile:
13+
verify:
1514
runs-on: ubuntu-latest
1615
steps:
1716
- name: Checkout repository
1817
uses: actions/checkout@v4
19-
- name: Set up OpenJDK 21
20-
uses: actions/setup-java@v4
18+
19+
- name: Cache Git history
20+
uses: actions/cache@v4
2121
with:
22-
java-version: '21'
23-
distribution: 'adopt'
24-
cache: 'maven'
25-
- name: Compile with Maven
26-
run: mvn compile --file pom.xml
22+
path: .git
23+
key: ${{ runner.os }}-git-${{ github.sha }}
24+
restore-keys: |
25+
${{ runner.os }}-git-
2726
28-
verify:
29-
needs: compile
30-
runs-on: ubuntu-latest
31-
steps:
32-
- name: Checkout repository
33-
uses: actions/checkout@v4
3427
- name: Set up OpenJDK 21
3528
uses: actions/setup-java@v4
3629
with:
3730
java-version: '21'
3831
distribution: 'adopt'
3932
cache: 'maven'
40-
- name: Verify with Maven
33+
34+
- name: Cache local Maven repository
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/.m2/repository
38+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
39+
restore-keys: |
40+
${{ runner.os }}-maven-
41+
42+
- name: Compile and verify with Maven
4143
run: mvn verify --file pom.xml
44+
4245
- name: Upload JaCoCo coverage report artifact
4346
uses: actions/upload-artifact@v4
4447
with:
4548
name: jacoco.xml
4649
path: ./target/site/jacoco/jacoco.xml
4750

48-
coverage-codecov:
51+
coverage:
4952
needs: verify
5053
runs-on: ubuntu-latest
54+
strategy:
55+
matrix:
56+
service: [codecov, codacy]
5157
steps:
5258
- name: Checkout repository
5359
uses: actions/checkout@v4
60+
with:
61+
fetch-depth: ${{ matrix.service == 'codacy' && 0 || 1 }}
62+
5463
- name: Download JaCoCo coverage report artifact
5564
uses: actions/download-artifact@v4
5665
with:
5766
name: jacoco.xml
67+
5868
- name: Upload JaCoCo coverage report to Codecov
69+
if: matrix.service == 'codecov'
5970
uses: codecov/codecov-action@v5
6071
with:
6172
token: ${{ secrets.CODECOV_TOKEN }}
6273
files: jacoco.xml
6374

64-
coverage-codacy:
65-
needs: verify
66-
runs-on: ubuntu-latest
67-
steps:
68-
- name: Checkout repository
69-
uses: actions/checkout@v4
70-
- name: Download JaCoCo coverage report artifact
71-
uses: actions/download-artifact@v4
72-
with:
73-
name: jacoco.xml
7475
- name: Upload JaCoCo coverage report to Codacy
76+
if: matrix.service == 'codacy'
7577
uses: codacy/codacy-coverage-reporter-action@v1
7678
with:
7779
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
78-
coverage-reports: jacoco.xml
80+
force-coverage-parser: jacoco -r jacoco.xml

0 commit comments

Comments
 (0)