Skip to content

Commit

Permalink
Document Istanbul check-coverage cli command (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke committed Jan 27, 2024
1 parent abea00b commit 54bfdbd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Common problems & questions:
+ [Running out of stack][1002] (Stack too deep)
+ [Running out of memory][5]
+ [Running in parallel (in CI)][1003]
+ [Running coverage threshold checks][1004]

## Example reports
+ [metacoin][9] (Istanbul HTML)
Expand Down Expand Up @@ -218,4 +219,5 @@ $ yarn
[1001]: https://docs.soliditylang.org/en/v0.8.0/using-the-compiler.html#input-description
[1002]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-out-of-stack
[1003]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/advanced.md#parallelization-in-ci
[1004]: https://github.com/sc-forks/solidity-coverage/blob/master/docs/advanced.md#coverage-threshold-checks

13 changes: 13 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ There's a nice example of this being done in CircleCI [at Synthetix, here][31].

:bulb: **Pro Tip**: Codecov CI will automatically combine coverage reports sent to them as a batch - if you're using that service you don't need to do this yourself.

## Coverage threshold checks

Istanbul has a command line utility which can be used to set thresholds for different coverage categories and throw an error if your coverage drops below them. (Istanbul is a solidity-coverage dependency so you shouldn't need to install it separately.)

```shell
# Usage

$ npx istanbul check-coverage ./coverage.json --statements 99 --branches 94 --functions 99 --lines 99

ERROR: Coverage for statements (60%) does not meet global threshold (99%)
ERROR: Coverage for lines (60%) does not meet global threshold (99%)
ERROR: Coverage for functions (66.67%) does not meet global threshold (99%)
```

[22]: https://github.com/JoranHonig/vertigo#vertigo
[23]: http://spideruci.org/papers/jones05.pdf
Expand Down

0 comments on commit 54bfdbd

Please sign in to comment.