Skip to content
51 changes: 51 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Java Code Coverage

on:
push:
branches:
- main
pull_request:
branches: [ '*' ]

jobs:
coverage:
name: Generate Coverage Report
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install buf
run: |
curl -sSL "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m)" -o /usr/local/bin/buf
chmod +x /usr/local/bin/buf

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

- name: Build with Maven
run: mvn -B clean package

- name: Run tests
run: mvn test

- name: Generate Jacoco coverage report
run: mvn jacoco:report

- name: show files
run: |
ls
pwd
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
${{ github.workspace }}/target/site/jacoco/jacoco.xml
${{ github.workspace }}/target/site/jacoco/index.html


25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,31 @@
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/site/jacoco</outputDirectory>
<formats>
<format>xml</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down