Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#62 Add Code coverage report #70

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/pr-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Measure coverage

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
- name: Run Coverage
run: |
chmod +x gradlew
./gradlew jacocoTestReport

- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
${{ github.workspace }}/**/build/reports/jacoco/**/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
title: Code Coverage
update-comment: true

- name: Fail PR if overall coverage is less than 80%
if: ${{ steps.jacoco.outputs.coverage-overall < 80.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Overall coverage is less than 80%!')
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ buildscript {
plugins {
id("net.ltgt.errorprone") version "3.0.1" apply false
id "org.sonarqube" version "4.2.1.3168"
id "jacoco"
}

apply(plugin: "java-library");
Expand Down Expand Up @@ -65,6 +66,11 @@ test {
useTestNG() {
useDefaultListeners = true;
};
finalizedBy jacocoTestReport // report is always generated after tests run
}

jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}

/*
Expand Down Expand Up @@ -100,6 +106,12 @@ artifacts {
archives javadocJar;
}

jacocoTestReport{
reports {
xml.enabled true
html.enabled true
}
}

wrapper {
gradleVersion = "7.6.1";
Expand Down
Loading