Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase to parent #6

Open
wants to merge 90 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
19a6673
added TC branch coverage reporting
alexnikitchuk May 2, 2018
9defcea
Fixed README to say you do not need to run coverageReport before cove…
Jan 29, 2020
d45e59b
Merge pull request #302 from arkban/fixCoverageReportAggregateInReadme
0xRoch Feb 3, 2021
78eac8d
Typo
Feb 5, 2021
fb8480e
Depend on the exact bincompat (patch) version of scalac
Feb 5, 2021
192db28
Adding PR workflow
Feb 5, 2021
aaff04c
Merge pull request #320 from blast-hardcheese/build-cross-version-full
0xRoch Feb 6, 2021
e944e6d
cleanup build file, js test fix
domizei385 Apr 27, 2021
5d298ed
only use major sjs version, changes as per review comments
domizei385 Apr 28, 2021
eb9fba9
Update to newly released 1.4.3
ckipp01 Apr 28, 2021
fe21a51
Merge pull request #324 from domizei385/updates
ckipp01 Apr 28, 2021
80708de
Remove cross from release
ckipp01 Apr 28, 2021
aa00d3f
Merge pull request #325 from ckipp01/cross
ckipp01 Apr 28, 2021
f7c409e
Bump pgp plugin and remove extra matrix.
ckipp01 Apr 28, 2021
69d5060
Merge pull request #326 from ckipp01/pgp
ckipp01 Apr 28, 2021
3e5cdc0
Setting version to 1.7.0
ckipp01 Apr 28, 2021
78caf76
Setting version to 1.7.1-SNAPSHOT
ckipp01 Apr 28, 2021
fd123f9
Merge pull request #327 from ckipp01/master
ckipp01 Apr 28, 2021
8f216f5
Fix shields
ckipp01 Apr 29, 2021
0467efe
Merge pull request #329 from ckipp01/shields
ckipp01 Apr 29, 2021
c929d3e
Correct report location in readme.
ckipp01 Apr 29, 2021
1660e91
Merge pull request #330 from ckipp01/location
ckipp01 Apr 29, 2021
3c41a98
Update CI and release strategy
ckipp01 May 1, 2021
8c2c79e
Merge pull request #331 from ckipp01/release
ckipp01 May 1, 2021
c2a34da
Remove no longer needed travis file
ckipp01 May 1, 2021
37258c6
Merge pull request #332 from ckipp01/getOutOfHere
ckipp01 May 1, 2021
abd6515
Update to scoverage 1.4.4.
ckipp01 May 2, 2021
bffa0fd
Merge pull request #334 from ckipp01/update
ckipp01 May 2, 2021
89511a6
Remove explicit version in example in docs.
ckipp01 May 2, 2021
fe25bfb
Merge pull request #335 from ckipp01/docs
ckipp01 May 2, 2021
313d3e6
Update default branch from master to main
ckipp01 May 2, 2021
d741525
Merge pull request #337 from ckipp01/update-branch
ckipp01 May 2, 2021
321863c
Add in dependabot for actions, and release drafter stuff.
ckipp01 May 2, 2021
239a266
Merge pull request #338 from ckipp01/drafter
ckipp01 May 2, 2021
8b11eba
Test on jdk 8 and 11
ckipp01 May 2, 2021
93edf00
Merge pull request #340 from ckipp01/ci
ckipp01 May 2, 2021
2b12851
Update to latest scoverage 1.4.5
ckipp01 May 2, 2021
90cae8b
Merge pull request #341 from ckipp01/update
ckipp01 May 2, 2021
8a2726c
Make sure buildInfo is in it's own package.
ckipp01 May 4, 2021
0f12390
Merge pull request #342 from ckipp01/namespace
ckipp01 May 4, 2021
50f58c9
Don't have a local snapshot version
ckipp01 May 4, 2021
183fbad
Merge pull request #343 from ckipp01/bump
ckipp01 May 4, 2021
af23965
Add in Scalafmt
ckipp01 May 6, 2021
db47a65
Merge pull request #344 from ckipp01/scalafmt
ckipp01 May 6, 2021
443f12b
Remove scala-compiler as a dep.
ckipp01 May 6, 2021
6d87354
Overhaul the README
ckipp01 May 6, 2021
af9d4b9
Merge pull request #346 from ckipp01/docs
ckipp01 May 6, 2021
7bb57d4
Report test names
vincentdehaan Oct 10, 2019
c6fca81
Merge pull request #345 from ckipp01/compiler
ckipp01 May 6, 2021
17e2575
Merge pull request #297 from vincentdehaan/feature/report-test-names
ckipp01 May 7, 2021
c43b43a
Merge branch 'main' into master
ckipp01 May 7, 2021
464cb01
Merge pull request #258 from alexnikitchuk/master
ckipp01 May 7, 2021
6225254
Update tests in scripted.
ckipp01 May 7, 2021
db352b8
Merge pull request #347 from ckipp01/scripted
ckipp01 May 7, 2021
fdc20aa
Coverage minima: add more fine-grained control
May 8, 2021
3af76cc
Update sbt, scripted-plugin to 1.5.2
scala-steward May 10, 2021
550b3e8
Merge pull request #348 from scala-steward/update/sbt-1.5.2
ckipp01 May 10, 2021
34490a3
Merge pull request #253 from kitbellew/covmin
ckipp01 May 10, 2021
ea3e142
Bump scoverage version to 1.4.6
ckipp01 May 10, 2021
cadb042
Merge pull request #349 from ckipp01/scalac-scoveage
ckipp01 May 10, 2021
a15cce2
Add in missing percent sign for branch coverage
ckipp01 May 11, 2021
2bcb322
Merge pull request #350 from ckipp01/missing-percent
ckipp01 May 11, 2021
6d9d65a
Add in .git-blame-ignore-revs
ckipp01 May 11, 2021
910ee0d
Merge pull request #351 from ckipp01/blame-ignore-refs
ckipp01 May 11, 2021
90289bb
Bump scoverage version to 1.4.7
ckipp01 May 19, 2021
9811fc3
Merge pull request #353 from ckipp01/scoverageUpdate
ckipp01 May 19, 2021
f9874cd
Update scalac-scoverage-plugin to 1.4.8
scala-steward May 28, 2021
e8e3505
Merge pull request #354 from scala-steward/update/scalac-scoverage-pl…
ckipp01 May 28, 2021
4dcf121
Update sbt, scripted-plugin to 1.5.3
scala-steward Jun 1, 2021
bad6866
Update to scala 2.12.14
samupra Jun 4, 2021
99c4822
Merge pull request #355 from scala-steward/update/sbt-1.5.3
ckipp01 Jun 4, 2021
03de62e
Merge pull request #356 from samupra/main
ckipp01 Jun 4, 2021
f8952fd
Update sbt, scripted-plugin to 1.5.4
scala-steward Jun 14, 2021
bad92cb
Merge pull request #357 from scala-steward/update/sbt-1.5.4
ckipp01 Jun 14, 2021
8b3f4de
Update sbt-scalafmt to 2.4.3
scala-steward Jul 9, 2021
ca24fe4
Merge pull request #359 from scala-steward/update/sbt-scalafmt-2.4.3
ckipp01 Jul 10, 2021
9d9fa31
Update sbt, scripted-plugin to 1.5.5
scala-steward Jul 12, 2021
ed3de78
Merge pull request #361 from scala-steward/update/sbt-1.5.5
ckipp01 Jul 12, 2021
369559e
Update scalafmt-core to 3.0.0
scala-steward Aug 19, 2021
cf2dcac
Reformat with scalafmt 3.0.0
scala-steward Aug 19, 2021
828a491
Merge pull request #363 from scala-steward/update/scalafmt-core-3.0.0
ckipp01 Aug 19, 2021
9d96252
Update scalafmt-core to 3.0.1
scala-steward Aug 27, 2021
a532e6f
Merge pull request #364 from scala-steward/update/scalafmt-core-3.0.1
ckipp01 Aug 28, 2021
9141cf7
Update scalafmt-core to 3.0.2
scala-steward Sep 4, 2021
1fdb369
Merge pull request #365 from scala-steward/update/scalafmt-core-3.0.2
ckipp01 Sep 4, 2021
332744a
Merge pull request #5 from scoverage/main
pzhong-livongo Sep 7, 2021
1839027
Allow for overriding location for coverage data and report
pzhong-livongo Sep 8, 2021
4324103
Update src/main/scala/scoverage/ScoverageKeys.scala
pzhong-livongo Sep 10, 2021
58ae1b3
Update ScoverageSbtPlugin.scala
pzhong-livongo Sep 10, 2021
1246442
Update build.sbt
pzhong-livongo Sep 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# It's a good idea to ignore the following commits from git blame.j
# You can read more about this here if you're unfamiliar:
# https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame
#
# Added scalafmt
af2396558918fea00eaa2da12906a3012eb72153
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed

$CHANGES
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
push:
paths-ignore:
- '*.md'
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8', '11' ]

steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JVM
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}

- name: Run tests
run: sbt scripted

formatting:
runs-on: ubuntu-latest

steps:
- name: checkout the repo
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up JVM
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'

- name: Check Formatting
run: sbt scalafmtCheckAll
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release
on:
push:
branches:
- main
tags: ["*"]
jobs:
publish:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
1 change: 1 addition & 0 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
updates.ignore = [ { groupId = "org.scala-lang" } ]
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "3.0.2"
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

182 changes: 90 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
sbt-scoverage
========
# sbt-scoverage

sbt-scoverage is a plugin for SBT that integrates the scoverage code coverage library. Find out more about [scoverage](https://github.com/scoverage/scalac-scoverage-plugin).

Join the [scoverage](http://groups.google.com/group/scala-code-coverage-tool)
google group for help, bug reports, feature requests, and general
discussion on scoverage.

[![Build Status](https://travis-ci.org/scoverage/sbt-scoverage.png?branch=master)](https://travis-ci.org/scoverage/sbt-scoverage)
[![Gitter](https://img.shields.io/gitter/room/scoverage/scoverage.svg)](https://gitter.im/scoverage/scoverage)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scoverage/sbt-scoverage/badge.svg?kill_cache=1)](https://search.maven.org/artifact/org.scoverage/sbt-scoverage/)
[![License](http://img.shields.io/:license-Apache%202-red.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
[<img src="https://img.shields.io/maven-central/v/org.scoverage/sbt-scoverage.svg?label=latest%20release"/>](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22sbt-scoverage%22)

## How to use
sbt-scoverage is a plugin for sbt that integrates the scoverage code coverage
library. Find out more about
[scoverage here](https://github.com/scoverage/scalac-scoverage-plugin).

Make sure your SBT version in project/build.properties:
```
sbt.version = 0.13.17
```
or
```
sbt.version = 1.1.1
```
## Setup

**Requirements**: Requires sbt 1.2.8 or above

Add the plugin in project/plugins.sbt:
In `project/plugins.sbt`:
```scala
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "x.x.x")
```

## Usage

Run the tests with enabled coverage:
```
$ sbt clean coverage test
Expand All @@ -37,7 +29,7 @@ $ sbt clean coverage it:test
```

To enable coverage directly in your build, use:
```
```scala
coverageEnabled := true
```

Expand All @@ -46,54 +38,40 @@ To generate the coverage reports run
$ sbt coverageReport
```

Coverage reports will be in `target/scoverage-report`. There are HTML and XML reports. The XML is useful if you need to programatically use the results, or if you're writing a tool.

If you're running the coverage reports from within an sbt console session (as
opposed to one command per sbt launch), then the `coverage` command is sticky. To
turn it back off when you're done running reports, use the `coverageOff` command or reset `coverageEnabled` with `set coverageEnabled := false`.

Sample project with scoverage in both sbt and maven - [the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).

## Notes on upgrading to version 1.6.0

* `coverageAggregate` aggregates raw coverage data, not coverage xml reports for modules.
There is no requirement to generate individual coverage reports for modules (`coverageReport`)
before generating aggregated report (`coverageAggregate`).

If only aggregated report is required, not executing `coverageReport` can reduce the build time significantly.

## Notes on upgrading to version 1.3.0

* The object containing the keys has changed from nested to top level so you might need to adjust the import. It's also an auto plugin now, so you might not need the import at all.
* There is an issue syncing the binary with the sbt-plugin-releases repo, so in the meantime add `resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(Resolver.ivyStylePatterns)` to your build.
Coverage reports will be in your `target/scala-<scala-version>/scoverage-report`
directory. There are HTML and XML reports. The XML is useful if you need to
programatically use the results, or if you're writing a tool.

## Notes on upgrading to version 1.0.0
**NOTE**: If you're running the coverage reports from within an sbt console
session (as opposed to one command per sbt launch), then the `coverage` command
is sticky. To turn it back off when you're done running reports, use the
`coverageOff` command or reset `coverageEnabled` with `set coverageEnabled :=
false`.

If you are upgrading from 0.99.x then you must remove the `instrumentSettings` from your build.sbt or Build.scala, as that is no longer needed.
### Multi project reports

Next, the keys have been renamed slightly. The new names begin with coverageXXX, eg coverageExcludedPackages and some have had their full name changed. You can see a full list of keys by opening the object ScoverageKeys.
By default, scoverage will generate reports for each project separately. You can
merge them into an aggregated report by using the following:

## Multi project reports

By default, scoverage will generate reports for each project separately. You can merge them into an aggregated report by invoking `sbt coverageAggregate`.

(Note, you must do this after all the coverage data is complete as a separate command, so you cannot do `sbt coverage test coverageAggregate` (at least until a way around this is found).)
```
$ sbt coverageAggregate
```

(You must have first run `sbt coverageReport` for `coverageAggregate` to work. It aggregates over the sub-projects' report xml rather than over the coverage data directly.)
**NOTE**: You do not need to run `coverageReport` before `coverageAggregate`; it
aggregates over the sub-projects' coverage data directly, not the report xml.

## Exclude classes and packages
### Exclude classes and packages

You can exclude classes from being considered for coverage measurement by providing semicolon-separated list of
regular expressions.
You can exclude classes from being considered for coverage measurement by
providing semicolon-separated list of regular expressions.

Example:
```scala
coverageExcludedPackages := "<empty>;Reverse.*;.*AuthService.*;models\\.data\\..*"
```

The regular expressions are matched against the fully qualified class name, and must match the entire string to take effect.

Any matched classes will not be instrumented or included in the coverage report.
The regular expressions are matched against the fully qualified class name, and
must match the entire string to take effect. Any matched classes will not be
instrumented or included in the coverage report.

You can also mark sections of code with comments like:

Expand All @@ -103,67 +81,87 @@ You can also mark sections of code with comments like:
// $COVERAGE-ON$
```

Any code between two such comments will not be instrumented or included in the coverage report.
Any code between two such comments will not be instrumented or included in the
coverage report.

## Minimum coverage
### Minimum coverage

Based on minimum coverage, you can fail the build with the following keys
Based on minimum coverage, you can fail the build with the following keys:

```scala
coverageMinimum := 80
coverageFailOnMinimum := true
coverageMinimumStmtTotal := 90
coverageMinimumBranchTotal := 90
coverageMinimumStmtPerPackage := 90
coverageMinimumBranchPerPackage := 85
coverageMinimumStmtPerFile := 85
coverageMinimumBranchPerFile := 80
```

These settings will be enforced when the reports are generated.
If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report.
These settings will be enforced when the reports are generated. If you generate
an aggregate report using `coverageAggregate` then these settings will apply to
that report.

## Highlighting
### Override Location for Coverage Data And Report

If you are using Scala 2.11.1 or less, then highlighting will not work (due to this bug which was fixed in 2.11.2 https://github.com/scala/scala/pull/3799). In that case you must disable highlighting by adding the following to your build:
If desired, one could override the default location for generating the sbt report and data through setting `coverageDataDir`:

Example in data-dir test:
```scala
coverageHighlighting := false
coverageDataDir := target.value / "custom-test"
```

## Failing tests
Scoverage does a lot of file writing behind the scenes in order to track which statements have been executed.
If you are running into a scenario where your tests normally pass, but fail when scoverage is enabled, then the culprit can be one of the following:
Can also be set through the sbt set directive
```scala
set coverageDataDir := file("/tmp")
```


## Trouble-shooting failing tests

scoverage does a lot of file writing behind the scenes in order to track which
statements have been executed. If you are running into a scenario where your
tests normally pass, but fail when scoverage is enabled, then the culprit can be
one of the following:

* timing issues on futures and other async operations, try upping the timeouts by an order of magnitude.
* tests are run in a sandbox mode (such as with `java.security.PrivilegedAction<T>`), try running the tests outside of the sandbox.

## Example project

[the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).

## Integrations

### Codacy

[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to provide an in-depth overlook of your project status. Scoverage information can be integrated into Codacy through the [sbt-codacy-coverage plugin](https://github.com/codacy/sbt-codacy-coverage).
[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to
provide an in-depth overlook of your project status. scoverage information can
be integrated into Codacy through the
[codacy-coverage-reporter](https://github.com/codacy/codacy-coverage-reporter).

### Coveralls

If you have an open source project then you can add code coverage metrics with the excellent website https://coveralls.io/ Scoverage will integrate with coveralls using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin.

### Plugin for SonarQube
If you have an open source project then you can add code coverage metrics with
the [Coveralls](https://coveralls.io/). scoverage will integrate with coveralls
using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin.

If you want to visually browse statement coverage reports then use this [plugin for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin).
It allows you to review overall project statement coverage as well as dig deeper into sub-modules, directories and
source code files to see uncovered statements. Statement coverage measurement can become an integral part of your
team's continuous integration process and a required quality standard.
### Codecov

## License
```
This software is licensed under the Apache 2 license, quoted below.
You can integrate with [Codecov](https://about.codecov.io/) easily sending your
reports there via your CI. You can see an example of this here in
[codecov/example-scala](https://github.com/codecov/example-scala).

Copyright 2013-2016 Stephen Samuel and contributors
### Plugin for SonarQube

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
If you want to visually browse statement coverage reports then use this [plugin
for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin). It
allows you to review overall project statement coverage as well as dig deeper
into sub-modules, directories and source code files to see uncovered statements.
Statement coverage measurement can become an integral part of your team's
continuous integration process and a required quality standard.

http://www.apache.org/licenses/LICENSE-2.0
## Release Notes

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.
```
For any information on releases and upgrading, please refer to the [release
page](https://github.com/scoverage/sbt-scoverage/releases).
Loading