3

I am following the following tutorial to create code coverage report: Publish code coverage report with GitLab Pages

My .gitlab-ci.yml file looks same as in the tutorial, except that I am doing it in python

image: ubuntu:18.04

variables:
    CODECOV_TOKEN: $CODECOV_TOKEN

stages:
    - coverage
    - deploy

coverage:
    stage: coverage
    before_script:
        - apt-get -y update
        - apt-get -y install curl python3-pip python3.7 zip
        - python3.7 -m pip install --upgrade pip
        - python3.7 -V
        - pip3.7 install -r requirements.txt

    script:
        - coverage run -m pytest
        - coverage report -m
        - coverage html
    artifacts:
        paths:
            - htmlcov/

pages:
    stage: deploy
    dependencies:
        - coverage
    script:
        - mv htmlcov/ public/
    artifacts:
        paths:
            - public/

When the .yml file is run, it creates an artifact named public enter image description here This folder contains index.html whose contents are

enter image description here

Now, I want to have 52% as a coverage badge in the repo. From the tutorial above, I would like to know which link should I use so that I can get the badge in the repo. In the tutorial, under Using the code coverage report badge section, they have a markdown source

[![Coverage report](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/coverage.svg?job=coverage)](http://gitlab-org.gitlab.io/gitlab-ce/coverage-ruby)

I am a bit confused as to what these links are and thus would like to know what would this be for my project?

1
  • 1
    Coverage.py doesn't make badges. I'm don't understand the gitlab URLs you are showing, or how those get the coverage total. Commented May 26, 2020 at 21:52

2 Answers 2

2

In your project, go to Settings > CI/CD and expand the General pipelines section. You will find the necessary codes to add pipeline and coverage badges to your project. In this section, you can also specify the branch name so badges will show the status of that branch.

In case you stuck with the coverage: unknown badge, you may read my solution for the problem using this link: Gitlab coverage badge is always unknown

0

Here in your

->> settings  
->> ci_cd  
->> General pipelines  
->> Test coverage parsing  

it will scan you gitlab-ci logs to catch regex.

I guess!
However, I think it's the answer.

Not the answer you're looking for? Browse other questions tagged or ask your own question.