Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hand-written pre-commit hooks with pre-commit Python tool #88866

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Install Python dependencies and general setup
run: |
pip3 install black==23.3.0 pytest==7.1.2 mypy==0.971
pip3 install pytest==7.1.2 mypy==0.971
git config diff.wsErrorHighlight all

- name: Get changed files
Expand All @@ -46,6 +46,9 @@ jobs:
run: |
bash ./misc/scripts/gitignore_check.sh

- name: Style checks via pre-commit
uses: pre-commit/[email protected]

- name: File formatting checks (file_format.sh)
run: |
bash ./misc/scripts/file_format.sh changed.txt
Expand All @@ -54,14 +57,6 @@ jobs:
run: |
bash ./misc/scripts/header_guards.sh changed.txt

- name: Python style checks via black (black_format.sh)
run: |
if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then
bash ./misc/scripts/black_format.sh
else
echo "Skipping Python formatting as no Python files were changed."
fi

- name: Python scripts static analysis (mypy_check.sh)
run: |
if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then
Expand Down Expand Up @@ -92,12 +87,6 @@ jobs:
- name: Documentation checks
run: |
doc/tools/doc_status.py doc/classes modules/*/doc_classes platform/*/doc_classes
doc/tools/make_rst.py --dry-run --color doc/classes modules platform

- name: Style checks via clang-format (clang_format.sh)
run: |
clang-format --version
bash ./misc/scripts/clang_format.sh changed.txt

- name: Style checks via dotnet format (dotnet_format.sh)
run: |
Expand Down
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
- id: clang-format
files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java|glsl)$
types_or: [text]
exclude: |
(?x)^(
tests/python_build.*|
.*thirdparty.*|
.*platform/android/java/lib/src/com.*|
.*-so_wrap.*
)

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.3.0
hooks:
- id: black
files: (\.py$|SConstruct|SCsub)
types_or: [text]
exclude: .*thirdparty.*
args:
- --line-length=120

- repo: local
hooks:
- id: make-rst
name: make-rst
entry: python3 doc/tools/make_rst.py doc/classes modules platform --dry-run --color
pass_filenames: false
language: python
files: ^(doc|modules|platform).*xml$

- id: copyright-headers
name: copyright-headers
language: python
files: \.(c|h|cpp|hpp|cc|cxx|m|mm|inc|java)$
entry: python3 misc/scripts/copyright_headers.py
exclude: |
(?x)^(
tests/python_build.*|
.*thirdparty.*|
.*platform/android/java/lib/src/com.*|
.*-so_wrap.*|
platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView.*|
platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper.*|
platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.*
)
42 changes: 0 additions & 42 deletions misc/hooks/README.md

This file was deleted.

59 changes: 0 additions & 59 deletions misc/hooks/asmessage.applescript

This file was deleted.

48 changes: 0 additions & 48 deletions misc/hooks/canonicalize_filename.sh

This file was deleted.

50 changes: 0 additions & 50 deletions misc/hooks/pre-commit

This file was deleted.

Loading
Loading