Skip to content

Commit 6d0b6a7

Browse files
authored
Merge pull request #445 from codacy/feature/setup-coverage-COV-149
Setup codebase coverage reporting to Codacy
2 parents 2faff0f + 62e01a3 commit 6d0b6a7

File tree

3 files changed

+46
-19
lines changed

3 files changed

+46
-19
lines changed

.circleci/config.yml

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
codacy: codacy/base@9.3.5
4+
codacy: codacy/base@10.1.1
55

66
references:
77
circleci_job: &circleci_job
@@ -207,25 +207,45 @@ workflows:
207207
requires:
208208
- codacy/checkout_and_version
209209
- codacy/sbt:
210-
name: scalafmt_and_compile
211-
cmd: sbt "scalafmtCheckAll;scalafmtSbtCheck;test:compile;it:compile"
210+
name: compile_and_test
212211
persist_to_workspace: true
212+
steps_before_sbt:
213+
- run:
214+
name: Enable coverage
215+
command: echo "ThisBuild / coverageEnabled := true" > coverage.sbt
216+
steps:
217+
- run:
218+
name: Check formatting Sbt files
219+
command: sbt scalafmtSbtCheck
220+
- run:
221+
name: Check formatting Scala files
222+
command: sbt scalafmtCheckAll
223+
- run:
224+
name: Test compile
225+
command: sbt test:compile
226+
- run:
227+
name: It compile
228+
command: sbt it:compile
229+
- run:
230+
name: Unit testing
231+
command: sbt test
232+
- run:
233+
name: It testing
234+
command: sbt it:test
235+
- run:
236+
name: Aggregate coverage reports
237+
command: sbt coverageAggregate
238+
- run:
239+
name: Send coverage report to Codacy
240+
# Specify only scala coverage reports, because coverage reporter is detecting coverage reports
241+
# for other languages that are not valid and are used on tests
242+
command: |
243+
bash <(curl -Ls https://coverage.codacy.com/get.sh) report -l Scala -r "**/cobertura*.xml"
244+
- run:
245+
name: Clean coverage.sbt from cache
246+
command: rm coverage.sbt
213247
requires:
214248
- codacy/checkout_and_version
215-
- codacy/sbt:
216-
name: test_and_coverage
217-
cmd: |
218-
sbt coverage test
219-
sbt coverageAggregate
220-
./get.sh report --skip
221-
requires:
222-
- scalafmt_and_compile
223-
- codacy/sbt:
224-
name: integration_tests
225-
cmd: sbt it:test
226-
persist_to_workspace: true
227-
requires:
228-
- scalafmt_and_compile
229249
- codacy/sbt:
230250
name: create_artifacts
231251
cmd: |
@@ -236,7 +256,7 @@ workflows:
236256
mv target/codacy-coverage-reporter-assembly-$(cat .version).jar ~/workdir/tmp-artifacts/codacy-coverage-reporter-assembly.jar
237257
persist_to_workspace: true
238258
requires:
239-
- scalafmt_and_compile
259+
- compile_and_test
240260
- codacy/sbt_osx:
241261
name: create_artifacts_for_osx
242262
cmd: |
@@ -258,7 +278,7 @@ workflows:
258278
persist_to_workspace: true
259279
persist_to_workspace_path: "tmp-artifacts/codacy-coverage-reporter-darwin"
260280
requires:
261-
- scalafmt_and_compile
281+
- compile_and_test
262282
- package_artifacts:
263283
requires:
264284
- create_artifacts

build.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,6 @@ ThisBuild / assemblyMergeStrategy := {
100100
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
101101
oldStrategy(x)
102102
}
103+
104+
// required to upgrade org.scoverage.sbt-scoverage.2.0.6
105+
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

project/plugins.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
77
// Updates
88
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0")
99
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")
10+
11+
// Coverage
12+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6")
13+
evictionErrorLevel := Level.Warn

0 commit comments

Comments
 (0)