From 44da1674920ca5a9abc84295081d7e781b176ed9 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 29 Jul 2024 01:23:09 +0800 Subject: [PATCH] CI for Code style --- .github/workflows/code_style.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/code_style.yml diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml new file mode 100644 index 00000000..ef10adbe --- /dev/null +++ b/.github/workflows/code_style.yml @@ -0,0 +1,30 @@ +name: Codestyle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + lint: + name: "clang-format-always-success" + runs-on: ubuntu-latest + steps: + - name: Checkout Playerbot Module + uses: actions/checkout@v4 + - name: Install clang-format + run: sudo apt-get install clang-format -y + + - name: Run clang-format + run: | + # Find all C/C++ source files + FILES=$(find . -name "*.h" -o -name "*.cpp" -o -name "*.c" -o -name "*.hpp") + + # Run clang-format in dry-run mode to check for formatting issues + clang-format -i $FILES + + # Check if there are any formatting changes + git diff --exit-code + shell: bash + continue-on-error: true \ No newline at end of file