-
Notifications
You must be signed in to change notification settings - Fork 78
100 lines (96 loc) · 4.2 KB
/
jacoco_check.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
#
# 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:
pull_request:
branches: [ master ]
paths:
- "cobol-parser/**"
- "cobol-converters/**"
- "spark-cobol/**"
- "project/**"
- "build.sbt"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
# The project supports Scala 2.11, 2.12, 2.13
# The CI runs all tests suites for all supported Scala versions at build.yml
# The codebase for all Scala versions is the same, so the coverage is calculated only once
# Scala 2.12 is chosen since it is supported by the most wide range of Spark versions and
# vendor distributions.
include:
- scala: 2.12.17
scalaShort: "2.12"
spark: 3.3.2
overall: 0.0
changed: 80.0
# Historically, 'cobol-parser' module was part of 'spark-cobol' and the coverage is combined.
# Jacoco can't combine coverage across modules, so until 'cobol-parser' has unit tests
# that covers the same codepade from the same module, the coverage requirement is lowered to 20%.
changedCobolParserOverride: 20
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Scala
uses: olafurpg/setup-scala@v10
with:
java-version: "[email protected]"
- name: Build and run tests
run: sbt ++${{matrix.scala}} jacoco -DSPARK_VERSION=${{matrix.spark}}
- name: Add coverage of 'cobol-parser' to PR
id: jacocoParser
uses: madrapps/[email protected]
with:
paths: >
${{ github.workspace }}/cobol-parser/target/scala-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ matrix.overall }}
min-coverage-changed-files: ${{ matrix.changedCobolParserOverride }}
title: JaCoCo code coverage report - 'cobol-parser'
update-comment: true
- name: Get the Coverage info
run: |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"
- name: Add coverage of 'spark-cobol' to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: >
${{ github.workspace }}/spark-cobol/target/scala-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: ${{ matrix.overall }}
min-coverage-changed-files: ${{ matrix.changed }}
title: JaCoCo code coverage report - 'spark-cobol'
update-comment: true
- name: Get the Coverage info
run: |
echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"
- name: Fail PR if changed files coverage for 'cobol-parser' is less than ${{ matrix.changedCobolParserOverride }}%
if: ${{ steps.jacocoParser.outputs.coverage-changed-files < matrix.changedCobolParserOverride }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than ${{ matrix.changedCobolParserOverride }}% for 'cobol-parser'!')
- name: Fail PR if changed files coverage for 'spark-cobol' is less than ${{ matrix.changed }}%
if: ${{ steps.jacoco.outputs.coverage-changed-files < matrix.changed }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than ${{ matrix.changed }}% for 'spark-cobol!')