Skip to content

Commit

Permalink
#602 - Add GitHub action for code-coverage check (#603)
Browse files Browse the repository at this point in the history
* #602 - Add GitHub action for code-coverage check
- Update of plugins file to support current Absa-JaCoCo workaround.
- New yml file for server side check.
  • Loading branch information
miroslavpojer authored Apr 20, 2023
1 parent 28f2203 commit fb61b66
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 5 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/jacoco_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# 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 ]
types: [ opened, edited, synchronize, reopened ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- scala: 2.11.12
scalaShort: "2.11"
spark: 2.4.8
overall: 0.0
changed: 80.0
- scala: 2.12.17
scalaShort: "2.12"
spark: 3.2.3
overall: 0.0
changed: 80.0
- scala: 2.13.10
scalaShort: "2.13"
spark: 3.3.2
overall: 0.0
changed: 80.0
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 to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: >
${{ github.workspace }}/cobol-parser/target/scala-${{ matrix.scalaShort }}/jacoco/report/jacoco.xml,
${{ 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 - scala ${{ matrix.scala }} - spark ${{ matrix.spark }}
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 is less than ${{ matrix.changed }}%
if: ${{ steps.jacoco.outputs.coverage-changed-files < 80.0 }}
uses: actions/github-script@v6
with:
script: |
core.setFailed('Changed files coverage is less than ${{ matrix.changed }}%!')
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ lazy val cobolConverters = (project in file("cobol-converters"))
// No need to publish this artifact since it has test only at the moment
publishArtifact := false,
publish := {},
publishLocal := {},
publishLocal := {}
).dependsOn(cobolParser)
.settings(
jacocoReportSettings := commonJacocoReportSettings.withTitle("cobrix:cobol-converters Jacoco Report"),
jacocoExcludes := commonJacocoExcludes
).dependsOn(cobolParser)
)
.enablePlugins(AutomateHeaderPlugin)

lazy val sparkCobol = (project in file("spark-cobol"))
Expand All @@ -101,12 +103,11 @@ lazy val sparkCobol = (project in file("spark-cobol"))
populateBuildInfoTemplate,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
assemblySettings
)
).dependsOn(cobolParser)
.settings(
jacocoReportSettings := commonJacocoReportSettings.withTitle("cobrix:spark-cobol Jacoco Report"),
jacocoExcludes := commonJacocoExcludes
)
.dependsOn(cobolParser)
.enablePlugins(AutomateHeaderPlugin)

// scoverage settings
Expand Down
20 changes: 19 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,22 @@ addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.2.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0")
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0")

// sbt-jacoco - workaround related dependencies required to download
lazy val ow2Version = "9.5"
lazy val jacocoVersion = "0.8.9-absa.1"

def jacocoUrl(artifactName: String): String = s"https://github.com/AbsaOSS/jacoco/releases/download/$jacocoVersion/org.jacoco.$artifactName-$jacocoVersion.jar"
def ow2Url(artifactName: String): String = s"https://repo1.maven.org/maven2/org/ow2/asm/$artifactName/$ow2Version/$artifactName-$ow2Version.jar"

addSbtPlugin("com.jsuereth" %% "scala-arm" % "2.0" from "https://repo1.maven.org/maven2/com/jsuereth/scala-arm_2.11/2.0/scala-arm_2.11-2.0.jar")
addSbtPlugin("com.jsuereth" %% "scala-arm" % "2.0" from "https://repo1.maven.org/maven2/com/jsuereth/scala-arm_2.12/2.0/scala-arm_2.12-2.0.jar")

addSbtPlugin("za.co.absa.jacoco" % "report" % jacocoVersion from jacocoUrl("report"))
addSbtPlugin("za.co.absa.jacoco" % "core" % jacocoVersion from jacocoUrl("core"))
addSbtPlugin("za.co.absa.jacoco" % "agent" % jacocoVersion from jacocoUrl("agent"))
addSbtPlugin("org.ow2.asm" % "asm" % ow2Version from ow2Url("asm"))
addSbtPlugin("org.ow2.asm" % "asm-commons" % ow2Version from ow2Url("asm-commons"))
addSbtPlugin("org.ow2.asm" % "asm-tree" % ow2Version from ow2Url("asm-tree"))

addSbtPlugin("za.co.absa.sbt" % "sbt-jacoco" % "3.4.1-absa.2" from "https://github.com/AbsaOSS/sbt-jacoco/releases/download/3.4.1-absa.2/sbt-jacoco-3.4.1-absa.2.jar")

0 comments on commit fb61b66

Please sign in to comment.