Skip to content

Commit ac86eac

Browse files
authored
Add pre-commit in CI and move some check over (#3489)
As promised in #3484, I am adding pre-commit to CI. To better demonstrate what we can gain from this, I also move some formatting checks into pre-commit. This way, users can easily run exactly the same formatters as used in CI.
1 parent f04b2a6 commit ac86eac

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.github/workflows/formatting.yaml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ jobs:
2222
rm ./buildifier
2323
env:
2424
BUILDIFIER_VERSION: 8.2.0
25-
- uses: DoozyX/[email protected]
26-
with:
27-
source: '.'
28-
extensions: 'h,c,cc,proto,java,m'
29-
clangFormatVersion: 14
3025
- uses: actionsx/prettier@v2
3126
with:
3227
args: --config "${{ github.workspace }}/.prettierrc.toml" --write "**/*.{js,mjs,cjs,jsx,ts,tsx}"
@@ -43,10 +38,7 @@ jobs:
4338
python-version: 3.11
4439
- name: Install dependencies
4540
run: |
46-
pip install 'black==24.10.0' 'isort==5.13.2'
47-
- name: Run black
48-
run: |
49-
python -m black --check --diff ./
50-
- name: Run isort
41+
pip install pre-commit
42+
- name: Run pre-commit
5143
run: |
52-
python -m isort --profile=black --check-only ./
44+
pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,20 @@ repos:
2121
tools|
2222
util
2323
)
24+
- repo: https://github.com/psf/black
25+
rev: 24.10.0
26+
hooks:
27+
- id: black
28+
- repo: https://github.com/PyCQA/isort
29+
rev: 5.13.2
30+
hooks:
31+
- id: isort
32+
args: [--profile, black]
33+
- repo: https://github.com/pre-commit/mirrors-clang-format
34+
# See supported types: https://github.com/pre-commit/mirrors-clang-format/blob/v14.0.6/.pre-commit-hooks.yaml#L6
35+
rev: v14.0.6
36+
hooks:
37+
- id: clang-format
38+
exclude_types:
39+
- json
40+
- javascript

0 commit comments

Comments
 (0)