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
I have setup Test Coverage parsing regex for python
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With