From c1f0d72d152cada054b45474f9bd077664a36337 Mon Sep 17 00:00:00 2001 From: AnyaCoder Date: Thu, 10 Oct 2024 13:35:01 +0800 Subject: [PATCH] Add pre-commit & clang-format --- .github/workflows/pre-commit.yml | 16 ++++++++++++++++ .pre-commit-config.yaml | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..39a2b09 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,16 @@ +name: pre-commit + +on: + pull_request: + push: + branches: + - main + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pre-commit/action@v4.5.0 + with: + extra_args: --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..854ef46 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +ci: + autoupdate_schedule: monthly + +repos: + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v14.0.6 # 使用你需要的版本 + hooks: + - id: clang-format + args: ["--style=file", "-i"] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: end-of-file-fixer + - id: check-yaml + - id: check-json + - id: mixed-line-ending + args: ['--fix=lf'] + - id: check-added-large-files + args: ['--maxkb=5000']