Skip to content

Commit 54bfdbd

Browse files
authored
Document Istanbul check-coverage cli command (#834)
1 parent abea00b commit 54bfdbd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Common problems & questions:
123123
+ [Running out of stack][1002] (Stack too deep)
124124
+ [Running out of memory][5]
125125
+ [Running in parallel (in CI)][1003]
126+
+ [Running coverage threshold checks][1004]
126127

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

docs/advanced.md

+13
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ There's a nice example of this being done in CircleCI [at Synthetix, here][31].
138138

139139
: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.
140140

141+
## Coverage threshold checks
142+
143+
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.)
144+
145+
```shell
146+
# Usage
147+
148+
$ npx istanbul check-coverage ./coverage.json --statements 99 --branches 94 --functions 99 --lines 99
149+
150+
ERROR: Coverage for statements (60%) does not meet global threshold (99%)
151+
ERROR: Coverage for lines (60%) does not meet global threshold (99%)
152+
ERROR: Coverage for functions (66.67%) does not meet global threshold (99%)
153+
```
141154

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

0 commit comments

Comments
 (0)