Skip to content

Commit 4bc72fe

Browse files
committed
Added code coverage
1 parent 04f6fa5 commit 4bc72fe

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: AST Java Wrapper CI
22

3-
on: [ pull_request ]
3+
on: [pull_request]
44

55
jobs:
66
integration-tests:
@@ -21,7 +21,6 @@ jobs:
2121
- name: Checkout LFS objects
2222
run: git lfs checkout
2323

24-
2524
- name: Cache local Maven repository
2625
uses: actions/cache@v4
2726
with:
@@ -39,13 +38,15 @@ jobs:
3938
- name: Check existence of cx-linux binary
4039
run: |
4140
if [ ! -f "src/main/resources/cx-linux" ]; then
42-
echo "cx-linux binary does not exist"; exit 1;
41+
echo "cx-linux binary does not exist"; exit 1;
4342
fi
43+
4444
- name: Check existence of cx.exe binary
4545
run: |
4646
if [ ! -f "src/main/resources/cx.exe" ]; then
4747
echo "cx.exe binary does not exist"; exit 1;
4848
fi
49+
4950
- name: Check existence of cx-mac binary
5051
run: |
5152
if [ ! -f "src/main/resources/cx-mac" ]; then
@@ -55,13 +56,12 @@ jobs:
5556
- name: Run tests with Maven
5657
run: mvn -B test --file pom.xml
5758
env:
58-
CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID}}
59-
CX_CLIENT_SECRET: ${{ secrets.CX_CLIENT_SECRET}}
59+
CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID }}
60+
CX_CLIENT_SECRET: ${{ secrets.CX_CLIENT_SECRET }}
6061
CX_BASE_URI: ${{ secrets.CX_BASE_URI }}
6162
CX_TENANT: ${{ secrets.CX_TENANT }}
6263
CX_APIKEY: ${{ secrets.CX_APIKEY }}
6364

64-
6565
- name: Build with Maven
6666
run: mvn -B verify -DskipTests -Dgpg.skip --file pom.xml
6767

@@ -70,3 +70,36 @@ jobs:
7070
uses: jwgmeligmeyling/spotbugs-github-action@b8e2c3523acb34c87f14e18cbcd2d87db8c8584e #v1.2
7171
with:
7272
path: '**/spotbugsXml.xml'
73+
74+
code-coverage:
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Cache local Maven repository
81+
uses: actions/cache@v4
82+
with:
83+
path: ~/.m2/repository
84+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
85+
restore-keys: |
86+
${{ runner.os }}-maven-
87+
88+
- name: Set up JDK 11
89+
uses: actions/[email protected]
90+
with:
91+
distribution: 'temurin'
92+
java-version: '11'
93+
94+
- name: Generate and Display Code Coverage Report
95+
run: |
96+
mvn clean verify
97+
mvn jacoco:report
98+
echo "Code Coverage Summary:"
99+
grep -A 10 "Total" target/site/jacoco/jacoco.csv || echo "Coverage report not found."
100+
101+
- name: Upload JaCoCo Coverage Report
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: jacoco-report
105+
path: target/site/jacoco/*

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@
6161

6262
<build>
6363
<plugins>
64+
<plugin>
65+
<groupId>org.jacoco</groupId>
66+
<artifactId>jacoco-maven-plugin</artifactId>
67+
<version>0.8.8</version>
68+
<executions>
69+
<execution>
70+
<goals>
71+
<goal>prepare-agent</goal>
72+
</goals>
73+
</execution>
74+
<execution>
75+
<id>report</id>
76+
<phase>verify</phase>
77+
<goals>
78+
<goal>report</goal>
79+
</goals>
80+
</execution>
81+
</executions>
82+
</plugin>
6483
<plugin>
6584
<groupId>com.github.spotbugs</groupId>
6685
<artifactId>spotbugs-maven-plugin</artifactId>

0 commit comments

Comments
 (0)