-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (109 loc) · 4.57 KB
/
jacoco_report.yml
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
# Copyright 2022 ABSA Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: JaCoCo Report
on:
push:
branches: [master]
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled ]
jobs:
build-test-and-measure:
name: "Build, Test and Measure"
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: movies
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
SCALA_VERSION: "2.13.12"
SCALA_SHORT_VERSION: "2.13"
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v14
with:
java-version: "adopt@1.8"
- name: Prepare testing database
run: sbt flywayMigrate
- name: Build and run all tests for code coverage
run: sbt ++${{env.SCALA_VERSION}} jacoco # We will need JaCoCo report in second job
- name: Add coverage to PR
id: jacoco-core
uses: madrapps/jacoco-report@v1.6.1
with:
paths: >
${{ github.workspace }}/core/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ 61.0 }}
min-coverage-changed-files: ${{ 80.0 }}
title: JaCoCo core code coverage report - scala ${{ env.SCALA_VERSION }}
update-comment: true
- name: Get the Coverage info
run: |
echo "Total core core coverage ${{ steps.jacoco-core.outputs.coverage-overall }}"
echo "Changed core Files coverage ${{ steps.jacoco-core.outputs.coverage-changed-files }}"
- name: Add coverage to PR
id: jacoco-slick
uses: madrapps/jacoco-report@v1.6.1
with:
paths: >
${{ github.workspace }}/slick/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ 61.0 }}
min-coverage-changed-files: ${{ 80.0 }}
title: JaCoCo slick code coverage report - scala ${{ env.SCALA_VERSION }}
update-comment: true
- name: Get the Coverage info
run: |
echo "Total slick coverage ${{ steps.jacoco-slick.outputs.coverage-overall }}"
echo "Changed slick Files coverage ${{ steps.jacoco-slick.outputs.coverage-changed-files }}"
- name: Add coverage to PR
id: jacoco-doobie
uses: madrapps/jacoco-report@v1.6.1
with:
paths: >
${{ github.workspace }}/doobie/target/scala-${{ env.SCALA_SHORT_VERSION }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ 61.0 }}
min-coverage-changed-files: ${{ 80.0 }}
title: JaCoCo doobie code coverage report - scala ${{ env.SCALA_VERSION }}
update-comment: true
- name: Get the Coverage info
run: |
echo "Total doobie coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}"
echo "Changed doobie Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}"
- name: Fail PR if changed files coverage is less than ${{ 80.0 }}%
if: ${{ steps.jacoco-core.outputs.coverage-changed-files < 80.0 || steps.jacoco-slick.outputs.coverage-changed-files < 80.0 || steps.jacoco-doobie.outputs.coverage-changed-files < 80.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than ${{ 80.0 }}%!')
- name: Fail PR if total files coverage is less than ${{ 61.0 }}%
if: ${{ steps.jacoco-core.outputs.coverage-overall < 75.0 || steps.jacoco-slick.outputs.coverage-overall < 75.0 || steps.jacoco-doobie.outputs.coverage-overall < 75.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Total files coverage is less than ${{ 61.0 }}%!')