Package: ccguard
ccguardyou can only improve! :-)ccguard compares the current code coverage to past code coverage. ccguard fails unless your new code coverage is equal or better than your past code coverage!requirespython3 (on the server)githow should you use this softwaresetup the serverdefine your code coverage exclusions and inclusions (in your test runner, not in ccguard)setup the CI workflow so that ccguard can (herefor CircleCI)ingest the code coverage reportsend it to the serverensure that the coverage improves(optional, but required for the following steps) download reports on your computer usingccguard_sync(recommended) inspect the git/reference log withccguard_log(optional) display the code coverage for a specific commit withccguard_show(optional) display the code coverage diff between two references withccguard_diffwelcome beta testers: setup# prepare the package and install it./distrib.shcontribute./bootstrap.shplease execute flake8, black, pytest and ccguard against all of your changes.
(a pre-commit hook will ensure that everythng is fine before letting you commit)./pre-commitccguard - the code coverage guardcdyour-favorite-source-folder# execute unit tests, collecting code coverage hereccguardcoverage.xml# change your code somehow# execute unit tests, collecting code coverage# then verify that your code coverage has not decreasedccguard--consider-uncommitted-changescoverage.xml# if you are rather a visual person, check cc.html and diff.htmlccguard--html--consider-uncommitted-changescoverage.xml# if needed to display the line coverage for each file in the HTML report,# fine tune the source files path with the --repository argumentccguard--html--consider-uncommitted-changescoverage.xml--repositorysrc/# allow regressions up to 3%ccguardcoverage.xml--tolerance3# allow regressions up to 10%, but never descend below 70%ccguardcoverage.xml--tolerance10--hard-minimum70# use the web adapter (ie. send the data to ccguard_server).# requires a ccguard.server.address setting in the config.ccguardcoverage.xml--adapterwebplease seehow to produce code coverage datain your favourite language.display code coverage trendsWhat a better feedback loop than measuring the work you have accomplished?ccguard_logdisplay code coverage reportYou could be curious about how the code coverage looked like a few commits ago..ccguard_show7b43f26display code coverage diffAnd, you could be curious about how the code coverage has evolved between two commits.ccguard_diff3413af37b43f26synchronize repositoriesThe use case being: you wish to use ccguard as pre-commit. Your team already has some references.
Then you could be interested in sharing them.# upload the report to a distant redis repositoryccguard_syncsqliteredis# download the report from a distant redis repositoryccguard_syncredissqlite# limit to a single repositoryccguard_syncredissqlite--repository_idabcd# limit to a single repository and a single commitccguard_syncredissqlite--repository_idabcd--commit_idef12# retrieve data from a specific web server, and display whats going on behind the scenesccguard_server_address=https://ccguard.nilleb.comccguard_syncwebsqlite--debuglaunch a local serverccguard_server allows you to centralize the reports and the regression checks (useful for CI workflows)
also serves coverage and diff reports.ccguard_serverYou could be interested to know how tosetup the server.convert a reportSometimes you need to convert a report from a format to another. ccguard_convert is here to help!# convert the report from golang textual format to cobertura.xmlccguard_convertgolang-coverage-report.txt-ifgo-ofxml-ooutput.xml# convert the report from cobertura xml format to html (pycobertura)ccguard_convertcobertura.xml-ifxml-ofhtml-ooutput.html# convert the report from golang textual format to html (pycobertura)ccguard_convertgolang-coverage-report.txt-ifgo-ofhtml-ooutput.html# you can add a .ccguard.config.json in the same directory of the report or to your home directory to fine tune the exclusionsecho'{"convert.exclusions.go": ["**/config/default.go"]}'>.ccguard.config.json# the report will not contain the files matching the glob expressionccguard_convertgolang-coverage-report.txt-ifgo-ofxml-ooutput.xmlTo know more about glob expressions, seeman 3 fnmatch.expose a status badgeAdd the following Markdown to your README.md[![CodeCoverage](https://ccguard.nilleb.com/api/v1/repositories/a8858db8a0d483f8f6c8e74a5dc03b84bc9674f8/status_badge.svg?branch=master)](https://ccguard.nilleb.com/web/main/a8858db8a0d483f8f6c8e74a5dc03b84bc9674f8)(make sure that you change your repository_id to match the one printed by accguard --debug)alternatives to this softwareopencovdiff-covercodecov.iocoveralls.iosonarqubecreditsAlexandre Conradfor his wonderful pycoberturaall the beta testers for their precious feedback