From 90e2cc7eff35424fd45e1edf8a155c5ed338d45f Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Tue, 25 Jun 2019 08:49:34 +0200 Subject: [PATCH] CI: check coding style of C code (!465) --- .gitlab-ci.yml | 9 +++++++++ .gitlab-ci/static_clang-format.sh | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 .gitlab-ci/static_clang-format.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e712bca6..23103de1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,6 +42,15 @@ py-sh-static: script: - .gitlab-ci/static_code_analysis.sh +# coding style check +clang-format-static: + stage: first + <<: *only-default + before_script: + - apk -q add clang git + script: + - .gitlab-ci/static_clang-format.sh + # aports checks (generic) aports-static: stage: first diff --git a/.gitlab-ci/static_clang-format.sh b/.gitlab-ci/static_clang-format.sh new file mode 100755 index 000000000..2c0017e37 --- /dev/null +++ b/.gitlab-ci/static_clang-format.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +clang-format -i $(find . -name "*.c") + +git diff > differences.patch + +if [ -s differences.patch ]; then + echo "C-Code formatting check failed!" + echo "Please make sure, the code is formatted properly!" + echo "Run:" + echo ' clang-format -i $(find . -name "*.c")' + echo + cat differences.patch + echo + rm differences.patch + exit 1 +else + echo "C-Code formatting check is sucessful!" + exit 0 +fi