Skip to content

Commit 2648b7c

Browse files
committed
Add Java code coverage reporting with JaCoCo
1 parent 2c5130d commit 2648b7c

10 files changed

Lines changed: 158 additions & 13 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
docs
2+
!docs/coverage
23
charts

.github/workflows/unit_tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ jobs:
1616
restore-keys: |
1717
${{ runner.os }}-maven-
1818
- name: test java
19-
run: make test-java
19+
run: make test-java-with-coverage
20+
- uses: actions/upload-artifact@v2
21+
with:
22+
name: java-coverage-report
23+
path: ${{ github.workspace }}/docs/coverage/java/target/site/jacoco-aggregate/
2024

2125
unit-test-python:
2226
runs-on: ubuntu-latest

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ lint-java:
4646
test-java:
4747
mvn test
4848

49+
test-java-with-coverage:
50+
mvn test jacoco:report-aggregate
51+
4952
build-java:
5053
mvn clean verify
5154

@@ -158,4 +161,4 @@ build-html: clean-html
158161
# Build Python SDK documentation
159162
$(MAKE) compile-protos-python
160163
cd $(ROOT_DIR)/sdk/python/docs && $(MAKE) html
161-
cp -r $(ROOT_DIR)/sdk/python/docs/html/* $(ROOT_DIR)/dist/python
164+
cp -r $(ROOT_DIR)/sdk/python/docs/html/* $(ROOT_DIR)/dist/python

core/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232

3333
<build>
3434
<plugins>
35+
<plugin>
36+
<groupId>org.jacoco</groupId>
37+
<artifactId>jacoco-maven-plugin</artifactId>
38+
</plugin>
39+
3540
<plugin>
3641
<groupId>org.springframework.boot</groupId>
3742
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -195,7 +200,6 @@
195200
<dependency>
196201
<groupId>org.mockito</groupId>
197202
<artifactId>mockito-core</artifactId>
198-
<version>2.23.0</version>
199203
<scope>test</scope>
200204
</dependency>
201205

docs/coverage/java/pom.xml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2020 The Feast Authors
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<!--
24+
~ This module serves to collect JaCoCo coverage data and produce an aggregate
25+
~ report with e.g. `mvn test jacoco:report-aggregate`.
26+
~ See https://github.com/jacoco/jacoco/wiki/MavenMultiModule
27+
-->
28+
29+
<parent>
30+
<groupId>dev.feast</groupId>
31+
<artifactId>feast-parent</artifactId>
32+
<version>${revision}</version>
33+
<relativePath>../../..</relativePath>
34+
</parent>
35+
36+
<name>Feast Coverage Java</name>
37+
<artifactId>feast-coverage</artifactId>
38+
39+
<properties>
40+
<maven.deploy.skip>true</maven.deploy.skip>
41+
</properties>
42+
43+
<dependencies>
44+
<dependency>
45+
<groupId>dev.feast</groupId>
46+
<artifactId>feast-storage-api</artifactId>
47+
<version>${project.version}</version>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>dev.feast</groupId>
52+
<artifactId>feast-storage-connector-bigquery</artifactId>
53+
<version>${project.version}</version>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>dev.feast</groupId>
58+
<artifactId>feast-storage-connector-redis</artifactId>
59+
<version>${project.version}</version>
60+
</dependency>
61+
62+
<dependency>
63+
<groupId>dev.feast</groupId>
64+
<artifactId>feast-storage-connector-redis-cluster</artifactId>
65+
<version>${project.version}</version>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>dev.feast</groupId>
70+
<artifactId>feast-ingestion</artifactId>
71+
<version>${project.version}</version>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>dev.feast</groupId>
76+
<artifactId>feast-core</artifactId>
77+
<version>${project.version}</version>
78+
</dependency>
79+
80+
<dependency>
81+
<groupId>dev.feast</groupId>
82+
<artifactId>feast-serving</artifactId>
83+
<version>${project.version}</version>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>dev.feast</groupId>
88+
<artifactId>feast-sdk</artifactId>
89+
<version>${project.version}</version>
90+
</dependency>
91+
</dependencies>
92+
93+
<build>
94+
<plugins>
95+
<plugin>
96+
<groupId>org.jacoco</groupId>
97+
<artifactId>jacoco-maven-plugin</artifactId>
98+
<executions>
99+
<execution>
100+
<id>report-aggregate</id>
101+
<phase>prepare-package</phase>
102+
<goals>
103+
<goal>report-aggregate</goal>
104+
</goals>
105+
</execution>
106+
</executions>
107+
</plugin>
108+
</plugins>
109+
</build>
110+
111+
</project>

ingestion/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
</execution>
9292
</executions>
9393
</plugin>
94+
95+
<plugin>
96+
<groupId>org.jacoco</groupId>
97+
<artifactId>jacoco-maven-plugin</artifactId>
98+
</plugin>
9499
</plugins>
95100
</build>
96101

pom.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<module>core</module>
3636
<module>serving</module>
3737
<module>sdk/java</module>
38+
<module>docs/coverage/java</module>
3839
</modules>
3940

4041
<properties>
@@ -471,9 +472,9 @@
471472
<plugin>
472473
<groupId>org.apache.maven.plugins</groupId>
473474
<artifactId>maven-surefire-plugin</artifactId>
474-
<version>2.22.1</version>
475+
<version>3.0.0-M4</version>
475476
<configuration>
476-
<argLine>-Xms2048m -Xmx2048m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
477+
<argLine>@{argLine} -Xms2048m -Xmx2048m -Djdk.net.URLClassPath.disableClassPathURLCheck=true</argLine>
477478
<excludes>
478479
<groups>IntegrationTest</groups>
479480
</excludes>
@@ -614,6 +615,18 @@
614615
<cleanupDaemonThreads>false</cleanupDaemonThreads>
615616
</configuration>
616617
</plugin>
618+
<plugin>
619+
<groupId>org.jacoco</groupId>
620+
<artifactId>jacoco-maven-plugin</artifactId>
621+
<version>0.8.5</version>
622+
<executions>
623+
<execution>
624+
<goals>
625+
<goal>prepare-agent</goal>
626+
</goals>
627+
</execution>
628+
</executions>
629+
</plugin>
617630
<plugin>
618631
<groupId>org.springframework.boot</groupId>
619632
<artifactId>spring-boot-maven-plugin</artifactId>

sdk/java/pom.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,8 @@
9494
</configuration>
9595
</plugin>
9696
<plugin>
97-
<artifactId>maven-surefire-plugin</artifactId>
98-
<version>2.22.2</version>
99-
</plugin>
100-
<plugin>
101-
<artifactId>maven-failsafe-plugin</artifactId>
102-
<version>2.22.2</version>
97+
<groupId>org.jacoco</groupId>
98+
<artifactId>jacoco-maven-plugin</artifactId>
10399
</plugin>
104100
</plugins>
105101
</build>

serving/pom.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040

4141
<build>
4242
<plugins>
43+
<plugin>
44+
<groupId>org.jacoco</groupId>
45+
<artifactId>jacoco-maven-plugin</artifactId>
46+
</plugin>
47+
4348
<plugin>
4449
<groupId>org.springframework.boot</groupId>
4550
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -248,11 +253,9 @@
248253
<scope>test</scope>
249254
</dependency>
250255

251-
<!-- TODO: fix version discrepancy with managed version -->
252256
<dependency>
253257
<groupId>org.mockito</groupId>
254258
<artifactId>mockito-core</artifactId>
255-
<version>2.23.0</version>
256259
<scope>test</scope>
257260
</dependency>
258261

storage/connectors/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
</ignoredUnusedDeclaredDependencies>
3333
</configuration>
3434
</plugin>
35+
36+
<plugin>
37+
<groupId>org.jacoco</groupId>
38+
<artifactId>jacoco-maven-plugin</artifactId>
39+
</plugin>
3540
</plugins>
3641
</build>
3742

0 commit comments

Comments
 (0)