|
| 1 | +# |
| 2 | +# Copyright 2021 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 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | + |
| 17 | +name: JaCoCo report |
| 18 | + |
| 19 | +on: |
| 20 | + pull_request: |
| 21 | + branches: [ master ] |
| 22 | + types: [ opened, edited, synchronize, reopened ] |
| 23 | + |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + name: Build and test |
| 27 | + runs-on: ubuntu-latest |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + # The project supports Scala 2.11, 2.12 and the default version of spark2 |
| 32 | + # The CI runs all tests suites for all supported Scala versions at build.yml |
| 33 | + # The codebase for all Scala versions is the same, so the coverage is calculated only once |
| 34 | + # Scala 2.12 is chosen since it is supported by the most wide range of Spark versions and |
| 35 | + # vendor distributions. |
| 36 | + - scala: 2.12.12 |
| 37 | + scalaShort: "2.12" |
| 38 | + overall: 80.0 |
| 39 | + changed: 80.0 |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v2 |
| 43 | + - name: Setup Scala |
| 44 | + uses: olafurpg/setup-scala@v10 |
| 45 | + with: |
| 46 | + |
| 47 | + - name: Build and run tests |
| 48 | + run: sbt ++${{matrix.scala}} jacoco |
| 49 | + # Agent module code coverage |
| 50 | + - name: Add coverage to PR |
| 51 | + id: jacoco-agent |
| 52 | + |
| 53 | + with: |
| 54 | + name: agent-jacoco-report |
| 55 | + paths: ${{ github.workspace }}/agent/target/spark2-jvm-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml |
| 56 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + min-coverage-overall: ${{matrix.overall }} |
| 58 | + min-coverage-changed-file: ${{ matrix.changed }} |
| 59 | + title: JaCoCo agent module code coverage report - spark:2 - scala ${{ matrix.scala }} |
| 60 | + update-comment: true |
| 61 | + # server module code coverage |
| 62 | + - name: Add coverage to PR |
| 63 | + id: jacoco-server |
| 64 | + |
| 65 | + with: |
| 66 | + name: server-jacoco-report |
| 67 | + paths: ${{ github.workspace }}/server/target/jvm-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml |
| 68 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + min-coverage-overall: ${{matrix.overall }} |
| 70 | + min-coverage-changed-file: ${{ matrix.changed }} |
| 71 | + title: JaCoCo server module code coverage report - scala ${{ matrix.scala }} |
| 72 | + update-comment: true |
| 73 | + - name: Get the Coverage info |
| 74 | + run: | |
| 75 | + echo "Total agent module coverage ${{ steps.jacoco-agent.outputs.coverage-overall }}" |
| 76 | + echo "Changed Files coverage ${{ steps.jacoco-agent.outputs.coverage-changed-files }}" |
| 77 | + echo "Total sever module coverage ${{ steps.jacoco-server.outputs.coverage-overall }}" |
| 78 | + echo "Changed Files coverage ${{ steps.jacoco-server.outputs.coverage-changed-files }}" |
| 79 | + - name: Fail PR if changed files coverage is less than ${{ matrix.changed }}% |
| 80 | + if: | |
| 81 | + ${{ steps.jacoco-agent.outputs.coverage-changed-files < 80.0 }} && |
| 82 | + ${{ steps.jacoco-server.outputs.coverage-changed-files < 80.0 }} |
| 83 | + uses: actions/github-script@v6 |
| 84 | + with: |
| 85 | + script: | |
| 86 | + core.setFailed('Changed files coverage is less than ${{ matrix.changed }}%!') |
| 87 | +
|
| 88 | +
|
0 commit comments