diff --git a/README.md b/README.md index 33e46b4cdcbd528674a7a809d8039f660abbd474..2bea443f5a1510c5bb48b6a1925a72b365b1d68a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Default configuration follows [this Python project structure](https://docs.pytho The Python template supports [Poetry](https://python-poetry.org/) as packaging and dependency management tool. If a `pyproject.toml` and `poetry.lock` file is detected at the root of your project structure, requirements will automatically be generated from Poetry. -Poetry support is disabled if `PYTHON_POETRY_DISABLED` has a value. +Poetry support is disabled if `PYTHON_POETRY_DISABLED` is set to `true`. :warning: as stated in [Poetry documentation](https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control), _You should commit the `poetry.lock` file to your project repo so that all people working on the project are locked to the same versions of dependencies_. @@ -53,7 +53,7 @@ It uses the following variables: #### `py-pylint` job This job is **disabled by default** and performs code analysis based on [pylint](http://pylint.pycqa.org/en/latest/) Python lib. -It is activated by setting `$PYLINT_ENABLED`. +It is activated by setting `$PYLINT_ENABLED` to `true`. It is bound to the `build` stage, and uses the following variables: @@ -78,7 +78,7 @@ The Python template features four alternative test jobs: #### `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. -It is activated by setting `$UNITTEST_ENABLED`. +It is activated by setting `$UNITTEST_ENABLED` to `true`. In order to produce JUnit test reports, the tests are executed with the [xmlrunner](https://github.com/xmlrunner/unittest-xml-reporting) module. @@ -111,7 +111,7 @@ source = #### `py-pytest` job This job is **disabled by default** and performs tests based on [pytest](https://docs.pytest.org/en/latest/) Python lib. -It is activated by setting `$PYTEST_ENABLED`. +It is activated by setting `$PYTEST_ENABLED` to `true`. It is bound to the `build` stage, and uses the following variables: @@ -142,7 +142,7 @@ source = #### `py-nosetest` job This job is **disabled by default** and performs tests based on [nose](https://nose.readthedocs.io/en/latest/) Python lib. -It is activated by setting `$NOSETESTS_ENABLED`. +It is activated by setting `$NOSETESTS_ENABLED` to `true`. It is bound to the `build` stage, and uses the following variables: @@ -207,7 +207,7 @@ It is bound to the `test` stage, and uses the following variables: | Name | description | default value | | ---------------- | ---------------------------------------------------------------------- | ----------------- | -| `BANDIT_ENABLED` | Variable to enable Bandit analysis | _none_ (disabled) | +| `BANDIT_ENABLED` | Set to `true` to enable Bandit analysis | _none_ (disabled) | | `BANDIT_ARGS` | Additional [Bandit CLI options](https://github.com/PyCQA/bandit#usage) | `--recursive .` | This job outputs a **textual report** in the console, and in case of failure also exports a JSON report in the `reports/` @@ -221,7 +221,7 @@ It is bound to the `test` stage, and uses the following variables: | Name | description | default value | | ---------------- | ----------------------------------------------------------------------- | ----------------- | -| `SAFETY_ENABLED` | Variable to enable Safety job | _none_ (disabled) | +| `SAFETY_ENABLED` | Set to `true` to enable Safety job | _none_ (disabled) | | `SAFETY_ARGS` | Additional [Safety CLI options](https://github.com/pyupio/safety#usage) | `--full-report` | This job outputs a **textual report** in the console, and in case of failure also exports a JSON report in the `reports/` @@ -275,7 +275,7 @@ It is bound to the `publish` stage, applies only on tags and uses the following | Name | description | default value | | ------------------------ | -------------------------------------------------------------------------------------- | --------------------------------- | -| `DOCS_ENABLED` | Variable to enable pages job | _none_ (disabled) | +| `DOCS_ENABLED` | Set to `true` to enable pages job | _none_ (disabled) | | `DOCS_REQUIREMENTS_FILE` | Python dependencies for documentation generation _(relative to `$PYTHON_PROJECT_DIR`)_ | `docs-requirements.txt` | | `DOCS_DIRECTORY` | Directory containing docs source | `docs` | | `DOCS_BUILD_DIR` | Output build directory for documentation | `public` | diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml index 8830cd8b3be1307fc2646c6c69deecda1b196bdc..006b96106568e3f3ea06d0e5c3dbb3634fe9e344 100644 --- a/templates/gitlab-ci-python.yml +++ b/templates/gitlab-ci-python.yml @@ -70,7 +70,7 @@ variables: } function install_test_requirements() { - if [[ -f "pyproject.toml" ]] && [[ -z "${PYTHON_POETRY_DISABLED}" ]]; then + if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then if [[ ! -f "poetry.lock" ]]; then log_error "Poetry detected but \\e[33;1mpoetry.lock\\e[0m file not found: you shall commit it with your project files" exit 1 @@ -305,7 +305,7 @@ variables: fi } - if [[ -z "$TEMPLATE_CHECK_UPDATE_DISABLED" ]]; then check_for_update python "1.3.0"; fi + if [[ "$TEMPLATE_CHECK_UPDATE_DISABLED" != "true" ]]; then check_for_update python "1.3.0"; fi unscope_variables # ENDSCRIPT @@ -373,11 +373,11 @@ py-lint: - if: $CI_MERGE_REQUEST_ID when: never # on production branch(es): if $PYLINT_ENABLED is set - - if: '$PYLINT_ENABLED && $CI_COMMIT_REF_NAME =~ $PROD_REF' + - if: '$PYLINT_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $PROD_REF' # on integration branch(es): if $PYLINT_ENABLED is set - - if: '$PYLINT_ENABLED && $CI_COMMIT_REF_NAME =~ $INTEG_REF' + - if: '$PYLINT_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $INTEG_REF' # on non-production, non-integration branches, with $PYLINT_ENABLED set: auto & non-blocking - - if: '$PYLINT_ENABLED' + - if: '$PYLINT_ENABLED == "true"' allow_failure: true py-compile: @@ -391,7 +391,7 @@ py-compile: - if: $CI_MERGE_REQUEST_ID when: never # on any branch: only when none of supported unit test framework is enabled - - if: '$UNITTEST_ENABLED == null && $PYTEST_ENABLED == null && $NOSETESTS_ENABLED == null' + - if: '$UNITTEST_ENABLED != "true" && $PYTEST_ENABLED != "true" && $NOSETESTS_ENABLED != "true"' ############################################################################################### # test stage # @@ -427,7 +427,7 @@ py-unittest: - if: $CI_MERGE_REQUEST_ID when: never # on any branch: when $UNITTEST_ENABLED is set - - if: $UNITTEST_ENABLED + - if: '$UNITTEST_ENABLED == "true"' py-pytest: extends: .python-base @@ -455,7 +455,7 @@ py-pytest: - if: $CI_MERGE_REQUEST_ID when: never # on any branch: when $PYTEST_ENABLED is set - - if: $PYTEST_ENABLED + - if: '$PYTEST_ENABLED == "true"' py-nosetests: extends: .python-base @@ -482,7 +482,7 @@ py-nosetests: - if: $CI_MERGE_REQUEST_ID when: never # on any branch: when $NOSETESTS_ENABLED is set - - if: $NOSETESTS_ENABLED + - if: '$NOSETESTS_ENABLED == "true"' # Bandit (SAST) py-bandit: @@ -512,11 +512,11 @@ py-bandit: - if: $CI_MERGE_REQUEST_ID when: never # on production branch(es): if $BANDIT_ENABLED is set - - if: '$BANDIT_ENABLED && $CI_COMMIT_REF_NAME =~ $PROD_REF' + - if: '$BANDIT_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $PROD_REF' # on integration branch(es): if $BANDIT_ENABLED is set - - if: '$BANDIT_ENABLED && $CI_COMMIT_REF_NAME =~ $INTEG_REF' + - if: '$BANDIT_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $INTEG_REF' # on non-production, non-integration branches, with $BANDIT_ENABLED set: manual & non-blocking - - if: '$BANDIT_ENABLED' + - if: '$BANDIT_ENABLED == "true"' when: manual allow_failure: true @@ -549,11 +549,11 @@ py-safety: - if: $CI_MERGE_REQUEST_ID when: never # on production branch(es): if $SAFETY_ENABLED is set - - if: '$SAFETY_ENABLED && $CI_COMMIT_REF_NAME =~ $PROD_REF' + - if: '$SAFETY_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $PROD_REF' # on integration branch(es): if $SAFETY_ENABLED is set - - if: '$SAFETY_ENABLED && $CI_COMMIT_REF_NAME =~ $INTEG_REF' + - if: '$SAFETY_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $INTEG_REF' # on non-production, non-integration branches, with $SAFETY_ENABLED set: manual & non-blocking - - if: '$SAFETY_ENABLED' + - if: '$SAFETY_ENABLED == "true"' when: manual allow_failure: true @@ -593,7 +593,7 @@ py-docs: - $DOCS_BUILD_DIR rules: # on tags with $DOCS_ENABLED set - - if: '$DOCS_ENABLED && $CI_COMMIT_TAG' + - if: '$DOCS_ENABLED == "true" && $CI_COMMIT_TAG' # (manual from master branch): triggers a release (tag creation) py-release: