diff --git a/README.md b/README.md index 8e562b6..55a06a6 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/docs/advanced.md b/docs/advanced.md index e06af40..b42c7ca 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -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