From 57ca8daa32345eeedff236eabc9ec1732ee74268 Mon Sep 17 00:00:00 2001 From: 6arelyFuture Date: Wed, 5 Feb 2025 16:22:40 +0100 Subject: [PATCH] build: test format --- .gitea/workflows/check-formatting.yml | 28 +++++++++++++++++++++++++++ scripts/check-format.sh | 8 ++++++++ 2 files changed, 36 insertions(+) create mode 100644 .gitea/workflows/check-formatting.yml create mode 100755 scripts/check-format.sh diff --git a/.gitea/workflows/check-formatting.yml b/.gitea/workflows/check-formatting.yml new file mode 100644 index 0000000..e8c880e --- /dev/null +++ b/.gitea/workflows/check-formatting.yml @@ -0,0 +1,28 @@ +name: check-formatting + +on: + push: + branches: + - "*" + pull_request: + branches: + - "*" + types: [opened, synchronize, reopened] + +jobs: + check-formatting: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@main + + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v2.0.5 + with: + version: "11.0" + + - name: Test formatting for all files + working-directory: ${{ github.workspace }} + run: | + export CLANG_FORMAT_BIN="${LLVM_PATH}/bin/clang-format" + ./scripts/check-format.sh diff --git a/scripts/check-format.sh b/scripts/check-format.sh new file mode 100755 index 0000000..349d7b3 --- /dev/null +++ b/scripts/check-format.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Go to repository root +cd "$(dirname "$0")/.." || exit 2 + +CLANG_FORMAT_BIN="${CLANG_FORMAT_BIN:-clang-format}" + +find ./src -iname '*.hpp' -o -iname '*.cpp' | xargs $CLANG_FORMAT_BIN -Werror -ferror-limit=1 --dry-run