Set of tools for validating code coverage as a merge criterion in a CI pipeline.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coveragecheck-0.0.3.tar.gz.
File metadata
- Download URL: coveragecheck-0.0.3.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1e29f674540747fd69a07cf32c4ac80910adb6fb4aa7aa59325098557492e56
|
|
| MD5 |
2713d2907b48e9f015cf10baccb73460
|
|
| BLAKE2b-256 |
1f862cf58a19dc67b43d6b5d8fa1f1b77a0ffc87fb4bf5e931aaee4c7ed01175
|
File details
Details for the file coveragecheck-0.0.3-py3-none-any.whl.
File metadata
- Download URL: coveragecheck-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
334ed1b4d32fcaa59dad150dd8655145241657a30809b765c3b33b84cd66d95b
|
|
| MD5 |
2dcccb46bd9741b14ab02649016fb600
|
|
| BLAKE2b-256 |
bc6f77867e410e68e32d8bbe1e4fe228e0de48eeab18007e49dcf3e54c95d25b
|