Skip to content

Commit

Permalink
Merge pull request #70 from gravity9-tech/feature/62_add_coverage_rep…
Browse files Browse the repository at this point in the history
…orts

#62 Add Code coverage report
  • Loading branch information
MateuszGravity9 authored Mar 26, 2024
2 parents 4ca19cb + bd22ec5 commit 03ab4ee
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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

0 comments on commit 03ab4ee

Please sign in to comment.