|
| 1 | +# |
| 2 | +# Copyright 2018 ABSA Group Limited |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | + |
| 16 | +name: JaCoCo report |
| 17 | + |
| 18 | +on: |
| 19 | + pull_request: |
| 20 | + branches: [ master ] |
| 21 | + types: [ opened, edited, synchronize, reopened ] |
| 22 | + |
| 23 | +jobs: |
| 24 | + test: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + include: |
| 30 | + - scala: 2.11.12 |
| 31 | + scalaShort: "2.11" |
| 32 | + spark: 2.4.8 |
| 33 | + overall: 0.0 |
| 34 | + changed: 80.0 |
| 35 | + - scala: 2.12.15 |
| 36 | + scalaShort: "2.12" |
| 37 | + spark: 2.4.8 |
| 38 | + overall: 0.0 |
| 39 | + changed: 80.0 |
| 40 | + - scala: 2.12.15 |
| 41 | + scalaShort: "2.12" |
| 42 | + spark: 3.2.1 |
| 43 | + overall: 0.0 |
| 44 | + changed: 80.0 |
| 45 | + name: Check code-coverage by JaCoCo - Spark ${{matrix.spark}} on Scala ${{matrix.scala}} |
| 46 | + steps: |
| 47 | + - name: Checkout code |
| 48 | + uses: actions/checkout@v2 |
| 49 | + - uses: coursier/cache-action@v5 |
| 50 | + - name: Setup Scala |
| 51 | + uses: olafurpg/setup-scala@v10 |
| 52 | + with: |
| 53 | + java-version: "adopt@1.8" |
| 54 | + - name: Build and run tests |
| 55 | + run: sbt ++${{matrix.scala}} jacoco -DSPARK_VERSION=${{matrix.spark}} |
| 56 | + - name: Add coverage to PR for Scala ${{matrix.scala}} & Spark ${{matrix.spark}} |
| 57 | + id: jacoco |
| 58 | + uses: madrapps/jacoco-report@v1.3 |
| 59 | + with: |
| 60 | + paths: ${{ github.workspace }}/target/scala-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml |
| 61 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + min-coverage-overall: ${{ matrix.overall }} |
| 63 | + min-coverage-changed-files: ${{ matrix.changed }} |
| 64 | + title: JaCoCo code coverage report - Scala ${{ matrix.scala }} & Spark ${{ matrix.spark }} |
| 65 | + update-comment: true |
| 66 | + - name: Get the Coverage info |
| 67 | + run: | |
| 68 | + echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}" |
| 69 | + echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}" |
| 70 | + - name: Fail PR if changed files coverage is less than ${{ matrix.changed }}% |
| 71 | + if: ${{ steps.jacoco.outputs.coverage-changed-files < 80.0 }} |
| 72 | + uses: actions/github-script@v6 |
| 73 | + with: |
| 74 | + script: | |
| 75 | + core.setFailed('Changed files coverage is less than ${{ matrix.changed }}%!') |
| 76 | +
|
0 commit comments