Skip to content
Snippets Groups Projects
Commit d13a855f authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Fuse test and coverage for python.

parent 4beeae32
No related branches found
No related tags found
No related merge requests found
......@@ -37,12 +37,11 @@ build:ubuntu_python:
####################################################################################################
# TEST
####################################################################################################
.setup:test:ubuntu_python:
before_script:
- !reference [.retrieve_deps:apt, script]
- source venv/bin/activate
- python -m pip install pytest
- python -m pip install pytest pytest-cov
- which python
- python -m pip list
......@@ -50,55 +49,40 @@ test:ubuntu_python:
stage: test
needs: ["build:ubuntu_python"]
rules:
- when : on_success
- allow_failure: false
- when: on_success
tags:
- docker
extends: .setup:test:ubuntu_python
script:
- cd ${CI_PROJECT_NAME}
# Run on discovery all tests located in project/unit_tests/python and discard the stdout
# only to show the errors/warnings and the results of the tests
# - python -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml
- pytest unit_tests/ -v --junitxml=xmlrunner-results.xml
# Run tests with coverage, produce JUnit and coverage XML reports
- pytest unit_tests/ -v --junitxml=xmlrunner-results.xml --cov=${CI_PROJECT_NAME} --cov-report=xml:coverage.xml --cov-report=term
artifacts:
reports:
junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
####################################################################################################
# COVERAGE
####################################################################################################
# ####################################################################################################
# # COVERAGE
# ####################################################################################################
.setup:coverage:ubuntu_python:
before_script:
- !reference [.retrieve_deps:apt, script]
- source venv/bin/activate
- which python
- python -m pip list
- python -m pip install numpy coverage requests pytest
- echo "WARNING: The .setup:coverage:ubuntu_python job is deprecated and will be removed in future versions."
coverage:ubuntu_python:
stage: coverage
needs: ["build:ubuntu_python"]
extends:
- .rules:static_analysis_coverage
- .setup:coverage:ubuntu_python
rules:
- when: always
tags:
- docker
script:
- cd ${CI_PROJECT_NAME}
# Retrieve the installation path of the module, since it is installed with pip.
- export MODULE_LOCATION=`python -c "import ${CI_PROJECT_NAME} as _; print(_.__path__[0])"`
- python -m coverage run --source=$MODULE_LOCATION -m pytest unit_tests/ -v
- python -m coverage report
- python -m coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
expire_in: 3 days
reports:
coverage_report:
coverage_format: cobertura
path: ${CI_PROJECT_NAME}/coverage.xml
- echo "WARNING: The coverage:ubuntu_python job is deprecated and will be removed in future versions."
- echo "Please run tests with coverage in the test:ubuntu_python job instead."
allow_failure: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment