Skip to content
Snippets Groups Projects
Commit 8c407bea 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: ...@@ -37,12 +37,11 @@ build:ubuntu_python:
#################################################################################################### ####################################################################################################
# TEST # TEST
#################################################################################################### ####################################################################################################
.setup:test:ubuntu_python: .setup:test:ubuntu_python:
before_script: before_script:
- !reference [.retrieve_deps:apt, script] - !reference [.retrieve_deps:apt, script]
- source venv/bin/activate - source venv/bin/activate
- python -m pip install pytest - python -m pip install pytest pytest-cov
- which python - which python
- python -m pip list - python -m pip list
...@@ -50,55 +49,40 @@ test:ubuntu_python: ...@@ -50,55 +49,40 @@ test:ubuntu_python:
stage: test stage: test
needs: ["build:ubuntu_python"] needs: ["build:ubuntu_python"]
rules: rules:
- when : on_success - when: on_success
- allow_failure: false
tags: tags:
- docker - docker
extends: .setup:test:ubuntu_python extends: .setup:test:ubuntu_python
script: script:
- cd ${CI_PROJECT_NAME} - cd ${CI_PROJECT_NAME}
# Run on discovery all tests located in project/unit_tests/python and discard the stdout # Run tests with coverage, produce JUnit and coverage XML reports
# only to show the errors/warnings and the results of the tests - pytest unit_tests/ -v --junitxml=xmlrunner-results.xml --cov=${CI_PROJECT_NAME} --cov-report=xml:coverage.xml --cov-report=term
# - python -m xmlrunner discover -s unit_tests/ -v -b --output-file xmlrunner-results.xml
- pytest unit_tests/ -v --junitxml=xmlrunner-results.xml
artifacts: artifacts:
reports: reports:
junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml junit: ${CI_PROJECT_NAME}/xmlrunner-results.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml
#################################################################################################### # ####################################################################################################
# COVERAGE # # COVERAGE
#################################################################################################### # ####################################################################################################
.setup:coverage:ubuntu_python: .setup:coverage:ubuntu_python:
before_script: before_script:
- !reference [.retrieve_deps:apt, script] - echo "WARNING: The .setup:coverage:ubuntu_python job is deprecated and will be removed in future versions."
- source venv/bin/activate
- which python
- python -m pip list
- python -m pip install numpy coverage requests pytest
coverage:ubuntu_python: coverage:ubuntu_python:
stage: coverage stage: coverage
needs: ["build:ubuntu_python"] needs: ["build:ubuntu_python"]
extends: rules:
- .rules:static_analysis_coverage - when: always
- .setup:coverage:ubuntu_python
tags: tags:
- docker - docker
script: script:
- cd ${CI_PROJECT_NAME} - echo "WARNING The coverage:ubuntu_python job is deprecated and will be removed in future versions."
# Retrieve the installation path of the module, since it is installed with pip. - echo "Please run tests with coverage in the test:ubuntu_python job instead."
- export MODULE_LOCATION=`python -c "import ${CI_PROJECT_NAME} as _; print(_.__path__[0])"` allow_failure: true
- 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
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