Skip to content

Commit e3f06ac

Browse files
committed
test coverage merge
1 parent f7a41e3 commit e3f06ac

File tree

4 files changed

+68
-25
lines changed

4 files changed

+68
-25
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ indent_size = 2
66
insert_final_newline = true
77
charset = utf-8
88
end_of_line = lf
9+
trim_trailing_whitespace = true
910

1011
[{pom.xml,*.md}]
11-
indent_style = space
1212
indent_size = 4

.github/workflows/build.yml

+50-23
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ env:
1616

1717
jobs:
1818
build:
19+
if: github.event_name == 'push' || github.event.pull_request.head.repo.owner.login == 'dnsjava'
1920
strategy:
2021
fail-fast: false
2122
matrix:
2223
os: [ ubuntu-latest, windows-latest ]
2324
java: [ '17' ]
2425
arch: [ 'x64' ]
25-
include:
26-
- os: windows-latest
27-
java: '17'
28-
arch: x86
26+
# include:
27+
# - os: windows-latest
28+
# java: '17'
29+
# arch: x86
2930

3031
name: Java ${{ matrix.java }}/${{ matrix.arch }}/${{ matrix.os }}
3132
runs-on: ${{ matrix.os }}
@@ -44,29 +45,55 @@ jobs:
4445
distribution: temurin
4546
cache: maven
4647

47-
- name: Cache SonarCloud packages
48-
uses: actions/cache@v3
49-
with:
50-
path: ~/.sonar/cache
51-
key: ${{ runner.os }}-sonar
52-
restore-keys: ${{ runner.os }}-sonar
53-
5448
- name: Build with Maven
55-
if: ${{ !(matrix.arch == 'x64' && matrix.os == 'ubuntu-latest' && matrix.java == env.BUILD_JAVA_VERSION) }}
56-
run: mvn verify -B -"Dgpg.skip"
49+
run: |
50+
mvn verify -B -"Dgpg.skip" jacoco:report
51+
cp target/jacoco.exec target/jacoco-${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}.exec
5752
58-
- name: Build with Maven and run Sonar
59-
if: ${{ matrix.arch == 'x64' && matrix.os == 'ubuntu-latest' && matrix.java == env.BUILD_JAVA_VERSION }}
60-
env:
61-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
63-
run: mvn -B -"Dgpg.skip" test
64-
#jacoco:report org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
53+
- name: Publish Test Report
54+
if: always()
55+
uses: mikepenz/action-junit-report@v3
56+
with:
57+
report_paths: target/surefire-reports/TEST-*.xml
58+
require_tests: true
59+
check_retries: true
60+
detailed_summary: true
6561

66-
- name: Upload Test Report
62+
- name: Upload Coverage Report
6763
uses: actions/upload-artifact@v3
6864
if: always() # always run even if the previous step fails
6965
with:
70-
name: junit-test-results-${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}
71-
path: 'target/surefire-reports/TEST-*.xml'
66+
name: coverage-report-${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}
67+
path: 'target/jacoco-${{ matrix.java }}-${{ matrix.arch }}-${{ matrix.os }}.exec'
7268
retention-days: 1
69+
70+
analyze:
71+
name: Analyze Code
72+
runs-on: ubuntu-latest
73+
needs: build
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v3
77+
78+
- name: Get Artifacts
79+
uses: actions/download-artifact@v3
80+
81+
- name: Set up JDK
82+
uses: actions/setup-java@v3
83+
with:
84+
java-version: ${{ env.BUILD_JAVA_VERSION }}
85+
distribution: temurin
86+
cache: maven
87+
88+
- name: Cache SonarCloud packages
89+
uses: actions/cache@v3
90+
with:
91+
path: ~/.sonar/cache
92+
key: ${{ runner.os }}-sonar
93+
restore-keys: ${{ runner.os }}-sonar
94+
95+
- name: Merge JaCoCo and run SonarQube
96+
run: |
97+
mkdir target/coverage-reports
98+
mv coverage-report-*/target/*.exec target/
99+
mvn -B jacoco:merge org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

.github/workflows/junit-report.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: JUnit reporting
33
on:
44
workflow_run:
55
workflows:
6-
- 'Build'
76
- 'Build PR'
87
types:
98
- completed

pom.xml

+17
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@
192192
<goal>report</goal>
193193
</goals>
194194
</execution>
195+
<execution>
196+
<id>merge-results</id>
197+
<goals>
198+
<goal>merge</goal>
199+
</goals>
200+
<configuration>
201+
<fileSets>
202+
<fileSet>
203+
<directory>${project.build.directory}/coverage-reports</directory>
204+
<includes>
205+
<include>*.exec</include>
206+
</includes>
207+
</fileSet>
208+
</fileSets>
209+
<destFile>${project.build.directory}/jacoco.exec</destFile>
210+
</configuration>
211+
</execution>
195212
</executions>
196213
</plugin>
197214

0 commit comments

Comments
 (0)