仅适用于差异的Linting和coverage报告

diff-cov-lint的Python项目详细描述


差异cov lint

仅适用于git diff的Linting和coverage报告。在

用法:

diff-cov-lint master new_branch --cov_report=coverage.xml --lint_report=pylint_output.txt

输出示例(上面的命令在tests/repo文件夹中运行):

======================== 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)

参数:

位置参数
TARGET_REF 回购中的目标分行
SOURCE_REF 回购来源分行

标志
--cov_report=COV_REPORT
Cobertura(pytest cov)格式的覆盖率报告路径,如果未声明,则不会生成覆盖率报告。
--lint_report=LINT_REPORT
pylint报告的路径。如未注明,将不出具林绒报告。
--repo_path=REPO_PATH
回购文件夹的路径,默认为“” --show_missing 标志以显示缺少的行,默认为false

CI设置

这个项目的回购使用diff cov lint本身。您可能需要检查.gitlab-ci.yml的完整配置。在

简单场景

计算差异覆盖率并为合并请求生成diff-pylint报告

^{pr2}$

更复杂的情况

  • 对每个推送运行测试(测试作业)
  • 计算差异覆盖率并为合并请求生成diff pylint报告(code_quality_diff job)
  • 获取覆盖率和pylint报告的完整代码在主或手动推。(代码-质量-全部工作)

测试作业:

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 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_requests

全代码质量作业:

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. 

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
数据库java操作符是如何工作的?   带有JSON迭代器的java类型安全警告   java@NotNull类型注释Solrj   JDBC无法将19y旧Java连接到新的SQL Server。它在旧服务器上运行良好   java两个线程获得相同的值   java阶乘方法工作不好!   java Android体系结构决策   java如何使用JSON中的@RequestBody绑定自定义对象的映射   java Android ActionBarSherlock定制topbar?   java自定义DozerConverter仅在SpringBoot测试中调用   java为什么Hibernate试图映射@Transient方法?   MongoDB Java自己的编解码器不工作   java无法从MySQL中的存储引擎读取自动增量值   java使用SwingFXUtils将BuffereImage(awt)转换为Image(JavaFx)   java Camel hdfs2到文件协议文件传输   java什么是GZIP JSFSeam web应用程序页面的最佳方法