GitLab 测试覆盖率可视化不适用于简单的示例

mvf*_*fwd 7 code-coverage cobertura gitlab gitlab-ci

我创建了一个非常简单的示例:https ://gitlab.com/mvfwd/gitlab-coverage 。

不幸的是 gitlab 不显示 Cobertura 覆盖可视化。

这是我的.gitlab-ci.yml

image: python:3

stages:
- test

coverage:
  stage: test
  script:
  - pip install coverage
  - coverage run ./main.py
  - coverage report -m
  - coverage xml
  artifacts:
    paths:
    - ./coverage.xml
    reports:
      cobertura: ./coverage.xml
  only:
  - master
Run Code Online (Sandbox Code Playgroud)

在日志中我可以看到覆盖率报告已上传(链接):

$ coverage run ./main.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK
$ coverage report -m
Name      Stmts   Miss  Cover   Missing
---------------------------------------
main.py      26     12    54%   9-14, 20-25
---------------------------------------
TOTAL        26     12    54%
$ coverage xml
Uploading artifacts for successful job
00:03
Uploading artifacts...
./coverage.xml: found 1 matching files and directories 
Uploading artifacts as "archive" to coordinator... ok  id=1450561054 responseStatus=201 Created token=eZqc9KYb
Uploading artifacts...
./coverage.xml: found 1 matching files and directories 
Uploading artifacts as "cobertura" to coordinator... ok  id=1450561054 responseStatus=201 Created token=eZqc9KYb
Cleaning up file based variables
00:00
Job succeeded
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

mvf*_*fwd 4

我已提交问题并找到解决方案。以下是回顾:

  • 我对该功能的理解错误,它仅适用于 MR 更改,不适用于常规提交或文件资源管理器
  • master我错过了最近从to重命名main,文档示例未更新,我将其复制到我的.gitlab-ci.yml,这阻止了提交时自动启动管道