File tree Expand file tree Collapse file tree 4 files changed +77
-3
lines changed
Expand file tree Collapse file tree 4 files changed +77
-3
lines changed Original file line number Diff line number Diff line change 1+ name : CI check JaCoCo code-coverage
2+
3+ on :
4+ pull_request :
5+ branches : [ main ]
6+
7+ jobs :
8+ code_coverage :
9+ name : CI check JaCoCo code-coverage
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout code
13+ 14+ - name : Setup Scala
15+ uses : olafurpg/setup-scala@v14
16+ with :
17+ 18+ - name : Build, run tests, and generate Jacoco code coverage report
19+ run : sbt ++2.12.18 jacoco
20+ - name : Add coverage to PR
21+ id : jacoco
22+ 23+ with :
24+ paths : >
25+ ${{ github.workspace }}/target/scala-2.12/jacoco/report/jacoco.xml
26+ token : ${{ secrets.GITHUB_TOKEN }}
27+ min-coverage-overall : 0.0
28+ min-coverage-changed-files : 80.0
29+ title : JaCoCo code coverage report - springdoc-openapi-scala
30+ update-comment : true
31+ debug-mode : true
32+ - name : Get the Coverage info
33+ run : |
34+ echo "Total coverage ${{ steps.jacoco.outputs.coverage-overall }}"
35+ echo "Changed Files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}"
36+ - name : Fail PR if changed files coverage is less than 80%
37+ if : ${{ steps.jacoco.outputs.coverage-changed-files < 80.0 }}
38+ 39+ with :
40+ script : |
41+ core.setFailed('Changed files coverage is less than 80%!')
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ jobs:
3030 name : Scala ${{matrix.scala}}
3131 steps :
3232 - name : Checkout code
33- uses : actions/checkout@v4
33+ uses : actions/checkout@v4.1.1
3434 - uses : coursier/cache-action@v6
3535 - name : Setup Scala
36- uses : olafurpg/setup-scala@v11
36+ uses : olafurpg/setup-scala@v14
3737 with :
38383939 - name : Build and run tests
Original file line number Diff line number Diff line change 1515 */
1616
1717import Dependencies ._
18+ import com .github .sbt .jacoco .report .JacocoReportSettings
1819
1920ThisBuild / organization := " za.co.absa"
2021ThisBuild / scalaVersion := Versions .scala212
2122ThisBuild / versionScheme := Some (" early-semver" )
2223
2324lazy val supportedScalaVersions = List (Versions .scala212, Versions .scala213)
2425
26+ lazy val commonJacocoReportSettings : JacocoReportSettings = JacocoReportSettings (
27+ formats = Seq (JacocoReportFormats .HTML , JacocoReportFormats .XML )
28+ )
29+
30+ lazy val commonJacocoExcludes : Seq [String ] = Seq (
31+ // "za.co.absa.springdocopenapiscala.*"
32+ )
33+
2534lazy val root = (project in file(" ." ))
2635 .settings(
2736 name := " springdoc-openapi-scala" ,
2837 libraryDependencies ++= libraryDependencyList(scalaVersion.value),
29- crossScalaVersions := supportedScalaVersions
38+ crossScalaVersions := supportedScalaVersions,
39+ jacocoReportSettings := commonJacocoReportSettings.withTitle(s " SpringDoc OpenApi - scala: ${scalaVersion.value}" ),
40+ jacocoExcludes := commonJacocoExcludes
3041 )
3142
3243lazy val simpleExample = (project in file(" examples/simple" ))
Original file line number Diff line number Diff line change 1616
1717addSbtPlugin(" org.jetbrains.scala" % " sbt-ide-settings" % " 1.1.1" )
1818addSbtPlugin(" com.earldouglas" % " xsbt-web-plugin" % " 4.2.4" )
19+
20+ // sbt-jacoco - workaround related dependencies required to download
21+ lazy val ow2Version = " 9.5"
22+ lazy val jacocoVersion = " 0.8.11-absa.1"
23+ val sbtJacocoVersion = " 3.4.1-absa.4"
24+ val scalaArmVersion = " 2.0"
25+
26+ def jacocoUrl (artifactName : String ): String = s " https://github.com/AbsaOSS/jacoco/releases/download/ $jacocoVersion/org.jacoco. $artifactName- $jacocoVersion.jar "
27+ def ow2Url (artifactName : String ): String = s " https://repo1.maven.org/maven2/org/ow2/asm/ $artifactName/ $ow2Version/ $artifactName- $ow2Version.jar "
28+ def armUrl (scalaMajor : String ): String = s " https://repo1.maven.org/maven2/com/jsuereth/scala-arm_ $scalaMajor/ $scalaArmVersion/scala-arm_ $scalaMajor- $scalaArmVersion.jar "
29+
30+ addSbtPlugin(" com.jsuereth" %% " scala-arm" % scalaArmVersion from armUrl(" 2.11" ))
31+ addSbtPlugin(" com.jsuereth" %% " scala-arm" % scalaArmVersion from armUrl(" 2.12" ))
32+
33+ addSbtPlugin(" za.co.absa.jacoco" % " report" % jacocoVersion from jacocoUrl(" report" ))
34+ addSbtPlugin(" za.co.absa.jacoco" % " core" % jacocoVersion from jacocoUrl(" core" ))
35+ addSbtPlugin(" za.co.absa.jacoco" % " agent" % jacocoVersion from jacocoUrl(" agent" ))
36+ addSbtPlugin(" org.ow2.asm" % " asm" % ow2Version from ow2Url(" asm" ))
37+ addSbtPlugin(" org.ow2.asm" % " asm-commons" % ow2Version from ow2Url(" asm-commons" ))
38+ addSbtPlugin(" org.ow2.asm" % " asm-tree" % ow2Version from ow2Url(" asm-tree" ))
39+
40+ addSbtPlugin(" za.co.absa.sbt" % " sbt-jacoco" % sbtJacocoVersion from s " https://github.com/AbsaOSS/sbt-jacoco/releases/download/ $sbtJacocoVersion/sbt-jacoco- $sbtJacocoVersion.jar " )
You can’t perform that action at this time.
0 commit comments