From fd7f07812790ebdf8989461b12d7d4670794a0cb Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 24 Mar 2023 10:59:08 +0000 Subject: [PATCH] Add workflow for checking clang-format --- .github/workflows/lint.yml | 27 +++++++++++++++++++++++++++ third_party/.clang-format | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/lint.yml create mode 100644 third_party/.clang-format diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4815039 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: lint + +on: [push] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: clang-format + id: clang-format + uses: DoozyX/clang-format-lint-action@c3b2c943e924028b93a707a5b1b017976ab8d50c # v0.15 + with: + exclude: './third_party' + extensions: 'c,h,cpp,hpp' + clangFormatVersion: 15 + style: file + + - name: clang-format instructions + if: ${{ failure() && steps.clang-format.outcome == 'failure' }} + run: | + # Instructions for fixing the formatting errors + echo -e "\n\033[0;31mTo fix the formatting, run:\nclang-format -style=file -i \$(git ls-files \"*.c\" \"*.h\" \"*.cpp\" \"*.hpp\")\033[0m\n" + exit 1 \ No newline at end of file diff --git a/third_party/.clang-format b/third_party/.clang-format new file mode 100644 index 0000000..5ffcf50 --- /dev/null +++ b/third_party/.clang-format @@ -0,0 +1,3 @@ +# Disable clang-format in this folder +DisableFormat: true +SortIncludes: Never \ No newline at end of file