Skip to content

Commit

Permalink
[github] Add test coverage reports
Browse files Browse the repository at this point in the history
* Add Javalin SSL and Coverage modules

* Add Readme for coverage module and badges.
  • Loading branch information
zugazagoitia authored and tipsy committed Feb 22, 2024
1 parent 2dce81a commit 8f60d44
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
<a href="https://discord.gg/sgak4e5NKv">
<img alt="Discord" src="https://img.shields.io/discord/804862058528505896">
</a>

<!--Codecov badge-->
<a href="https://codecov.io/gh/javalin/javalin" >
<img src="https://codecov.io/gh/javalin/javalin/graph/badge.svg?token=3L3CvpyMPI"/>
</a>

</div>

#
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,35 @@ jobs:
run: ./mvnw -DRunningOnCi=true package --file pom.xml --batch-mode
env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
coverage:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Make Maven Wrapper executable
run: chmod +x ./mvnw
- name: Build with Maven
run: ./mvnw -P dev -DRunningOnCi=true clean verify --file pom.xml --batch-mode
env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
with:
files: "${{ github.workspace }}/javalin-utils/coverage/target/site/jacoco-aggregate/jacoco.xml"
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} #Must be added for dependabot too
40 changes: 40 additions & 0 deletions javalin-utils/coverage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Javalin Utils - Coverage

This module is used for Jacoco code coverage report aggregation.

## Jacoco Report Path

The Jacoco report can be found at the following path, relative to the root of the project:

`javalin-utils/coverage/target/site/jacoco-aggregate/jacoco.xml`

## Generating the Jacoco Report

To generate the Jacoco report, run the following command from the root of the project:

`mvn clean verify`

## Viewing the Jacoco Report

The Jacoco report can be viewed by opening the following file in a web browser:

`javalin-utils/coverage/target/site/jacoco-aggregate/index.html`

Or by using Codecov to view the report online here: [![codecov](https://codecov.io/gh/javalin/javalin/graph/badge.svg?token=3L3CvpyMPI)](https://codecov.io/gh/javalin/javalin)

## Coverage graphs

### Sunburst

[![codecov](https://codecov.io/gh/javalin/javalin/graphs/sunburst.svg?token=3L3CvpyMPI
)](https://codecov.io/gh/javalin/javalin)

### Icicle

[![codecov](https://codecov.io/gh/javalin/javalin/graphs/icicle.svg?token=3L3CvpyMPI
)](https://codecov.io/gh/javalin/javalin)

### Treemap / Grid

[![codecov](https://codecov.io/gh/javalin/javalin/graphs/treemap.svg?token=3L3CvpyMPI
)](https://codecov.io/gh/javalin/javalin)
87 changes: 87 additions & 0 deletions javalin-utils/coverage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>io.javalin</groupId>
<artifactId>javalin-utils</artifactId>
<version>6.1.1-SNAPSHOT</version>
</parent>

<artifactId>coverage</artifactId>
<packaging>pom</packaging>
<name>Jacoco Coverage Report</name>

<dependencies>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin-testtools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin-micrometer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin-context-mock</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin-rendering</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.javalin.community.ssl</groupId>
<artifactId>ssl-plugin</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<dataFileIncludes>
<dataFileInclude>**/jacoco.exec</dataFileInclude>
</dataFileIncludes>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
1 change: 1 addition & 0 deletions javalin-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<modules>
<module>javalin-context-mock</module>
<module>coverage</module>
</modules>

<properties>
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<source.plugin.version>3.2.1</source.plugin.version>
<moditect.plugin.version>1.1.0</moditect.plugin.version>
<maven.javadoc.skip>true</maven.javadoc.skip> <!-- property used by the javadoc plugin, which is triggered by ... something in the pom -->
<jacoco.plugin.version>0.8.11</jacoco.plugin.version>

<!-- DEPENDENCIES -->
<annotations.version>24.1.0</annotations.version>
Expand Down Expand Up @@ -411,6 +412,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
Expand Down

0 comments on commit 8f60d44

Please sign in to comment.