diff --git a/.gitlab/ci/ubuntu_python.gitlab-ci.yml b/.gitlab/ci/ubuntu_python.gitlab-ci.yml index c07000b9e6d4aecbacf4fb5026e4134a31cba770..1e43a8a6a12f7a8c69fc995b1a18cbad62e76ddd 100644 --- a/.gitlab/ci/ubuntu_python.gitlab-ci.yml +++ b/.gitlab/ci/ubuntu_python.gitlab-ci.yml @@ -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