-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (61 loc) · 2.19 KB
/
coverage.yml
File metadata and controls
74 lines (61 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Coverage
on:
push:
branches: ["main", "release/**"]
pull_request:
branches: ["main", "release/**"]
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
coverage:
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: gradle
- name: Grant execute permission for Gradle wrapper
run: chmod +x ./gradlew
- name: Run tests + JaCoCo coverage
run: ./gradlew clean coverage --no-daemon
- name: Build coverage summary
id: jacoco
uses: madrapps/jacoco-report@v1.7.2
with:
paths: build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: Code Coverage
min-coverage-overall: 0
min-coverage-changed-files: 0
update-comment: false
- name: Add coverage summary to job output
run: |
echo "### Code Coverage" >> "$GITHUB_STEP_SUMMARY"
echo "- Overall: ${{ steps.jacoco.outputs.coverage-overall }}%" >> "$GITHUB_STEP_SUMMARY"
echo "- Changed files: ${{ steps.jacoco.outputs.coverage-changed-files }}%" >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage HTML report
uses: actions/upload-artifact@v4
with:
name: jacoco-html-report
path: build/reports/jacoco/test/html/
- name: Upload coverage to Codecov
if: ${{ env.CODECOV_TOKEN != '' }}
uses: codecov/codecov-action@v5
with:
token: ${{ env.CODECOV_TOKEN }}
files: build/reports/jacoco/test/jacocoTestReport.xml
fail_ci_if_error: false
- name: Codecov token missing notice
if: ${{ env.CODECOV_TOKEN == '' }}
run: |
echo "### Codecov upload skipped" >> "$GITHUB_STEP_SUMMARY"
echo "- Missing repository secret: CODECOV_TOKEN" >> "$GITHUB_STEP_SUMMARY"
echo "- Add it in GitHub Settings > Secrets and variables > Actions" >> "$GITHUB_STEP_SUMMARY"