coveragecheck
coveragecheck is a tool that reports lines of code from diff that are not covered (or excluded) in project coverage report. The intent is for this tool to be invoked in a continuous integration pipeline to enforce that merging code has full statement coverage.
The tool is compatible with any diff in unified diff format, and a coverage report formatted as a JSON dictionary similar to the output of coverage.py. Example usage is shown below.
Installing
The simplest way to install is to use pip:
pip install coveragecheck
The tool can also be installed by cloning this repository and putting coveragecheck.py on your path:
git clone https://github.com/jdn5126/CoverageChecker.git
Continuous Integration Pipeline
For an example script for a continuous integration pipeline, check out the GitHub Actions configured for this repository in
.github/workflows/coverage_check.yml. These steps should translate to any continuous integration application/automation server.
Example
The example directory, which contains a simple Python library and test file, allows us to test coveragecheck:
Add a new class to example/lib.py without any test coverage:
class Bar(object):
def __init__(self, name):
self.name = name
def getName(self):
return self.name
Generate the coverage report using coverage.py:
$ cd example
$ coverage run -m unittest discover
$ coverage json
Invoke coveragecheck to show missing coverage:
$ git diff | coveragecheck -r coverage.json
Failure
Files missing coverage:
example/lib.py:
16 self.name = name
19 return self.name
Add coverage to test.py:
from lib import Foo, Bar
...
class TestBarCoverage(unittest.TestCase):
def test_bar(self):
print( 'TestBarCoverage: test_bar')
bar = Bar("bar")
assert bar.getName() == "bar"
Regenerate coverage report as shown above, then invoke coveragecheck:
$ git diff | coveragecheck.py -r coverage.json
Success!
Contributing
Contributions and issues are welcome!
To get started, simply install the required Python dependencies using:
pip install -r requirements.txt
Metadata
Release files for coveragecheck 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| coveragecheck-0.0.3.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| coveragecheck-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / coveragecheck-0.0.3.tar.gz
| Download URL | coveragecheck-0.0.3.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1e29f674540747fd69a07cf32c4ac80910adb6fb4aa7aa59325098557492e56
|
|
BLAKE2b-256 checksum How to use checksums |
1f862cf58a19dc67b43d6b5d8fa1f1b77a0ffc87fb4bf5e931aaee4c7ed01175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7
|
Release files / coveragecheck-0.0.3-py3-none-any.whl
| Download URL | coveragecheck-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
334ed1b4d32fcaa59dad150dd8655145241657a30809b765c3b33b84cd66d95b
|
|
BLAKE2b-256 checksum How to use checksums |
bc6f77867e410e68e32d8bbe1e4fe228e0de48eeab18007e49dcf3e54c95d25b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7
|