diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index eba56fe2e..a40b91340 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -26,6 +26,8 @@ jobs: token: ${{ secrets.GH_TOKEN }} - name: Format with clang-format (Cpp) run: sudo apt install moreutils && .github/workflows/scripts/format_cpp.sh + - name: Format with cmake-format (Cmake) + run: pip3 install cmakelang && .github/workflows/scripts/format_cmake.sh - name: Format with black (Python) run: | cd compiler diff --git a/.github/workflows/scripts/format_cmake.sh b/.github/workflows/scripts/format_cmake.sh new file mode 100755 index 000000000..14c992205 --- /dev/null +++ b/.github/workflows/scripts/format_cmake.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e -o pipefail + +cmake-format -i compiler/CMakeLists.txt -c compiler/.cmake-format-config.py + +find ./compiler/{include,lib,src,tests} -type f -name "CMakeLists.txt" | xargs -I % sh -c 'cmake-format -i % -c compiler/.cmake-format-config.py' + +# show changes if any +git --no-pager diff +# fail if there is a diff, success otherwise +git diff | ifne exit 1 diff --git a/compiler/.cmake-format-config.py b/compiler/.cmake-format-config.py new file mode 100644 index 000000000..23d1ae80c --- /dev/null +++ b/compiler/.cmake-format-config.py @@ -0,0 +1,11 @@ +# ----------------------------- +# Options effecting formatting. +# ----------------------------- +with section("format"): + + # How wide to allow formatted cmake files + line_width = 120 + + # How many spaces to tab for indent + tab_size = 2 +