Add CI support for code coverage

This commit is contained in:
Stuart Douglas
2019-12-18 09:05:59 +11:00
committed by Guillaume Smet
parent 8b1a42aae4
commit 3a35468e20
5 changed files with 34 additions and 144 deletions

View File

@@ -1,5 +1,6 @@
parameters: parameters:
jdk: 1.8 jdk: 1.8
extra:
steps: steps:
- task: CacheBeta@0 #we know the very first job will have restored or created this, so this will never write built artifacts to the cache - task: CacheBeta@0 #we know the very first job will have restored or created this, so this will never write built artifacts to the cache

View File

@@ -95,10 +95,27 @@ stages:
steps: steps:
- template: jvm-build-steps.yaml - template: jvm-build-steps.yaml
parameters: parameters:
# we only generate the PDF documentation once for the initial JDK 8 build # we only generate the PDF documentation and test coverage once for the initial JDK 8 build
extra: '-Ddocumentation-pdf' extra: '-Ddocumentation-pdf -Ptest-coverage'
- publish: $(MAVEN_CACHE_FOLDER) - publish: $(MAVEN_CACHE_FOLDER)
artifact: $(Build.SourceVersion)-BuiltMavenRepo artifact: $(Build.SourceVersion)-BuiltMavenRepo
- task: Maven@3
displayName: 'Aggregate Code Coverage'
inputs:
mavenPomFile: 'coverage-report/pom.xml'
goals: 'install'
mavenOptions: $(MAVEN_OPTS)
options: '-B --settings azure-mvn-settings.xml -Dno-native -Dno-format'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'coverage-report/target/site/jacoco/jacoco.xml'
pathToSources: 'coverage-report/src/main/java'
reportDirectory: 'coverage-report/target/site/jacoco/'
failIfCoverageEmpty: true
- template: prepare-cache.yaml - template: prepare-cache.yaml
- stage: run_jvm_tests_stage${{parameters.expectUseVMs}} - stage: run_jvm_tests_stage${{parameters.expectUseVMs}}

View File

@@ -35,7 +35,7 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<executable>prepare.sh</executable> <executable>${project.basedir}/prepare.sh</executable>
<workingDirectory>${project.basedir}</workingDirectory> <workingDirectory>${project.basedir}</workingDirectory>
</configuration> </configuration>
</plugin> </plugin>
@@ -61,13 +61,6 @@
</fileSets> </fileSets>
</configuration> </configuration>
</execution> </execution>
<execution>
<id>compile-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>

View File

@@ -5,14 +5,24 @@ mkdir -p src/main/java
for j in '../extensions' '../core' '../devtools' '../independent-projects/' for j in '../extensions' '../core' '../devtools' '../independent-projects/'
do do
for i in `find $j -regex .*target/classes ` for i in `find $j -regex .*target/classes`
do do
cp -r $i/* target/classes/ cp -r $i/* target/classes/
done done
for i in `find $j -regex .*src/main/java ` for i in `find $j -regex .*src/main/java`
do do
cp -r $i/* src/main/java/ cp -r $i/* src/main/java/
done done
done done
#needed to make sure the script always suceeds
#we don't care about classes in the 'graal' package, because they are only used in native image generation
find target/classes/ -name graal -exec rm -r {} \;
#antlr generated code
rm -r target/classes/io/quarkus/panacheql/internal
#we don't care about the document processor
rm -r target/classes/io/quarkus/annotation/processor/generate_doc
#needed to make sure the script always succeeds
echo "complete" echo "complete"

131
pom.xml
View File

@@ -159,137 +159,6 @@
</plugins> </plugins>
</build> </build>
</profile> </profile>
<!--
JaCoCo based code coverage analysis
mvn -Pjacoco clean verify
mvn antrun:run@jacoco-all-in-one-report -Pjacoco-report
open target/jacoco-report/index.html
-->
<profile>
<id>jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>jacoco-prepare</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<includes>
<include>*</include>
</includes>
<excludes>
<exclude>io.quarkus.it.*</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>jacoco-report-per-module</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jacoco-report</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>copy</goal>
</goals>
<phase>process-test-resources</phase>
<inherited>false</inherited>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>${jacoco.version}</version>
</artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
<outputDirectory>${project.build.directory}/jacoco-jars</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.ant</artifactId>
<version>${jacoco.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>jacoco-all-in-one-report</id>
<phase>post-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<inherited>false</inherited>
<configuration>
<target>
<taskdef name="report" classname="org.jacoco.ant.ReportTask">
<classpath path="${project.build.directory}/jacoco-jars/org.jacoco.ant.jar"/>
</taskdef>
<echo>Creating JaCoCo for Quarkus code coverage reports</echo>
<report>
<executiondata>
<fileset dir="${basedir}">
<include name="**/target/jacoco.exec"/>
</fileset>
</executiondata>
<structure name="JaCoCo for Quarkus">
<classfiles>
<fileset dir="${basedir}">
<include name="**/*${project.version}.jar"/>
<exclude name="**/target/lib/*.jar"/>
<exclude name="independent-projects/**/*.jar"/>
<exclude name="integration-tests/**/*.jar"/>
<exclude name="**/*quarkus-cli-${project.version}.jar"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<dirset dir="${basedir}">
<include name="**/src/main/java"/>
</dirset>
</sourcefiles>
</structure>
<html destdir="target/jacoco-report"/>
<xml destfile="target/jacoco-report/report.xml"/>
</report>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>tcks</id> <id>tcks</id>
<activation> <activation>