From 99ca79287d23b05c7ad77b71e7ab6b449a036cc7 Mon Sep 17 00:00:00 2001 From: r00t Date: Sun, 14 Mar 2021 05:30:21 +0100 Subject: [PATCH] add clang-format to github actions --- .github/workflows/check-formatting.yml | 11 +++++++++++ check-formatting.sh | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 .github/workflows/check-formatting.yml create mode 100755 check-formatting.sh diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml new file mode 100644 index 00000000..bc7c0f1e --- /dev/null +++ b/.github/workflows/check-formatting.yml @@ -0,0 +1,11 @@ +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: install clang-format + run: sudo apt-get install clang-format + - uses: actions/checkout@v2 + - run: ./check-formatting.sh diff --git a/check-formatting.sh b/check-formatting.sh new file mode 100755 index 00000000..2af29cd5 --- /dev/null +++ b/check-formatting.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -xe +SRCDIRS=(include src tests) +clang-format --version +find "${SRCDIRS[@]}" -type f -name '*.h' -o -name '*.cpp' -o -name '*.hpp' | xargs -I{} -P1 clang-format -i -style=file {} +[[ -z "$(git status --porcelain "${SRCDIRS[@]}")" ]] || (git status; git diff; false)