Skip to content
Snippets Groups Projects
Commit 9d7bcf39 authored by Cédric OLIVIER's avatar Cédric OLIVIER
Browse files

fix: Manage deprecation for artifacts:report:cobertura

parent b1fe6b70
No related branches found
No related tags found
No related merge requests found
...@@ -36,8 +36,8 @@ The cache policy also makes the necessary to manage pip cache (not to download P ...@@ -36,8 +36,8 @@ The cache policy also makes the necessary to manage pip cache (not to download P
The Python template supports the most popular dependency management & build systems. The Python template supports the most popular dependency management & build systems.
By default it tries to auto-detect the build system used by the project (based on the presence of `pyproject.toml` By default it tries to auto-detect the build system used by the project (based on the presence of `pyproject.toml`
and/or `setup.py` and/or `requirements.txt`), but the build system might also be set explicitly using the and/or `setup.py` and/or `requirements.txt`), but the build system might also be set explicitly using the
`$PYTHON_BUILD_SYSTEM` variable: `$PYTHON_BUILD_SYSTEM` variable:
| Value | Build System (scope) | | Value | Build System (scope) |
...@@ -83,6 +83,42 @@ The Python template features four alternative test jobs: ...@@ -83,6 +83,42 @@ The Python template features four alternative test jobs:
* or `py-nosetest` that performs tests based on [nose](https://nose.readthedocs.io/en/latest/) Python lib, * or `py-nosetest` that performs tests based on [nose](https://nose.readthedocs.io/en/latest/) Python lib,
* or `py-compile` that performs byte code generation to check syntax if not tests are available. * or `py-compile` that performs byte code generation to check syntax if not tests are available.
#### Activate code coverage report artifact
Code coverage report artifact is disabled, due to a [deprecated syntax](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/78132).
To activate code coverage report artifact, you need to update python-test step depending on our gitlab version:
* gitlab < 14.10 :
```yaml
artifacts:
name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
expire_in: 1 day
when: always
reports:
junit:
- $PYTHON_PROJECT_DIR/reports/TEST-*.xml
cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml
paths:
- $PYTHON_PROJECT_DIR/reports/
```
* gitlab >= 14.10
```yaml
artifacts:
name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
expire_in: 1 day
when: always
reports:
junit:
- $PYTHON_PROJECT_DIR/reports/TEST-*.xml
coverage_report:
​coverage_format: cobertura
path: ​$PYTHON_PROJECT_DIR/reports/coverage.xml
paths:
- $PYTHON_PROJECT_DIR/reports/
```
#### `py-unittest` job #### `py-unittest` job
This job is **disabled by default** and performs tests based on [unittest](https://docs.python.org/3/library/unittest.html) Python lib. This job is **disabled by default** and performs tests based on [unittest](https://docs.python.org/3/library/unittest.html) Python lib.
...@@ -101,6 +137,8 @@ This job produces the following artifacts, kept for one day: ...@@ -101,6 +137,8 @@ This job produces the following artifacts, kept for one day:
* JUnit test report (using the [xmlrunner](https://github.com/xmlrunner/unittest-xml-reporting) module) * JUnit test report (using the [xmlrunner](https://github.com/xmlrunner/unittest-xml-reporting) module)
* code coverage report (cobertura xml format). * code coverage report (cobertura xml format).
:warning: code coverage report artifact is disabled, due to a deprecated syntax, see [Activate code coverage report artifact](#activate-code-coverage-report-artifact)
:warning: create a `.coveragerc` file at the root of your Python project to control the coverage settings. :warning: create a `.coveragerc` file at the root of your Python project to control the coverage settings.
Example: Example:
...@@ -110,7 +148,7 @@ Example: ...@@ -110,7 +148,7 @@ Example:
# enables branch coverage # enables branch coverage
branch = True branch = True
# list of directories/packages to cover # list of directories/packages to cover
source = source =
module_1 module_1
module_2 module_2
``` ```
...@@ -131,6 +169,8 @@ This job produces the following artifacts, kept for one day: ...@@ -131,6 +169,8 @@ This job produces the following artifacts, kept for one day:
* JUnit test report (with the [`--junit-xml`](http://doc.pytest.org/en/latest/usage.html#creating-junitxml-format-files) argument) * JUnit test report (with the [`--junit-xml`](http://doc.pytest.org/en/latest/usage.html#creating-junitxml-format-files) argument)
* code coverage report (cobertura xml format). * code coverage report (cobertura xml format).
:warning: code coverage report artifact is disabled, due to a deprecated syntax, see [Activate code coverage report artifact](#activate-code-coverage-report-artifact)
:warning: create a `.coveragerc` file at the root of your Python project to control the coverage settings. :warning: create a `.coveragerc` file at the root of your Python project to control the coverage settings.
Example: Example:
...@@ -140,7 +180,7 @@ Example: ...@@ -140,7 +180,7 @@ Example:
# enables branch coverage # enables branch coverage
branch = True branch = True
# list of directories/packages to cover # list of directories/packages to cover
source = source =
module_1 module_1
module_2 module_2
``` ```
...@@ -164,6 +204,8 @@ This job produces the following artifacts, kept for one day: ...@@ -164,6 +204,8 @@ This job produces the following artifacts, kept for one day:
* JUnit test report (with the [`--with-xunit`](https://nose.readthedocs.io/en/latest/plugins/xunit.html) argument) * JUnit test report (with the [`--with-xunit`](https://nose.readthedocs.io/en/latest/plugins/xunit.html) argument)
* code coverage report (cobertura xml format + html report). * code coverage report (cobertura xml format + html report).
:warning: code coverage report artifact is disabled, due to a deprecated syntax, see [Activate code coverage report artifact](#activate-code-coverage-report-artifact)
:warning: create a `.coveragerc` file at the root of your Python project or use [nose CLI options](https://nose.readthedocs.io/en/latest/plugins/cover.html#options) to control the coverage settings. :warning: create a `.coveragerc` file at the root of your Python project or use [nose CLI options](https://nose.readthedocs.io/en/latest/plugins/cover.html#options) to control the coverage settings.
#### `py-compile` job #### `py-compile` job
...@@ -300,7 +342,7 @@ You should disable the `semantic-release` job (as it's the `py-release` job that ...@@ -300,7 +342,7 @@ You should disable the `semantic-release` job (as it's the `py-release` job that
Finally, the semantic-release integration can be disabled with the `PYTHON_SEMREL_RELEASE_DISABLED` variable. Finally, the semantic-release integration can be disabled with the `PYTHON_SEMREL_RELEASE_DISABLED` variable.
#### ####
#### Git authentication #### Git authentication
......
# ========================================================================================= # =========================================================================================
# Copyright (C) 2021 Orange & contributors # Copyright (C) 2021 Orange & contributors
# #
# This program is free software; you can redistribute it and/or modify it under the terms # This program is free software; you can redistribute it and/or modify it under the terms
# of the GNU Lesser General Public License as published by the Free Software Foundation; # of the GNU Lesser General Public License as published by the Free Software Foundation;
# either version 3 of the License, or (at your option) any later version. # either version 3 of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details. # See the GNU Lesser General Public License for more details.
# #
# You should have received a copy of the GNU Lesser General Public License along with this # You should have received a copy of the GNU Lesser General Public License along with this
# program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth # program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
# Floor, Boston, MA 02110-1301, USA. # Floor, Boston, MA 02110-1301, USA.
# ========================================================================================= # =========================================================================================
# default workflow rules # default workflow rules
...@@ -49,7 +49,7 @@ variables: ...@@ -49,7 +49,7 @@ variables:
PYTHON_COMPILE_ARGS: "*" PYTHON_COMPILE_ARGS: "*"
BANDIT_ARGS: "--recursive ." BANDIT_ARGS: "--recursive ."
# Safety tool # Safety tool
SAFETY_ARGS: "--full-report" SAFETY_ARGS: "--full-report"
...@@ -164,8 +164,8 @@ variables: ...@@ -164,8 +164,8 @@ variables:
_test_op=$(echo "$_fields" | cut -d: -f5) _test_op=$(echo "$_fields" | cut -d: -f5)
case "$_test_op" in case "$_test_op" in
defined) defined)
if [[ -z "$_not" ]] && [[ -z "$_cond_val" ]]; then continue; if [[ -z "$_not" ]] && [[ -z "$_cond_val" ]]; then continue;
elif [[ "$_not" ]] && [[ "$_cond_val" ]]; then continue; elif [[ "$_not" ]] && [[ "$_cond_val" ]]; then continue;
fi fi
;; ;;
equals|startswith|endswith|contains|in|equals_ic|startswith_ic|endswith_ic|contains_ic|in_ic) equals|startswith|endswith|contains|in|equals_ic|startswith_ic|endswith_ic|contains_ic|in_ic)
...@@ -184,28 +184,28 @@ variables: ...@@ -184,28 +184,28 @@ variables:
fi fi
case "$_test_op" in case "$_test_op" in
equals*) equals*)
if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val" ]]; then continue; if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val" ]]; then continue;
elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val" ]]; then continue; elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val" ]]; then continue;
fi fi
;; ;;
startswith*) startswith*)
if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val"* ]]; then continue; if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val"* ]]; then continue;
elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val"* ]]; then continue; elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val"* ]]; then continue;
fi fi
;; ;;
endswith*) endswith*)
if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val" ]]; then continue; if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val" ]]; then continue;
elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val" ]]; then continue; elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val" ]]; then continue;
fi fi
;; ;;
contains*) contains*)
if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val"* ]]; then continue; if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val"* ]]; then continue;
elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val"* ]]; then continue; elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val"* ]]; then continue;
fi fi
;; ;;
in*) in*)
if [[ -z "$_not" ]] && [[ "__${_cmp_val}__" != *"__${_cond_val}__"* ]]; then continue; if [[ -z "$_not" ]] && [[ "__${_cmp_val}__" != *"__${_cond_val}__"* ]]; then continue;
elif [[ "$_not" ]] && [[ "__${_cmp_val}__" == *"__${_cond_val}__"* ]]; then continue; elif [[ "$_not" ]] && [[ "__${_cmp_val}__" == *"__${_cond_val}__"* ]]; then continue;
fi fi
;; ;;
esac esac
...@@ -653,7 +653,6 @@ py-unittest: ...@@ -653,7 +653,6 @@ py-unittest:
reports: reports:
junit: junit:
- $PYTHON_PROJECT_DIR/reports/TEST-*.xml - $PYTHON_PROJECT_DIR/reports/TEST-*.xml
cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml
paths: paths:
- $PYTHON_PROJECT_DIR/reports/ - $PYTHON_PROJECT_DIR/reports/
rules: rules:
...@@ -677,7 +676,6 @@ py-pytest: ...@@ -677,7 +676,6 @@ py-pytest:
reports: reports:
junit: junit:
- $PYTHON_PROJECT_DIR/reports/TEST-*.xml - $PYTHON_PROJECT_DIR/reports/TEST-*.xml
cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml
paths: paths:
- $PYTHON_PROJECT_DIR/reports/ - $PYTHON_PROJECT_DIR/reports/
rules: rules:
...@@ -700,7 +698,6 @@ py-nosetests: ...@@ -700,7 +698,6 @@ py-nosetests:
reports: reports:
junit: junit:
- $PYTHON_PROJECT_DIR/reports/TEST-*.xml - $PYTHON_PROJECT_DIR/reports/TEST-*.xml
cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml
paths: paths:
- $PYTHON_PROJECT_DIR/reports/ - $PYTHON_PROJECT_DIR/reports/
rules: rules:
......
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