Package: diff-cov-lint
Diff cov lintLinting and coverage reports for git diff only.Usage:diff-cov-lint master new_branch --cov_report=coverage.xml --lint_report=pylint_output.txtExample output (the command above was run intests/repofolder):======================== 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 ARGUMENTSTARGET_REFTarget branch in repoSOURCE_REFSource branch in repoFLAGS--cov_report=COV_REPORTPath to coverage report in Cobertura (pytest-cov) format, If not stated, coverage report will not be produced.--lint_report=LINT_REPORTPath to pylint report. If not stated, linting report will not be produced.--repo_path=REPO_PATHPath to repo folder, defaults to "."--show_missingFlag to show missing lines, defaults to falseCI SetupThis project's repo uses diff-cov-lint itself. You might want to check.gitlab-ci.ymlfor full configuration.Simple scenarioCalculate diff coverage and produce diff pylint reports for merge requestscode_quality_diff:stage:code_quality_diffscript:-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 branchMore complicated scenarioRun 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:testscript:-pytest --cov=your_source_folder --cov-report xml tests# run pytest and produce xml reportartifacts:paths:-coverage.xml# save xml report to use it in further jobsonly:-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 jobDiff code quality job:code_quality_diff:stage:code_quality_diffscript:-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_requestsFull code quality job:code_quality_full:stage:code_quality_fullscript:-pytest --cov=your_source_folder tests# simply run pytest with coverage and pylint as usual-pylint --exit-zero diff_cov_lintrules:-if:'$CI_COMMIT_REF_NAME=="master"'-if:$CI_MERGE_REQUEST_IDwhen:never#otherwise this job will stuck for merge requests-when:manual# use manual to make this job optional for all other pipelines.