From 9ee361c65db1e1bd1ca446a3adc7b5d19d9610d9 Mon Sep 17 00:00:00 2001 From: Andreas Svanberg <andreass@dsv.su.se> Date: Thu, 5 Dec 2024 10:36:42 +0100 Subject: [PATCH] Report test coverage on pull request --- .gitea/workflows/coverage-report.yaml | 32 +++++++++++++++++++++++++++ pom.xml | 23 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .gitea/workflows/coverage-report.yaml diff --git a/.gitea/workflows/coverage-report.yaml b/.gitea/workflows/coverage-report.yaml new file mode 100644 index 0000000000..71d74f06a5 --- /dev/null +++ b/.gitea/workflows/coverage-report.yaml @@ -0,0 +1,32 @@ +name: Coverage report +on: + - pull_request: + types: + - opened + - pull_request: + types: + - synchronize + paths: + - '**/src/**.java' + - '.github/workflows/coverage-report.yaml' + +jobs: + coverage-report: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: ./mvnw --batch-mode --activate-profiles coverage verify + - name: Add coverage report to pull request + uses: madrapps/jacoco-report@v1.7.1 + with: + paths: ${{ github.workspace }}/**/target/site/jacoco/jacoco.xml + token: ${{ secrets.GITHUB_TOKEN }} + title: 'Coverage Report' + update-comment: true diff --git a/pom.xml b/pom.xml index 8448e670cf..9daa76f748 100755 --- a/pom.xml +++ b/pom.xml @@ -449,4 +449,27 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <id>coverage</id> + <build> + <plugins> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.8.11</version> + <executions> + <execution> + <goals> + <goal>prepare-agent</goal> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> \ No newline at end of file