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:
# 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.
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
# when running from the command line.
# `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.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
......@@ -14,18 +18,22 @@ cache:
- .m2/repository
stages:
- compile
- test
- deploy
run tests in branches:
stage: compile
run tests:
stage: test
image: maven:3-openjdk-11
script:
- mvn test -B
except:
- master
- /^application\-blocks\-/
# First do coverage testing
- mvn $MAVEN_CLI_OPTS --activate-profiles quality verify -U
- cat coverage/target/site/jacoco-aggregate/index.html | grep -o 'Total[^%]*%'
coverage: '/Total.*?([0-9]{1,3})%/'
artifacts:
name: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}"
expire_in: 1 day
paths:
- coverage/target/site/jacoco-aggregate
reports:
junit:
- core/target/surefire-reports/TEST-*.xml
......@@ -35,27 +43,42 @@ run tests in branches:
publish snapshot artifacts:
stage: deploy
image: maven:3-openjdk-11
dependencies:
- run tests
before_script:
- echo "${GPG_KEY_SECRET}" | gpg --batch --import
- gpg --list-keys
script:
- mvn clean deploy --settings .ci-maven-settings.xml -B -U
only:
- master
artifacts:
reports:
junit:
- core/target/surefire-reports/TEST-*.xml
- security/target/surefire-reports/TEST-*.xml
- auditlog/target/surefire-reports/TEST-*.xml
# Package the clean app
- mvn $MAVEN_CLI_OPTS -DskipTests=true clean deploy --settings .ci-maven-settings.xml
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
publish artifacts on central:
stage: deploy
dependencies:
- run tests
rules:
- if: '$CI_COMMIT_TAG =~ /^application\-blocks\-/'
image: maven:3-openjdk-11
before_script:
- echo "${GPG_KEY_SECRET}" | gpg --batch --import
- gpg --list-keys
script:
- mvn -P release clean deploy --settings .ci-maven-settings.xml -B -U
only:
- /^application\-blocks\-/
# Package the clean app
- mvn $MAVEN_CLI_OPTS -DskipTests=true --activate-profiles release clean deploy --settings .ci-maven-settings.xml
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 @@
<failOnWarning>true</failOnWarning>
</configuration>
</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 -->
<plugin>
<groupId>com.github.spotbugs</groupId>
......
......@@ -69,6 +69,7 @@
<module>core</module>
<module>security</module>
<module>auditlog</module>
<module>coverage</module>
</modules>
<build>
......@@ -134,6 +135,44 @@
</activation>
</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>
<id>release</id>
<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