diff --git a/README.md b/README.md index d2bb479ba62dae85f770dc6dedfcc621c241bd4e..b75d6e28609f436fb5882e38200288767678fb6b 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,14 @@ 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` is set to `true`. +If a `pyproject.toml` file is detected at the root of your Python project, requirements will automatically be generated from Poetry. +Poetry support can be explicitly disabled by setting `PYTHON_POETRY_DISABLED` 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_. +:warning: If no `poetry.lock` file is found, the template will emit a (non-blocking) warning message, to enforce [Poetry recommendation](https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control): -It uses the following variables: +> 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. + +Poetry support uses the following variables: | Name | description | default value | | ------------------------ | ---------------------------------------------------------- | ----------------- | diff --git a/templates/gitlab-ci-python.yml b/templates/gitlab-ci-python.yml index eaa477c40f12ff26c153b6e8fa6528e699551536..fe5af4a814c20d3968e790eef34c53e47ef3db00 100644 --- a/templates/gitlab-ci-python.yml +++ b/templates/gitlab-ci-python.yml @@ -69,10 +69,6 @@ variables: fi } - - - - function install_ca_certs() { certs=$1 if [[ -z "$certs" ]] @@ -213,9 +209,8 @@ variables: function install_requirements() { target=$1 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 + if [[ ! -f "poetry.lock" ]]; then + log_warn "Poetry detected but \\e[33;1mpoetry.lock\\e[0m file not found: you shall commit it with your project files" fi pip install -U poetry if [[ "$target" == "build" ]]; then @@ -244,7 +239,7 @@ variables: } function _run() { - if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then + if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then if ! command -v poetry > /dev/null then pip install -U poetry @@ -264,15 +259,16 @@ variables: } function _package(){ - if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then + if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then pip install -U poetry poetry build else python setup.py sdist bdist_wheel fi } + function _publish() { - if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then + if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then pip install -U poetry poetry config repositories.user_defined "$TWINE_REPOSITORY_URL" poetry publish --username "$TWINE_USERNAME" --password "$TWINE_PASSWORD" --repository user_defined @@ -286,7 +282,7 @@ variables: } function _release() { - if [[ -f "poetry.lock" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then + if [[ -f "pyproject.toml" ]] && [[ "${PYTHON_POETRY_DISABLED}" != "true" ]]; then pip install -U poetry poetry version "${RELEASE_VERSION_PART}" else @@ -381,12 +377,10 @@ py-lint: if ! _run pylint --ignore=.cache --output-format=text ${PYLINT_ARGS} ${PYLINT_FILES:-$(find -type f -name "*.py")} then # failed: also generate codeclimate report - _run pylint --ignore=.cache --output-format=pylint_gitlab.GitlabCodeClimateReporter ${PYLINT_ARGS} ${PYLINT_FILES:-$(find -type f -name "*.py")} > reports/pylint-codeclimate.json exit 1 else # success: generate empty codeclimate report (required by GitLab :( ) - echo "[]" > reports/pylint-codeclimate.json fi artifacts: