Commit a7a1d0c4 authored by Matija Obreza's avatar Matija Obreza
Browse files

CI: Produce aggregate JaCoCo report

parent 70098c05
include:
# https://docs.gitlab.com/ce/ci/yaml/README.html#workflowrules-templates
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
variables: variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log. # This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work. # `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true" MAVEN_OPTS: "-server -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used # As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line. # when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins. # `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" MAVEN_CLI_OPTS: "--batch-mode --errors --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
# Cache downloaded dependencies and plugins between builds. # Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"' # To keep cache across branches add 'key: "$CI_JOB_NAME"'
...@@ -14,18 +18,22 @@ cache: ...@@ -14,18 +18,22 @@ cache:
- .m2/repository - .m2/repository
stages: stages:
- compile - test
- deploy - deploy
run tests in branches: run tests:
stage: compile stage: test
image: maven:3-openjdk-11 image: maven:3-openjdk-11
script: script:
- mvn test -B # First do coverage testing
except: - mvn $MAVEN_CLI_OPTS --activate-profiles quality verify -U
- master - cat coverage/target/site/jacoco-aggregate/index.html | grep -o 'Total[^%]*%'
- /^application\-blocks\-/ coverage: '/Total.*?([0-9]{1,3})%/'
artifacts: artifacts:
name: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}"
expire_in: 1 day
paths:
- coverage/target/site/jacoco-aggregate
reports: reports:
junit: junit:
- core/target/surefire-reports/TEST-*.xml - core/target/surefire-reports/TEST-*.xml
...@@ -35,27 +43,42 @@ run tests in branches: ...@@ -35,27 +43,42 @@ run tests in branches:
publish snapshot artifacts: publish snapshot artifacts:
stage: deploy stage: deploy
image: maven:3-openjdk-11 image: maven:3-openjdk-11
dependencies:
- run tests
before_script: before_script:
- echo "${GPG_KEY_SECRET}" | gpg --batch --import - echo "${GPG_KEY_SECRET}" | gpg --batch --import
- gpg --list-keys - gpg --list-keys
script: script:
- mvn clean deploy --settings .ci-maven-settings.xml -B -U # Package the clean app
only: - mvn $MAVEN_CLI_OPTS -DskipTests=true clean deploy --settings .ci-maven-settings.xml
- master rules:
artifacts: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
reports:
junit:
- core/target/surefire-reports/TEST-*.xml
- security/target/surefire-reports/TEST-*.xml
- auditlog/target/surefire-reports/TEST-*.xml
publish artifacts on central: publish artifacts on central:
stage: deploy stage: deploy
dependencies:
- run tests
rules:
- if: '$CI_COMMIT_TAG =~ /^application\-blocks\-/'
image: maven:3-openjdk-11 image: maven:3-openjdk-11
before_script: before_script:
- echo "${GPG_KEY_SECRET}" | gpg --batch --import - echo "${GPG_KEY_SECRET}" | gpg --batch --import
- gpg --list-keys - gpg --list-keys
script: script:
- mvn -P release clean deploy --settings .ci-maven-settings.xml -B -U # Package the clean app
only: - mvn $MAVEN_CLI_OPTS -DskipTests=true --activate-profiles release clean deploy --settings .ci-maven-settings.xml
- /^application\-blocks\-/
pages:
stage: deploy
dependencies:
- run tests
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
script:
- mkdir public
- mv coverage/target/site/jacoco-aggregate/* public
artifacts:
expire_in: 1 days
paths:
- public
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2021 Global Crop Diversity Trust
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-parent</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>application-blocks-coverage</artifactId>
<packaging>pom</packaging>
<name>Application Blocks test coverage</name>
<description>This is a test coverage module</description>
<properties>
</properties>
<profiles>
<profile>
<id>quality</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<configuration></configuration>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-security</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-auditlog</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
...@@ -142,27 +142,6 @@ ...@@ -142,27 +142,6 @@
<failOnWarning>true</failOnWarning> <failOnWarning>true</failOnWarning>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<configuration>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- SpotBugs Static Analysis --> <!-- SpotBugs Static Analysis -->
<plugin> <plugin>
<groupId>com.github.spotbugs</groupId> <groupId>com.github.spotbugs</groupId>
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
<module>core</module> <module>core</module>
<module>security</module> <module>security</module>
<module>auditlog</module> <module>auditlog</module>
<module>coverage</module>
</modules> </modules>
<build> <build>
...@@ -134,6 +135,44 @@ ...@@ -134,6 +135,44 @@
</activation> </activation>
</profile> </profile>
<profile>
<id>quality</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} -Xms1g -Xmx3g -Djava.awt.headless=true -server</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<configuration>
<includes>
<include>org/genesys/**</include>
</includes>
<!-- <excludes>
<excludes>org/genesys/**</excludes>
</excludes> -->
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>release</id> <id>release</id>
<activation> <activation>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment