Skip to content

Commit ec1a14d

Browse files
committed
fix jacoco
1 parent a7ef3ef commit ec1a14d

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 23 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:
@@ -35,51 +35,47 @@ jobs:
3535
distribution: 'temurin'
3636
java-version: '11'
3737

38-
- name: Set Executable Permissions for Binary Files
39-
run: |
40-
chmod +x src/main/resources/cx-linux
41-
chmod +x src/main/resources/cx.exe
42-
chmod +x src/main/resources/cx-mac
43-
4438
- name: Check existence of cx-linux binary
4539
run: |
4640
if [ ! -f "src/main/resources/cx-linux" ]; then
47-
echo "cx-linux binary does not exist"; exit 1;
41+
echo "cx-linux binary does not exist"; exit 1;
4842
fi
49-
5043
- name: Check existence of cx.exe binary
5144
run: |
5245
if [ ! -f "src/main/resources/cx.exe" ]; then
5346
echo "cx.exe binary does not exist"; exit 1;
5447
fi
55-
5648
- name: Check existence of cx-mac binary
5749
run: |
5850
if [ ! -f "src/main/resources/cx-mac" ]; then
5951
echo "cx-mac binary does not exist"; exit 1;
6052
fi
6153
62-
- name: Run tests with Maven and Generate Coverage Report
63-
run: |
64-
mvn clean verify -Dgpg.skip
65-
mvn jacoco:report -Dgpg.skip
54+
- name: Install xmllint
55+
run: sudo apt-get install -y libxml2-utils
56+
57+
- name: Run tests with JaCoCo
58+
run: mvn test jacoco:report
6659
env:
67-
CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID }}
68-
CX_CLIENT_SECRET: ${{ secrets.CX_CLIENT_SECRET }}
60+
CX_CLIENT_ID: ${{ secrets.CX_CLIENT_ID}}
61+
CX_CLIENT_SECRET: ${{ secrets.CX_CLIENT_SECRET}}
6962
CX_BASE_URI: ${{ secrets.CX_BASE_URI }}
7063
CX_TENANT: ${{ secrets.CX_TENANT }}
7164
CX_APIKEY: ${{ secrets.CX_APIKEY }}
7265

73-
- name: Display Coverage Summary
66+
- name: Print total coverage percentage
7467
run: |
75-
echo "Code Coverage Summary:"
76-
grep -A 10 "Total" target/site/jacoco/jacoco.csv || echo "Coverage report not found."
68+
COVERED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@covered)" target/site/jacoco/jacoco.xml)
69+
MISSED_LINES=$(xmllint --xpath "string(//report/counter[@type='LINE']/@missed)" target/site/jacoco/jacoco.xml)
70+
TOTAL_LINES=$((COVERED_LINES + MISSED_LINES))
71+
COVERAGE_PERCENTAGE=$(echo "scale=2; $COVERED_LINES / $TOTAL_LINES * 100" | bc)
72+
echo "Total coverage percentage: $COVERAGE_PERCENTAGE%"
7773
78-
- name: Upload JaCoCo Coverage Report
79-
uses: actions/upload-artifact@v4
74+
- name: Upload JaCoCo coverage report
75+
uses: actions/upload-artifact@v3
8076
with:
81-
name: jacoco-report
82-
path: target/site/jacoco/*
77+
name: jacoco-coverage-report
78+
path: target/site/jacoco
8379

8480
- name: Build with Maven
8581
run: mvn -B verify -DskipTests -Dgpg.skip --file pom.xml

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@
7373
</execution>
7474
<execution>
7575
<id>report</id>
76-
<phase>verify</phase>
76+
<phase>test</phase>
7777
<goals>
7878
<goal>report</goal>
7979
</goals>
80+
<configuration>
81+
<includes>
82+
<include>**/src/main/java/**</include>
83+
<!-- Add other patterns as needed -->
84+
</includes>
85+
</configuration>
8086
</execution>
8187
</executions>
8288
</plugin>

0 commit comments

Comments
 (0)