-
Notifications
You must be signed in to change notification settings - Fork 158
80 lines (78 loc) · 3.85 KB
/
ci-check-jacoco.yml
File metadata and controls
80 lines (78 loc) · 3.85 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
74
75
76
77
78
79
80
name: CI check JaCoCo code-coverage
on:
pull_request:
branches: [ develop ]
types: [ opened, edited, synchronize, reopened ]
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
JACOCO_PATHS: >
${{ github.workspace }}/admin/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/arangodb-foxx-api/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/commons/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/consumer-rest-core/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/consumer-services/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/kafka-gateway/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/persistence/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/producer-model/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/producer-model-mapper/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/producer-rest-core/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/producer-services/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/rest-gateway/target/site/jacoco/jacoco.xml,
${{ github.workspace }}/test-data-generator/target/site/jacoco/jacoco.xml
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Scala
uses: coursier/setup-action@v1
with:
jvm: "corretto:21"
- name: Build and run tests
run: mvn verify -Dcode-coverage
- name: Add coverage to PR
id: jacoco
# Only comment on PR if we have write permissions (not from fork or dependabot)
if: github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'
uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 # v1.7.2
with:
paths: ${{ env.JACOCO_PATHS }}
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 0.0
min-coverage-changed-files: 80.0
title: JaCoCo code coverage report
update-comment: true
- name: Add coverage to workflow summary (for forks/dependabot)
id: jacoco-summary
# Only run this step if we couldn't comment on PR (fork or dependabot)
# This writes the report to workflow summary instead of PR comments
if: github.event.pull_request.head.repo.full_name != github.repository || github.actor == 'dependabot[bot]'
uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 # v1.7.2
with:
paths: ${{ env.JACOCO_PATHS }}
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 0.0
min-coverage-changed-files: 80.0
title: JaCoCo code coverage report
# Use workflow summary for PRs without write permissions
comment-type: summary
- name: Get the Coverage info
run: |
if [ "${{ steps.jacoco.conclusion }}" == "success" ]; then
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"
elif [ "${{ steps.jacoco-summary.conclusion }}" == "success" ]; then
echo "Total coverage ${{ steps.jacoco-summary.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco-summary.outputs.coverage-changed-files }}"
fi
- name: Fail PR if changed files coverage is less than 80%
if: |
(steps.jacoco.conclusion == 'success' && steps.jacoco.outputs.coverage-changed-files < 80.0) ||
(steps.jacoco-summary.conclusion == 'success' && steps.jacoco-summary.outputs.coverage-changed-files < 80.0)
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than 80%!')