diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 73568418..08a4abb9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,7 +93,17 @@ test: - apt-get -y build-dep . - apt-get -y install clang-tidy - ninja -C _build test - - tools/style-check _build + - tools/style-check_build _build + except: + variables: + - $PKG_ONLY == "1" + +test_style: + stage: test + needs: [] + script: + - apt-get -y build-dep . + - tools/style-check_source except: variables: - $PKG_ONLY == "1" diff --git a/debian/control b/debian/control index b91f5d99..149dc343 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,7 @@ Build-Depends: libwayland-dev (>= 1.16), lsb-release, python3, + python3-ruamel.yaml, rustc, wayland-protocols (>= 1.14), Standards-Version: 4.1.3 diff --git a/doc/hacking.md b/doc/hacking.md index 4ce40ff5..6d3feca2 100644 --- a/doc/hacking.md +++ b/doc/hacking.md @@ -120,6 +120,16 @@ User interface modules should: ### Style +Note that some portions, like the .gitlab-ci.yml file have accummulated enough style/whitespace conflicts that an enforced style checker is now applied. + +To fix your contributions before submitting a change, use: + +``` +./tools/style-check_source --apply +``` + +* * * + Code submitted should roughly match the style of surrounding code. Things that will *not* be accepted are ones that often lead to errors: - skipping brackets `{}` after every `if()`, `else`, and similar ([SCI CERT C: EXP19-C](https://wiki.sei.cmu.edu/confluence/display/c/EXP19-C.+Use+braces+for+the+body+of+an+if%2C+for%2C+or+while+statement)) diff --git a/tools/style-check b/tools/style-check_build similarity index 75% rename from tools/style-check rename to tools/style-check_build index 24c6dc81..29ed4167 100755 --- a/tools/style-check +++ b/tools/style-check_build @@ -1,13 +1,15 @@ #!/bin/sh +# Enforces style check for the C parts of the project. + if [ -z "$1" ]; then - echo "Please pass directory to check." + echo "Please pass build directory to check." exit 1 fi cd "$1" + clang-tidy --checks=-clang-diagnostic-missing-braces,readability-braces-around-statements, \ --warnings-as-errors=readability-braces-around-statements \ -extra-arg=-Wno-unknown-warning-option \ ../src/*.c ../eek/*.c ../eekboard/*.c - diff --git a/tools/style-check_source b/tools/style-check_source new file mode 100755 index 00000000..7a0f76ab --- /dev/null +++ b/tools/style-check_source @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +# Enforces style check for the project. +THIS=$(realpath $0) +TOOLS=$(dirname $THIS) +cd $TOOLS/.. + +# The CI file seems to be touched regularly, and causing problems often, +# unlike layout files. +./tools/yamlfmt ./.gitlab-ci.yml $1