Skip to content

Commit

Permalink
Merge pull request #445 from codacy/feature/setup-coverage-COV-149
Browse files Browse the repository at this point in the history
Setup codebase coverage reporting to Codacy
  • Loading branch information
rubencodacy committed Feb 9, 2023
2 parents 2faff0f + 62e01a3 commit 6d0b6a7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
58 changes: 39 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codacy: codacy/base@9.3.5
codacy: codacy/base@10.1.1

references:
circleci_job: &circleci_job
Expand Down Expand Up @@ -207,25 +207,45 @@ workflows:
requires:
- codacy/checkout_and_version
- codacy/sbt:
name: scalafmt_and_compile
cmd: sbt "scalafmtCheckAll;scalafmtSbtCheck;test:compile;it:compile"
name: compile_and_test
persist_to_workspace: true
steps_before_sbt:
- run:
name: Enable coverage
command: echo "ThisBuild / coverageEnabled := true" > coverage.sbt
steps:
- run:
name: Check formatting Sbt files
command: sbt scalafmtSbtCheck
- run:
name: Check formatting Scala files
command: sbt scalafmtCheckAll
- run:
name: Test compile
command: sbt test:compile
- run:
name: It compile
command: sbt it:compile
- run:
name: Unit testing
command: sbt test
- run:
name: It testing
command: sbt it:test
- run:
name: Aggregate coverage reports
command: sbt coverageAggregate
- run:
name: Send coverage report to Codacy
# Specify only scala coverage reports, because coverage reporter is detecting coverage reports
# for other languages that are not valid and are used on tests
command: |
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Scala -r "**/cobertura*.xml"
- run:
name: Clean coverage.sbt from cache
command: rm coverage.sbt
requires:
- codacy/checkout_and_version
- codacy/sbt:
name: test_and_coverage
cmd: |
sbt coverage test
sbt coverageAggregate
./get.sh report --skip
requires:
- scalafmt_and_compile
- codacy/sbt:
name: integration_tests
cmd: sbt it:test
persist_to_workspace: true
requires:
- scalafmt_and_compile
- codacy/sbt:
name: create_artifacts
cmd: |
Expand All @@ -236,7 +256,7 @@ workflows:
mv target/codacy-coverage-reporter-assembly-$(cat .version).jar ~/workdir/tmp-artifacts/codacy-coverage-reporter-assembly.jar
persist_to_workspace: true
requires:
- scalafmt_and_compile
- compile_and_test
- codacy/sbt_osx:
name: create_artifacts_for_osx
cmd: |
Expand All @@ -258,7 +278,7 @@ workflows:
persist_to_workspace: true
persist_to_workspace_path: "tmp-artifacts/codacy-coverage-reporter-darwin"
requires:
- scalafmt_and_compile
- compile_and_test
- package_artifacts:
requires:
- create_artifacts
Expand Down
3 changes: 3 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ ThisBuild / assemblyMergeStrategy := {
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}

// required to upgrade org.scoverage.sbt-scoverage.2.0.6
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
4 changes: 4 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
// Updates
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")

// Coverage
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6")
evictionErrorLevel := Level.Warn

0 comments on commit 6d0b6a7

Please sign in to comment.