Skip to content

Commit 332744a

Browse files
Merge pull request #5 from scoverage/main
Rebase to Main branch of parent project
2 parents da2dec1 + 1fdb369 commit 332744a

File tree

94 files changed

+1184
-506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1184
-506
lines changed

.git-blame-ignore-revs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# It's a good idea to ignore the following commits from git blame.j
2+
# You can read more about this here if you're unfamiliar:
3+
# https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame
4+
#
5+
# Added scalafmt
6+
af2396558918fea00eaa2da12906a3012eb72153

.github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"

.github/release-drafter.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
template: |
2+
## What’s Changed
3+
4+
$CHANGES

.github/workflows/ci.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '*.md'
7+
branches:
8+
- main
9+
pull_request:
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
java: [ '8', '11' ]
17+
18+
steps:
19+
- name: checkout the repo
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up JVM
25+
uses: actions/setup-java@v2
26+
with:
27+
distribution: 'adopt'
28+
java-version: ${{ matrix.java }}
29+
30+
- name: Run tests
31+
run: sbt scripted
32+
33+
formatting:
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: checkout the repo
38+
uses: actions/checkout@v2
39+
with:
40+
fetch-depth: 0
41+
42+
- name: Set up JVM
43+
uses: actions/setup-java@v2
44+
with:
45+
distribution: 'adopt'
46+
java-version: '8'
47+
48+
- name: Check Formatting
49+
run: sbt scalafmtCheckAll

.github/workflows/release-drafter.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
update_release_draft:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: release-drafter/release-drafter@v5
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags: ["*"]
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
14+
- uses: actions/setup-java@v2
15+
with:
16+
distribution: 'adopt'
17+
java-version: '11'
18+
- run: sbt ci-release
19+
env:
20+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
21+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
22+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
23+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

.scala-steward.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
updates.ignore = [ { groupId = "org.scala-lang" } ]

.scalafmt.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "3.0.2"

.travis.yml

-20
This file was deleted.

README.md

+79-96
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
1-
sbt-scoverage
2-
========
1+
# sbt-scoverage
32

4-
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).
5-
6-
Join the [scoverage](http://groups.google.com/group/scala-code-coverage-tool)
7-
google group for help, bug reports, feature requests, and general
8-
discussion on scoverage.
9-
10-
[![Build Status](https://travis-ci.org/scoverage/sbt-scoverage.png?branch=master)](https://travis-ci.org/scoverage/sbt-scoverage)
3+
[![Gitter](https://img.shields.io/gitter/room/scoverage/scoverage.svg)](https://gitter.im/scoverage/scoverage)
4+
[![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/)
115
[![License](http://img.shields.io/:license-Apache%202-red.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
12-
[<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)
136

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

16-
Make sure your SBT version in project/build.properties:
17-
```
18-
sbt.version = 0.13.17
19-
```
20-
or
21-
```
22-
sbt.version = 1.1.1
23-
```
11+
## Setup
12+
13+
**Requirements**: Requires sbt 1.2.8 or above
2414

25-
Add the plugin in project/plugins.sbt:
15+
In `project/plugins.sbt`:
2616
```scala
27-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
17+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "x.x.x")
2818
```
2919

20+
## Usage
21+
3022
Run the tests with enabled coverage:
3123
```
3224
$ sbt clean coverage test
@@ -37,7 +29,7 @@ $ sbt clean coverage it:test
3729
```
3830

3931
To enable coverage directly in your build, use:
40-
```
32+
```scala
4133
coverageEnabled := true
4234
```
4335

@@ -46,54 +38,40 @@ To generate the coverage reports run
4638
$ sbt coverageReport
4739
```
4840

49-
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.
50-
51-
If you're running the coverage reports from within an sbt console session (as
52-
opposed to one command per sbt launch), then the `coverage` command is sticky. To
53-
turn it back off when you're done running reports, use the `coverageOff` command or reset `coverageEnabled` with `set coverageEnabled := false`.
54-
55-
Sample project with scoverage in both sbt and maven - [the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).
56-
57-
## Notes on upgrading to version 1.6.0
58-
59-
* `coverageAggregate` aggregates raw coverage data, not coverage xml reports for modules.
60-
There is no requirement to generate individual coverage reports for modules (`coverageReport`)
61-
before generating aggregated report (`coverageAggregate`).
62-
63-
If only aggregated report is required, not executing `coverageReport` can reduce the build time significantly.
64-
65-
## Notes on upgrading to version 1.3.0
66-
67-
* 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.
68-
* 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.
41+
Coverage reports will be in your `target/scala-<scala-version>/scoverage-report`
42+
directory. There are HTML and XML reports. The XML is useful if you need to
43+
programatically use the results, or if you're writing a tool.
6944

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

72-
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.
51+
### Multi project reports
7352

74-
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.
53+
By default, scoverage will generate reports for each project separately. You can
54+
merge them into an aggregated report by using the following:
7555

76-
## Multi project reports
77-
78-
By default, scoverage will generate reports for each project separately. You can merge them into an aggregated report by invoking `sbt coverageAggregate`.
79-
80-
(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).)
56+
```
57+
$ sbt coverageAggregate
58+
```
8159

82-
(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.)
60+
**NOTE**: You do not need to run `coverageReport` before `coverageAggregate`; it
61+
aggregates over the sub-projects' coverage data directly, not the report xml.
8362

84-
## Exclude classes and packages
63+
### Exclude classes and packages
8564

86-
You can exclude classes from being considered for coverage measurement by providing semicolon-separated list of
87-
regular expressions.
65+
You can exclude classes from being considered for coverage measurement by
66+
providing semicolon-separated list of regular expressions.
8867

89-
Example:
9068
```scala
9169
coverageExcludedPackages := "<empty>;Reverse.*;.*AuthService.*;models\\.data\\..*"
9270
```
9371

94-
The regular expressions are matched against the fully qualified class name, and must match the entire string to take effect.
95-
96-
Any matched classes will not be instrumented or included in the coverage report.
72+
The regular expressions are matched against the fully qualified class name, and
73+
must match the entire string to take effect. Any matched classes will not be
74+
instrumented or included in the coverage report.
9775

9876
You can also mark sections of code with comments like:
9977

@@ -103,67 +81,72 @@ You can also mark sections of code with comments like:
10381
// $COVERAGE-ON$
10482
```
10583

106-
Any code between two such comments will not be instrumented or included in the coverage report.
84+
Any code between two such comments will not be instrumented or included in the
85+
coverage report.
10786

108-
## Minimum coverage
87+
### Minimum coverage
10988

110-
Based on minimum coverage, you can fail the build with the following keys
89+
Based on minimum coverage, you can fail the build with the following keys:
11190

11291
```scala
113-
coverageMinimum := 80
11492
coverageFailOnMinimum := true
93+
coverageMinimumStmtTotal := 90
94+
coverageMinimumBranchTotal := 90
95+
coverageMinimumStmtPerPackage := 90
96+
coverageMinimumBranchPerPackage := 85
97+
coverageMinimumStmtPerFile := 85
98+
coverageMinimumBranchPerFile := 80
11599
```
116100

117-
These settings will be enforced when the reports are generated.
118-
If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report.
119-
120-
## Highlighting
101+
These settings will be enforced when the reports are generated. If you generate
102+
an aggregate report using `coverageAggregate` then these settings will apply to
103+
that report.
121104

122-
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:
123-
124-
```scala
125-
coverageHighlighting := false
126-
```
105+
## Trouble-shooting failing tests
127106

128-
## Failing tests
129-
Scoverage does a lot of file writing behind the scenes in order to track which statements have been executed.
130-
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:
107+
scoverage does a lot of file writing behind the scenes in order to track which
108+
statements have been executed. If you are running into a scenario where your
109+
tests normally pass, but fail when scoverage is enabled, then the culprit can be
110+
one of the following:
131111

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

115+
## Example project
116+
117+
[the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).
118+
135119
## Integrations
136120

137121
### Codacy
138122

139-
[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).
123+
[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to
124+
provide an in-depth overlook of your project status. scoverage information can
125+
be integrated into Codacy through the
126+
[codacy-coverage-reporter](https://github.com/codacy/codacy-coverage-reporter).
140127

141128
### Coveralls
142129

143-
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.
144-
145-
### Plugin for SonarQube
130+
If you have an open source project then you can add code coverage metrics with
131+
the [Coveralls](https://coveralls.io/). scoverage will integrate with coveralls
132+
using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin.
146133

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

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

156-
Copyright 2013-2016 Stephen Samuel and contributors
140+
### Plugin for SonarQube
157141

158-
Licensed under the Apache License, Version 2.0 (the "License"); you may not
159-
use this file except in compliance with the License. You may obtain a copy of
160-
the License at
142+
If you want to visually browse statement coverage reports then use this [plugin
143+
for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin). It
144+
allows you to review overall project statement coverage as well as dig deeper
145+
into sub-modules, directories and source code files to see uncovered statements.
146+
Statement coverage measurement can become an integral part of your team's
147+
continuous integration process and a required quality standard.
161148

162-
http://www.apache.org/licenses/LICENSE-2.0
149+
## Release Notes
163150

164-
Unless required by applicable law or agreed to in writing, software
165-
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
166-
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
167-
License for the specific language governing permissions and limitations under
168-
the License.
169-
```
151+
For any information on releases and upgrading, please refer to the [release
152+
page](https://github.com/scoverage/sbt-scoverage/releases).

0 commit comments

Comments
 (0)