diff --git a/README.md b/README.md index 28f4671ef0137631701f4f79fceec73c0b920625..5b0bc208ea46c787e7abcacee11653ee53c2b02b 100644 --- a/README.md +++ b/README.md @@ -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. -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 +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 `$PYTHON_BUILD_SYSTEM` variable: | Value | Build System (scope) | @@ -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-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 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: * JUnit test report (using the [xmlrunner](https://github.com/xmlrunner/unittest-xml-reporting) module) * 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. Example: @@ -110,7 +148,7 @@ Example: # enables branch coverage branch = True # list of directories/packages to cover -source = +source = module_1 module_2 ``` @@ -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) * 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. Example: @@ -140,7 +180,7 @@ Example: # enables branch coverage branch = True # list of directories/packages to cover -source = +source = module_1 module_2 ``` @@ -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) * 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. #### `py-compile` job @@ -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. -#### +#### #### Git authentication diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml index ba40753cc14ec8486201d761d6060fcda4fd52f1..390603469fa7b45a790436305986125ff160afdf 100644 --- a/templates/gitlab-ci-python.yml +++ b/templates/gitlab-ci-python.yml @@ -1,16 +1,16 @@ # ========================================================================================= # Copyright (C) 2021 Orange & contributors # -# 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; +# 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; # 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; # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # 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 -# program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth +# 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 # Floor, Boston, MA 02110-1301, USA. # ========================================================================================= # default workflow rules @@ -49,7 +49,7 @@ variables: PYTHON_COMPILE_ARGS: "*" BANDIT_ARGS: "--recursive ." - + # Safety tool SAFETY_ARGS: "--full-report" @@ -164,8 +164,8 @@ variables: _test_op=$(echo "$_fields" | cut -d: -f5) case "$_test_op" in defined) - if [[ -z "$_not" ]] && [[ -z "$_cond_val" ]]; then continue; - elif [[ "$_not" ]] && [[ "$_cond_val" ]]; then continue; + if [[ -z "$_not" ]] && [[ -z "$_cond_val" ]]; then continue; + elif [[ "$_not" ]] && [[ "$_cond_val" ]]; then continue; fi ;; equals|startswith|endswith|contains|in|equals_ic|startswith_ic|endswith_ic|contains_ic|in_ic) @@ -184,28 +184,28 @@ variables: fi case "$_test_op" in equals*) - if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val" ]]; then continue; - elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val" ]]; then continue; + if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val" ]]; then continue; + elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val" ]]; then continue; fi ;; startswith*) - if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val"* ]]; then continue; - elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val"* ]]; then continue; + if [[ -z "$_not" ]] && [[ "$_cond_val" != "$_cmp_val"* ]]; then continue; + elif [[ "$_not" ]] && [[ "$_cond_val" == "$_cmp_val"* ]]; then continue; fi ;; endswith*) - if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val" ]]; then continue; - elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val" ]]; then continue; + if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val" ]]; then continue; + elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val" ]]; then continue; fi ;; contains*) - if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val"* ]]; then continue; - elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val"* ]]; then continue; + if [[ -z "$_not" ]] && [[ "$_cond_val" != *"$_cmp_val"* ]]; then continue; + elif [[ "$_not" ]] && [[ "$_cond_val" == *"$_cmp_val"* ]]; then continue; fi ;; in*) - if [[ -z "$_not" ]] && [[ "__${_cmp_val}__" != *"__${_cond_val}__"* ]]; then continue; - elif [[ "$_not" ]] && [[ "__${_cmp_val}__" == *"__${_cond_val}__"* ]]; then continue; + if [[ -z "$_not" ]] && [[ "__${_cmp_val}__" != *"__${_cond_val}__"* ]]; then continue; + elif [[ "$_not" ]] && [[ "__${_cmp_val}__" == *"__${_cond_val}__"* ]]; then continue; fi ;; esac @@ -653,7 +653,6 @@ py-unittest: reports: junit: - $PYTHON_PROJECT_DIR/reports/TEST-*.xml - cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml paths: - $PYTHON_PROJECT_DIR/reports/ rules: @@ -677,7 +676,6 @@ py-pytest: reports: junit: - $PYTHON_PROJECT_DIR/reports/TEST-*.xml - cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml paths: - $PYTHON_PROJECT_DIR/reports/ rules: @@ -700,7 +698,6 @@ py-nosetests: reports: junit: - $PYTHON_PROJECT_DIR/reports/TEST-*.xml - cobertura: $PYTHON_PROJECT_DIR/reports/coverage.xml paths: - $PYTHON_PROJECT_DIR/reports/ rules: