Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab Coverage badge not working

I am deploying Django application using Gitlab CI/CD and pytest for testing of code and pytest-cov for generating coverage report

My .gitlab-ci.yml

stages:
  - test
  - deploy

image: python:3.6

test:
  stage: test
  script:
    - pip install pipenv
    - pipenv install
    - pipenv run py.test src/
  artifacts:
    paths:
      - htmlcov/

pages:
  stage: deploy
  dependencies:
    - test
  script:
    - mv htmlcov/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
  only:
    - master

staging:
  stage: deploy
  script:
    - apt-get update -qy
    - apt-get install -y ruby-dev
    - gem install dpl
    - dpl --provider=heroku --app=app-staging --api-key=$HEROKU_PRODUCTION_API_KEY
  only:
    - master

production:
  stage: deploy
  script:
    - apt-get update -qy
    - apt-get install -y ruby-dev
    - gem install dpl
    - dpl --provider=heroku --app=app-production --api-key=$HEROKU_PRODUCTION_API_KEY
  when: manual
  only:
    - master

Since repository is under a group namespace, the url to the coverage report is

https://<group>.gitlab.io/<repository>/

For coverage report,

[![coverage report](https://gitlab.com/<group>/<repository>/badges/master/coverage.svg?job=coverage)](https://<group>.gitlab.io/<repository>/)

But this is displaying Unknown

enter image description here

I have setup Test Coverage parsing regex for python

enter image description here

like image 223
Anuj TBE Avatar asked Jul 08 '18 00:07

Anuj TBE


1 Answers

I know this is an old question, but this may help others see this question in the future. Except setting the Test Coverage parsing regex in the Settings, CI/CD page, you need to make sure the test coverage percent is printed somewhere in the CI's console log. The printed line should match the given regex. So, Gitlab can parse and save it as the code coverage percent.

I've answered with more detail the same question: Gitlab coverage badge always unknow

like image 177
Reza Ebrahimpour Avatar answered Oct 13 '22 16:10

Reza Ebrahimpour