diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 077b8580898af5b52b9c1c244d752b702c1792b4..e2dd1ab2e512cdf4e9f8602bb8c19d00289b1931 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,9 +68,33 @@ Check licenses: interruptible: true Check style: - extends: .common_pre_commit + extends: + - .colorized + - .common_pre_commit + variables: + STYLE_PATCH: style.patch script: - - pre-commit run --show-diff-on-failure --color=always --all-files + - | + # pre-commit run --all-files + pre-commit run --color=always --all-files || { + printf "${RED}The source code does not meet the style requirements:\n + ${CI_PROJECT_URL}/-/blob/${CI_DEFAULT_BRANCH}/CONTRIBUTING.md#coding-style.\n${DEFAULT}" + git diff --ignore-submodules --patch-with-raw > "${STYLE_PATCH}" + test -s "${STYLE_PATCH}" && { + printf "${RED}At least some of the issues can be resolved with the patch (see artifacts):\n + ${CI_JOB_URL}/artifacts/raw/${STYLE_PATCH}.\n${DEFAULT}" + } || { + printf "${RED}The issues cannot be resolved with a patch.\n${DEFAULT}" + rm -rf "${STYLE_PATCH}" + } + exit 1 + } + artifacts: + paths: + - ${STYLE_PATCH} + expose_as: 'Style Patch' + when: on_failure + rules: - if: $CI_PIPELINE_SOURCE == "web" when: manual diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3a86addc11af6c128ba291b982e32ebdeb4dd22e..becbb1ec274f17056fdaeb8b0960ae717a8d35fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Formatting and linting +# Coding style We use [`pre-commit`](https://pre-commit.com) hooks to maintain a set of formatting and linting rules. Although there is a CI job that runs for each merge request and checks whether the contribution does not break the rules, we