From d47305f1f115ea24630972d4be072698af259c5b Mon Sep 17 00:00:00 2001 From: Olli-Pekka Lehtokallio Date: Tue, 4 Jun 2024 10:23:10 +0300 Subject: [PATCH] jacoco --- .github/workflows/build.yml | 13 ++++ .github/workflows/coverage.yml | 33 +++++++++ eperusteet/eperusteet-service/pom.xml | 100 +++++++++++++++++--------- 3 files changed, 112 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02dc761501..376b528130 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,6 +76,19 @@ jobs: run: | cd eperusteet/eperusteet-service mvn clean verify -B + - name: Upload Coverage to Code Climate + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + run: | + pwd + ls -latr + cd eperusteet/eperusteet-service/target + ls -latr + 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 eperusteet/eperusteet-service/target/jacoco.exec --input-type jacoco + ./cc-test-reporter upload-coverage - name: Upload eperusteet-service-jar uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..23484cdc94 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,33 @@ +name: Test Coverage + +on: [] + +jobs: + test-coverage: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + + - name: Build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd eperusteet/eperusteet-service + mvn clean verify -B + + - name: Upload Coverage to Code Climate + run: | + 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 target/jacoco.exec --input-type jacoco + ./cc-test-reporter upload-coverage + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} diff --git a/eperusteet/eperusteet-service/pom.xml b/eperusteet/eperusteet-service/pom.xml index 621973ea5f..262ee8f3e3 100644 --- a/eperusteet/eperusteet-service/pom.xml +++ b/eperusteet/eperusteet-service/pom.xml @@ -48,6 +48,7 @@ 2.7.0 3.2.2 3.1.7 + 0.8.12 @@ -466,6 +467,11 @@ auditlogger 8.3.1-SNAPSHOT + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + @@ -523,28 +529,6 @@ - - org.eclipse.jetty - jetty-maven-plugin - 10.0.12 - - 0 - - 8080 - - - /eperusteet-service - ${basedir}/src/test/config/jetty-env.xml - - - - - org.postgresql - postgresql - ${postgresql.version} - - - org.apache.maven.plugins maven-failsafe-plugin @@ -558,13 +542,10 @@ - -Xmx2048m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC - - + -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 3 true plain - -Dlog4j2.level=OFF ${eperusteet.ittestdb.user} ${eperusteet.ittestdb.password} @@ -582,18 +563,11 @@ 3 true - -Dlog4j2.level=OFF - - - - - - - **/service/test/*.java **/*IT.java + -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 @@ -622,6 +596,63 @@ + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + + + pre-unit-test + + prepare-agent + + + ${project.build.directory}/jacoco-ut.exec + surefireArgLine + + + + pre-integration-test + pre-integration-test + + prepare-agent + + + ${project.build.directory}/jacoco-it.exec + failsafeArgLine + + + + merge-files + post-integration-test + + merge + + + + + ${project.build.directory} + + *.exec + + + + ${project.build.directory}/jacoco.exec + + + + post-integration-test + post-integration-test + + report + + + ${project.build.directory}/jacoco.exec + ${project.reporting.outputDirectory}/jacoco + + + + @@ -831,6 +862,7 @@ org.jacoco jacoco-maven-plugin + ${jacoco.version} pre-unit-test