diff --git a/clang-format.5 b/.clang-format similarity index 100% rename from clang-format.5 rename to .clang-format diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 000000000..da7c6267d --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,30 @@ +name: Code Format Test + +on: + pull_request: + branches: [ "master" ] + + push: + branches: [ "master" ] + +jobs: + pre-commit: + name: Format + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install clang-format-12 + run: sudo apt-get install clang-format-12 + + - name: Install and run pre-commit + run: | + python -m pip install pre-commit + git fetch origin + pre-commit run --show-diff-on-failure --color=always --from-ref origin/master --to-ref HEAD + id: precommit \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..1ce1a4cca --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v14.0.6 + hooks: + - id: clang-format + files: \.(c|cpp|h)$ \ No newline at end of file