Skip to content

Commit eb2731f

Browse files
authored
Merge pull request #37 from launchdarkly/eb/ch77594/coverage
(#2) add code coverage reports, improve CI
2 parents ade7f46 + 35b0dda commit eb2731f

File tree

3 files changed

+129
-8
lines changed

3 files changed

+129
-8
lines changed

.circleci/config.yml

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,75 @@
1-
version: 2
1+
version: 2.1
2+
3+
orbs:
4+
win: circleci/windows@1.0.0
5+
6+
workflows:
7+
test:
8+
jobs:
9+
- build-linux
10+
- test-linux:
11+
name: Java 8 - Linux - OpenJDK
12+
docker-image: circleci/openjdk:8
13+
requires:
14+
- build-linux
15+
- test-linux:
16+
name: Java 9 - Linux - OpenJDK
17+
docker-image: circleci/openjdk:9
18+
requires:
19+
- build-linux
20+
- test-linux:
21+
name: Java 10 - Linux - OpenJDK
22+
docker-image: circleci/openjdk:10
23+
requires:
24+
- build-linux
25+
- test-linux:
26+
name: Java 11 - Linux - OpenJDK
27+
docker-image: circleci/openjdk:11
28+
with-coverage: true
29+
requires:
30+
- build-linux
31+
- build-test-windows:
32+
name: Java 11 - Windows - OpenJDK
33+
234
jobs:
3-
build:
35+
build-linux:
436
docker:
5-
- image: circleci/openjdk:8
6-
environment:
7-
- TERM: dumb
37+
- image: circleci/openjdk:8u131-jdk # To match the version pre-installed in Ubuntu 16 and used by Jenkins for releasing
838
steps:
939
- checkout
10-
- run: ./gradlew test sourcesJar javadocJar
40+
- run: java -version
41+
- run: ./gradlew dependencies
42+
- run: ./gradlew jar
43+
- run: ./gradlew checkstyleMain
44+
- persist_to_workspace:
45+
root: build
46+
paths:
47+
- classes
48+
49+
test-linux:
50+
parameters:
51+
docker-image:
52+
type: string
53+
with-coverage:
54+
type: boolean
55+
default: false
56+
check-javadoc:
57+
type: boolean
58+
default: false
59+
docker:
60+
- image: <<parameters.docker-image>>
61+
steps:
62+
- checkout
63+
- attach_workspace:
64+
at: build
65+
- run: java -version
66+
- run: ./gradlew test
67+
- when:
68+
condition: <<parameters.with-coverage>>
69+
steps:
70+
- run:
71+
name: Generate test coverage report
72+
command: ./gradlew jacocoTestReport
1173
- run:
1274
name: Save test results
1375
command: |
@@ -18,3 +80,34 @@ jobs:
1880
path: ~/junit
1981
- store_artifacts:
2082
path: ~/junit
83+
- when:
84+
condition: <<parameters.with-coverage>>
85+
steps:
86+
- store_artifacts:
87+
path: build/reports/jacoco
88+
89+
build-test-windows:
90+
executor:
91+
name: win/vs2019
92+
shell: powershell.exe
93+
steps:
94+
- checkout
95+
- run:
96+
name: install OpenJDK
97+
command: |
98+
$ProgressPreference = "SilentlyContinue" # prevents console errors from CircleCI host
99+
iwr -outf openjdk.msi https://developers.redhat.com/download-manager/file/java-11-openjdk-11.0.5.10-2.windows.redhat.x86_64.msi
100+
Start-Process msiexec.exe -Wait -ArgumentList '/I openjdk.msi /quiet'
101+
- run:
102+
name: build and test
103+
command: |
104+
.\gradlew.bat --no-daemon test # must use --no-daemon because CircleCI in Windows will hang if there's a daemon running
105+
- run:
106+
name: save test results
107+
command: |
108+
mkdir .\junit
109+
cp build/test-results/test/*.xml junit
110+
- store_test_results:
111+
path: .\junit
112+
- store_artifacts:
113+
path: .\junit

build.gradle

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ buildscript {
99
plugins {
1010
id "java"
1111
id "java-library"
12+
id "checkstyle"
13+
id "jacoco"
1214
id "signing"
1315
id "maven-publish"
1416
id "de.marcphilipp.nexus-publish" version "0.4.0"
@@ -33,8 +35,8 @@ allprojects {
3335
}
3436

3537
ext.versions = [
36-
"okhttp": "4.5.0",
37-
"slf4j": "1.7.22"
38+
"okhttp": "4.5.0",
39+
"slf4j": "1.7.22"
3840
]
3941

4042
dependencies {
@@ -47,6 +49,10 @@ dependencies {
4749
testImplementation "org.hamcrest:hamcrest-all:1.3"
4850
}
4951

52+
checkstyle {
53+
configFile file("${project.rootDir}/checkstyle.xml")
54+
}
55+
5056
jar {
5157
manifest {
5258
attributes("Implementation-Version": project.version)
@@ -82,6 +88,14 @@ test {
8288
}
8389
}
8490

91+
jacocoTestReport { // code coverage report
92+
reports {
93+
xml.enabled
94+
csv.enabled true
95+
html.enabled true
96+
}
97+
}
98+
8599
idea {
86100
module {
87101
downloadJavadoc = true

checkstyle.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="TreeWalker">
7+
<module name="JavadocMethod">
8+
<property name="scope" value="public"/>
9+
</module>
10+
<module name="JavadocType">
11+
<property name="scope" value="public"/>
12+
</module>
13+
</module>
14+
</module>

0 commit comments

Comments
 (0)