Skip to content

Commit

Permalink
jacoco
Browse files Browse the repository at this point in the history
  • Loading branch information
oplekal committed Jun 5, 2024
1 parent a08a551 commit e580f68
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 113 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ jobs:
run: |
cd eperusteet/eperusteet-service
mvn clean verify -B
- name: Upload Coverage to Code Climate
if: ${{ github.ref_name == 'master' }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
cd eperusteet/eperusteet-service/src/main/java
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
./cc-test-reporter format-coverage -t jacoco --add-prefix src/main/java/ ../../../target/jacoco/jacoco.xml
./cc-test-reporter upload-coverage
- name: Upload eperusteet-service-jar
uses: actions/upload-artifact@v3
with:
Expand Down
197 changes: 84 additions & 113 deletions eperusteet/eperusteet-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<springfox.version>2.7.0</springfox.version>
<surefire.version>3.2.2</surefire.version>
<swagger-maven-plugin-version>3.1.7</swagger-maven-plugin-version>
<jacoco.version>0.8.12</jacoco.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -466,6 +467,11 @@
<artifactId>auditlogger</artifactId>
<version>8.3.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -523,28 +529,6 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>10.0.12</version>
<configuration>
<scan>0</scan>
<httpConnector>
<port>8080</port>
</httpConnector>
<webApp>
<contextPath>/eperusteet-service</contextPath>
<jettyEnvXml>${basedir}/src/test/config/jetty-env.xml</jettyEnvXml>
</webApp>
</configuration>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
Expand All @@ -558,13 +542,10 @@
</execution>
</executions>
<configuration>
<argLine>-Xmx2048m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC</argLine>
<!-- <parallel>classesAndMethods</parallel>-->
<!-- <useUnlimitedThreads>true</useUnlimitedThreads>-->
<argLine>-Dlog4j2.level=OFF -Xmx2048m -XX:+CMSClassUnloadingEnabled -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco-it.exec</argLine>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<reportFormat>plain</reportFormat>
<argLine>-Dlog4j2.level=OFF</argLine>
<systemPropertyVariables>
<eperusteet.ittestdb.user>${eperusteet.ittestdb.user}</eperusteet.ittestdb.user>
<eperusteet.ittestdb.password>${eperusteet.ittestdb.password}</eperusteet.ittestdb.password>
Expand All @@ -582,18 +563,11 @@
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Dlog4j2.level=OFF</argLine>
<!-- <argLine>${surefireArgLine}</argLine>-->
<!-- <systemPropertyVariables>-->
<!-- <eperusteet.ittestdb.user>${eperusteet.ittestdb.user}</eperusteet.ittestdb.user>-->
<!-- <eperusteet.ittestdb.password>${eperusteet.ittestdb.password}</eperusteet.ittestdb.password>-->
<!-- <eperusteet.ittestdb.jdbcurl>${eperusteet.ittestdb.jdbcurl}</eperusteet.ittestdb.jdbcurl>-->
<!-- <log4j.configuration>${project.basedir}/src/test/resources/log4j.properties</log4j.configuration>-->
<!-- </systemPropertyVariables>-->
<excludes>
<exclude>**/service/test/*.java</exclude>
<exclude>**/*IT.java</exclude>
</excludes>
<argLine>-Dlog4j2.level=OFF -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${project.build.directory}/jacoco-ut.exec</argLine>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -622,6 +596,82 @@
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.build.directory}/jacoco</outputDirectory>
<formats>
<format>XML</format>
<format>HTML</format>
</formats>
</configuration>
</execution>
<execution>
<id>merge-files</id>
<phase>post-integration-test</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.build.directory}/jacoco</outputDirectory>
<formats>
<format>XML</format>
<format>HTML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -824,85 +874,6 @@
</plugins>
</build>
</profile>
<profile>
<id>jacoco</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>merge-files</id>
<phase>post-integration-test</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>local</id>
<properties>
<eperusteet.devdb.user>oph</eperusteet.devdb.user>
<eperusteet.devdb.password>test</eperusteet.devdb.password>
<eperusteet.devdb.jdbcurl>jdbc:postgresql://localhost:5432/eperusteet</eperusteet.devdb.jdbcurl>

<eperusteet-amosaa.devdb.user>oph</eperusteet-amosaa.devdb.user>
<eperusteet-amosaa.devdb.password>test</eperusteet-amosaa.devdb.password>
<eperusteet-amosaa.devdb.jdbcurl>jdbc:postgresql://localhost:5433/amosaa</eperusteet-amosaa.devdb.jdbcurl>

<eperusteet-ylops.devdb.user>oph</eperusteet-ylops.devdb.user>
<eperusteet-ylops.devdb.password>test</eperusteet-ylops.devdb.password>
<eperusteet-ylops.devdb.jdbcurl>jdbc:postgresql://localhost:5434/ylops</eperusteet-ylops.devdb.jdbcurl>
</properties>
</profile>
</profiles>

<distributionManagement>
Expand Down

0 comments on commit e580f68

Please sign in to comment.