diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 344a91dc..7cbec438 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -82,6 +82,20 @@ stages: - update-crypto-policies --set FIPS - update-crypto-policies --show +############################################################################### +# Review # +############################################################################### +clang-format: + variables: + GIT_DEPTH: 100 + stage: review + image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD + script: + - ./.gitlab-ci/clang-format-check.sh + only: + - merge_requests + # the format is not always matching our intentions + allow_failure: true ############################################################################### # CentOS builds # diff --git a/.gitlab-ci/clang-format-check.sh b/.gitlab-ci/clang-format-check.sh new file mode 100755 index 00000000..1089c969 --- /dev/null +++ b/.gitlab-ci/clang-format-check.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# Based on Github Action +# https://github.com/yshui/git-clang-format-lint + +diff=`git-clang-format --diff --commit $CI_MERGE_REQUEST_DIFF_BASE_SHA` +[ "$diff" = "no modified files to format" ] && exit 0 +[ "$diff" = "clang-format did not modify any files" ] && exit 0 + +printf "You have introduced coding style breakages, suggested changes:\n\n" + +echo "$diff" | colordiff +exit 1