Skip to content

Commit abfc695

Browse files
jetersenoleg-nenashev
authored andcommitted
Update ci to include code coverage after #1215 (#1241)
Co-authored-by: Oleg Nenashev <[email protected]>
1 parent a43da63 commit abfc695

File tree

5 files changed

+91
-30
lines changed

5 files changed

+91
-30
lines changed

.github/workflows/maven.yml

+32-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
410

511
jobs:
612
build:
713
name: Build on Jenkins ${{ matrix.jenkins-version }}, JDK ${{ matrix.java }} and ${{ matrix.os }}
814
runs-on: ${{ matrix.os }}
915
strategy:
1016
matrix:
11-
java: [1.8, 11]
17+
java: [8, 11]
1218
jenkins-version: [2.60.3, 2.176.3]
1319
os: [ubuntu-latest, windows-latest]
1420
include:
@@ -19,11 +25,34 @@ jobs:
1925
jenkins-version: '2.60.3'
2026

2127
steps:
28+
2229
- uses: actions/checkout@v1
30+
2331
- name: Set up JDK ${{ matrix.java }}
2432
uses: actions/setup-java@v1
2533
with:
2634
java-version: ${{ matrix.java }}
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v1
38+
with:
39+
path: ~/.m2/repository
40+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
41+
restore-keys: |
42+
${{ runner.os }}-maven
43+
2744
- name: Build with Maven
45+
run: mvn -Pjacoco clean verify -B -V --no-transfer-progress ${{ matrix.flags }}
46+
47+
- name: Report coverage
48+
shell: bash
49+
env:
50+
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
51+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2852
run: |
29-
mvn install -B -V --no-transfer-progress ${{ matrix.flags }}
53+
if [ "$CODACY_PROJECT_TOKEN" != "" ] && [ "$CODECOV_TOKEN" != "" ]; then
54+
bash <(curl -s https://codecov.io/bash) -f "*jacoco.xml"
55+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Java -r integrations/target/site/jacoco-aggregate/jacoco.xml
56+
else
57+
echo "No secrets provided for coverage report"
58+
fi

.travis.yml

+7-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: java
22

3-
dist: xenial
3+
dist: bionic
44

55
if: |
66
repo != jenkinsci/configuration-as-code-plugin OR \
@@ -10,41 +10,22 @@ if: |
1010
services:
1111
- docker
1212

13-
before_cache:
14-
- rm -rf $HOME/.m2/repository/io/jenkins/configuration-as-code*
15-
1613
cache:
1714
directories:
1815
- $HOME/.m2
1916

20-
env:
21-
global:
22-
- JAVA_LEVEL=8
23-
24-
matrix:
25-
include:
26-
- jdk: openjdk11
27-
env:
28-
- MVN_FLAG='-Djenkins.version=2.176.3 -Daccess-modifier-checker.failOnError=true'
29-
- jdk: openjdk8
30-
env:
31-
- MVN_FLAG='-Djenkins.version=2.176.3 -Daccess-modifier-checker.failOnError=true'
32-
- jdk: openjdk8
17+
jdk: openjdk11
3318

34-
install:
35-
- mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V $MVN_FLAG -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
19+
install: skip
3620

3721
script:
3822
- |
39-
mvn -Penable-jacoco clean install jacoco:report -B \
40-
-Djava.level=$JAVA_LEVEL \
41-
$MVN_FLAG -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
23+
mvn -Pjacoco clean verify -B -V \
24+
-Djenkins.version=2.176.3 -Daccess-modifier-checker.failOnError=true \
25+
--no-transfer-progress
4226
4327
after_success:
44-
- export LATEST_VERSION="$(curl -Ls https://api.bintray.com/packages/codacy/Binaries/codacy-coverage-reporter/versions/_latest | jq -r .name)"
45-
- curl -Ls -o codacy-coverage-reporter "https://dl.bintray.com/codacy/Binaries/$LATEST_VERSION/codacy-coverage-reporter-linux"
46-
- chmod +x codacy-coverage-reporter
47-
- ./codacy-coverage-reporter report -l Java -r plugin/target/site/jacoco/jacoco.xml
28+
- bash <(curl -s https://codecov.io/bash) -f "*jacoco.xml"
4829

4930
notifications:
5031
email: false

codecov.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
comment:
2+
layout: "header, diff, tree, changes"

integrations/pom.xml

+23
Original file line numberDiff line numberDiff line change
@@ -677,4 +677,27 @@
677677
</resource>
678678
</resources>
679679
</build>
680+
681+
<profiles>
682+
<profile>
683+
<id>jacoco</id>
684+
<build>
685+
<plugins>
686+
<plugin>
687+
<groupId>org.jacoco</groupId>
688+
<artifactId>jacoco-maven-plugin</artifactId>
689+
<executions>
690+
<execution>
691+
<id>report-aggregate</id>
692+
<phase>verify</phase>
693+
<goals>
694+
<goal>report-aggregate</goal>
695+
</goals>
696+
</execution>
697+
</executions>
698+
</plugin>
699+
</plugins>
700+
</build>
701+
</profile>
702+
</profiles>
680703
</project>

pom.xml

+27-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<modules>
1616
<module>snakeyaml</module>
1717
<module>plugin</module>
18-
<module>integrations</module>
1918
<module>test-harness</module>
19+
<module>integrations</module>
2020
</modules>
2121

2222
<properties>
@@ -99,4 +99,30 @@
9999
</plugins>
100100
</build>
101101

102+
<profiles>
103+
<profile>
104+
<id>jacoco</id>
105+
<build>
106+
<plugins>
107+
<plugin>
108+
<groupId>org.jacoco</groupId>
109+
<artifactId>jacoco-maven-plugin</artifactId>
110+
<executions>
111+
<execution>
112+
<goals>
113+
<goal>prepare-agent</goal>
114+
</goals>
115+
</execution>
116+
</executions>
117+
<configuration>
118+
<excludes>
119+
<exclude>**/Messages.class</exclude>
120+
</excludes>
121+
</configuration>
122+
</plugin>
123+
</plugins>
124+
</build>
125+
</profile>
126+
</profiles>
127+
102128
</project>

0 commit comments

Comments
 (0)