From 3cd3b319d499dc6b8596df5604684987bf394b37 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 30 Oct 2020 11:51:13 +0100 Subject: [PATCH] Add a github action and config file for running CMake-format (#6849) * Add a github action and config file for running CMake-format --- .github/workflows/cmake-format.yml | 28 ++++++++++++++++++++++++++++ cmake/cmake-format.py | 20 ++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/cmake-format.yml create mode 100644 cmake/cmake-format.py diff --git a/.github/workflows/cmake-format.yml b/.github/workflows/cmake-format.yml new file mode 100644 index 0000000000..a75ffec63d --- /dev/null +++ b/.github/workflows/cmake-format.yml @@ -0,0 +1,28 @@ +name: cmake-format + +on: [push] + +jobs: + cmake-format-job: + runs-on: ubuntu-latest + steps: + - name: Install cmakelang for cmake-format + run: | + python3 -m pip install --user cmakelang + - uses: actions/checkout@v2 + - name: Check format - ApplicationCode + run: | + cd ApplicationCode + find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i + git diff + - name: Check format - AppFwk + run: | + cd Fwk/AppFwk + find -name CMake*.txt | xargs ~/.local/bin/cmake-format -c ${{ github.workspace }}/cmake/cmake-format.py -i + git diff + - uses: peter-evans/create-pull-request@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: 'Fixes by cmake-format' + title: 'Fixes by cmake-format' + branch: cmake-format-patches diff --git a/cmake/cmake-format.py b/cmake/cmake-format.py new file mode 100644 index 0000000000..2d18340701 --- /dev/null +++ b/cmake/cmake-format.py @@ -0,0 +1,20 @@ +# ----------------------------- +# Options effecting formatting. +# See: https://github.com/cheshirekow/cmake_format +# ----------------------------- +with section("format"): + # How wide to allow formatted cmake files + line_width = 80 + + # How many spaces to tab for indent + tab_size = 2 + + # If true, separate flow control names from their parentheses with a space + separate_ctrl_name_with_space = False + + # If true, separate function names from parentheses with a space + separate_fn_name_with_space = False + + # If a statement is wrapped to more than one line, than dangle the closing + # parenthesis on its own line. + dangle_parens = False