Skip to content

Commit

Permalink
Enable coverage reports (#1623)
Browse files Browse the repository at this point in the history
* Enable coverage reports

* Fix renaming
  • Loading branch information
Vlatombe authored Nov 29, 2024
1 parent 53bf958 commit 3fdd064
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ stage('Tests') {
try {
writeFile file: (split.includes ? "$WORKSPACE_TMP/includes.txt" : "$WORKSPACE_TMP/excludes.txt"), text: split.list.join("\n")
writeFile file: (split.includes ? "$WORKSPACE_TMP/excludes.txt" : "$WORKSPACE_TMP/includes.txt"), text: ''
sh './kind.sh -Dsurefire.includesFile="$WORKSPACE_TMP/includes.txt" -Dsurefire.excludesFile="$WORKSPACE_TMP/excludes.txt"'
sh './kind.sh -Penable-jacoco -Dsurefire.includesFile="$WORKSPACE_TMP/includes.txt" -Dsurefire.excludesFile="$WORKSPACE_TMP/excludes.txt"'
junit 'target/surefire-reports/*.xml'
withEnv(['NUM=' + num]) {
sh '''
for f in $(find . -name jacoco.exec)
do
mv "$f" "$(echo "$f" | sed s/jacoco./jacoco-$NUM./)"
done
'''
}
if (num == 0) {
stash name: 'classes', includes: '**/target/classes/**'
}
stash name: 'coverage-exec-' + num, allowEmpty: true, includes: '**/target/jacoco*.exec'
} finally {
dir(env.WORKSPACE_TMP) {
if (fileExists('kindlogs/docker-info.txt')) {
Expand All @@ -52,6 +64,17 @@ stage('Tests') {
}
}
parallel branches
stage('aggregate coverage') {
node('maven-17') {
checkout scm
unstash 'classes'
for (int i = 0; i < splits.size(); i++) {
unstash 'coverage-exec-' + i
}
sh 'mvn -B -ntp -P merge-jacoco-reports validate'
recordCoverage(tools: [[parser: 'JACOCO', pattern: '**/jacoco/jacoco.xml']], sourceCodeRetention: 'MODIFIED')
}
}
}
// Stage part of the library
infra.maybePublishIncrementals()
42 changes: 42 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,46 @@
</plugins>
</build>

<profiles>
<profile>
<id>merge-jacoco-reports</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>merge</goal>
</goals>
<phase>validate</phase>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>jacoco-*.exec</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</execution>
<execution>
<id>build-report</id>
<goals>
<goal>report</goal>
</goals>
<phase>validate</phase>
<configuration>
<formats>XML</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit 3fdd064

Please sign in to comment.