From d45a6d815359c53b7b343d1182b633f0f9b25498 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> Date: Mon, 17 Feb 2025 15:48:15 +0100 Subject: [PATCH] ci: generate the style patch artifact --- .gitlab-ci.yml | 28 ++++++++++++++++++++++++++-- CONTRIBUTING.md | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 077b8580..e2dd1ab2 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 3a86addc..becbb1ec 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 -- GitLab