Diff cov lint
Linting and coverage reports for git diff only.
Usage:
diff-cov-lint master new_branch --cov_report=coverage.xml --lint_report=pylint_output.txt
Example output (the command above was run in tests/repo folder):
======================== DIFF COVERAGE ========================
FILE COVERED STMTS PERCENT
src/add.py 5 8 62.5%
src/modify.py 1 2 50.0%
===============================================================
TOTAL DIFF COV 6 10 60.0%
========================== DIFF LINT ==========================
src/add.py:10:0 E0602: Undefined variable 'this_line_makes_no_sense' (undefined-variable)
Arguments:
POSITIONAL ARGUMENTS
TARGET_REF
Target branch in repo
SOURCE_REF
Source branch in repo
FLAGS
--cov_report=COV_REPORT
Path to coverage report in Cobertura (pytest-cov) format, If not stated, coverage report will not be produced.
--lint_report=LINT_REPORT
Path to pylint report. If not stated, linting report will not be produced.
--repo_path=REPO_PATH
Path to repo folder, defaults to "."
--show_missing
Flag to show missing lines, defaults to false
CI Setup
This project's repo uses diff-cov-lint itself. You might want to check .gitlab-ci.yml for full configuration.
Simple scenario
Calculate diff coverage and produce diff pylint reports for merge requests
code_quality_diff:
stage: code_quality_diff
script:
- pytest --cov=your_source_folder --cov-report xml tests # run pytest and produce xml report
- git fetch -a # fetch all branches to calculate diff
- pip install diff-cov-lint # install diff-cov-lint
- pylint --exit-zero diff_cov_lint > pylint_output.txt # get pylint report. --exit-zero needed for job not to fail if pylint give score less than 10.
- diff-cov-lint origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME --cov_report coverage.xml --lint_report pylint_output.txt # run diff-cov-lint on diff between target branch and source branch.
only:
- merge_requests # required to know target branch and source branch
More complicated scenario
- Run tests on each push (test job)
- Calculate diff coverage and produce diff pylint reports for merge requests (code_quality_diff job)
- Get coverage and pylint report on full code on master or manually on any push. (code_quality_full job)
Test job:
test:
stage: test
script:
- pytest --cov=your_source_folder --cov-report xml tests # run pytest and produce xml report
artifacts:
paths:
- coverage.xml # save xml report to use it in further jobs
only:
- tags # tags and branches are default values of "only", so preserve them
- branches
- merge_requests # add merge_requests since code_quality_diff job will use artifacts of this job
Diff code quality job:
code_quality_diff:
stage: code_quality_diff
script:
- git fetch -a # fetch all branches to calculate diff
- pip install diff-cov-lint # install diff-cov-lint
- pylint --exit-zero diff_cov_lint > pylint_output.txt # get pylint report. --exit-zero needed for job not to fail if pylint give score less than 10.
- diff-cov-lint origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME --cov_report coverage.xml --lint_report pylint_output.txt # run diff-cov-lint on diff between target branch and source branch. coverage.xml is used from the artifact.
only:
- merge_requests
Full code quality job:
code_quality_full:
stage:
code_quality_full
script:
- pytest --cov=your_source_folder tests # simply run pytest with coverage and pylint as usual
- pylint --exit-zero diff_cov_lint
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
- if: $CI_MERGE_REQUEST_ID
when: never #otherwise this job will stuck for merge requests
- when: manual # use manual to make this job optional for all other pipelines.
Metadata
Release files for diff-cov-lint 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diff_cov_lint-0.1.4.tar.gz | 6.1 kB | Without provenance | Details for diff_cov_lint-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diff_cov_lint-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for diff_cov_lint-0.1.4-py3-none-any.whl |
Total release size: 14.4 kB
Release files / diff_cov_lint-0.1.4.tar.gz
| Download URL | diff_cov_lint-0.1.4.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
375413faedd13255694ecc001f8ba82396849cb7343cd99fd3105b05ec9f537b
|
|
BLAKE2b-256 checksum How to use checksums |
2db3f97bdce710b1dbfab27c81356b3a9aba36803fdcfdf77d08ad404aa134ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.6
|
Release files / diff_cov_lint-0.1.4-py3-none-any.whl
| Download URL | diff_cov_lint-0.1.4-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb502b511f0579152671e268d53b18527e40d991a419f8494b4890e4c065616c
|
|
BLAKE2b-256 checksum How to use checksums |
1b12cf7b90ea34f2371d15ae80c42f96902e5272dc23771e3fef8c1a14fa34e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.6
|
Security for diff-cov-lint 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.