Skip to content

Commit 9baf7fc

Browse files
authored
Use pre-commit to implement GHA basic checks (#9015)
* Add initial pre-commit configuration * pre-commit: enable trailing-whitespace * pre-commit: enable end-of-file-fixer * pre-commit: enable check-executables-have-shebangs * pre-commit: enable check-shebang-scripts-are-executable * pre-commit: enable clang-format * pre-commit: extend clang-format to Objective-C * pre-commit: extend clang-format to JSON * pre-commit: enable ruff-check * pre-commit: enable ruff-format This step was missing the GitHub Actions workflow. * ruff: upgrade v0.15.0 to v0.15.5 * pre-commit: check test/**/CMakeLists.txt for missing sources * pre-commit: enable taplo-format (TOML formatter) * Deploy pre-commit on GitHub Actions
1 parent d9e57d7 commit 9baf7fc

113 files changed

Lines changed: 757 additions & 543 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ Standard: c++17
3838
TabWidth: 8
3939
UseTab: Never
4040
...
41+
---
42+
Language: Json
43+
IndentWidth: 2
44+
ColumnLimit: 0
45+
...

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// Comment out to connect as the root user.
3434
"remoteUser": "ubuntu",
3535
"containerUser": "root"
36-
}
36+
}

.github/workflows/presubmit-clang-tidy.yml renamed to .github/workflows/clang-tidy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- '**.cpp'
99
- 'run-clang-tidy.sh'
1010
- '**.clang-tidy'
11-
- '.github/workflows/presubmit-clang-tidy.yml'
11+
- '.github/workflows/clang-tidy.yml'
1212

1313
concurrency:
1414
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -33,4 +33,4 @@ jobs:
3333
- name: Run clang-tidy
3434
run: ./run-clang-tidy.sh
3535
env:
36-
CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@21
36+
CLANG_TIDY_LLVM_INSTALL_DIR: /opt/homebrew/opt/llvm@21

.github/workflows/pre-commit.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Halide Presubmit Checks
2+
on:
3+
# We don't want 'edited' (that's basically just the description, title, etc.)
4+
# We don't want 'review_requested' (that's redundant to the ones below for our purposes)
5+
pull_request:
6+
types: [ opened, synchronize, reopened ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
pre-commit:
17+
name: Run pre-commit checks
18+
runs-on: ubuntu-slim
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
22+
- uses: astral-sh/setup-uv@v5
23+
- uses: pre-commit/action@v3.0.1

.github/workflows/presubmit.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/testing-make.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
brew install libjpeg-turbo libpng pkgconf protobuf "llvm@${LLVM_VERSION}" "lld@${LLVM_VERSION}"
8282
echo "LLVM_CONFIG=$(brew --prefix "llvm@${LLVM_VERSION}")/bin/llvm-config" | tee -a "$GITHUB_ENV"
8383
fi
84-
84+
8585
uv sync --group ci-base --no-install-project
8686
echo "${GITHUB_WORKSPACE}/.venv/bin" | tee -a "$GITHUB_PATH"
8787
echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}/.venv" | tee -a "$GITHUB_ENV"

.pre-commit-config.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
exclude: ^dependencies/(spirv|vulkan)/
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-case-conflict
9+
- id: check-executables-have-shebangs
10+
- id: check-json
11+
exclude: ^\.devcontainer/
12+
- id: check-merge-conflict
13+
- id: check-shebang-scripts-are-executable
14+
- id: check-symlinks
15+
- id: check-yaml
16+
args: [ --allow-multiple-documents ]
17+
- id: destroyed-symlinks
18+
- id: end-of-file-fixer
19+
exclude: \.patch$
20+
- id: fix-byte-order-marker
21+
- id: mixed-line-ending
22+
- id: no-commit-to-branch
23+
- id: trailing-whitespace
24+
args: [ --markdown-linebreak-ext=md ]
25+
exclude: \.patch$
26+
27+
- repo: https://github.com/rhysd/actionlint
28+
rev: v1.7.11
29+
hooks:
30+
- id: actionlint
31+
32+
- repo: https://github.com/pre-commit/mirrors-clang-format
33+
rev: v21.1.8
34+
hooks:
35+
- id: clang-format
36+
args: [ --sort-includes ]
37+
types_or: [ c, c++, objective-c, json ]
38+
exclude: |
39+
(?x)(
40+
^tutorial/
41+
| ^src/runtime/hexagon_remote/bin/src/
42+
| ^src/runtime/mini_webgpu\.h$
43+
| ^src/runtime/mini_d3d12\.h$
44+
| ^src/runtime/vulkan_context\.h$
45+
| \.fbs\.h$
46+
| ^\.devcontainer/
47+
| \.xcassets/
48+
)
49+
50+
- repo: https://github.com/gitleaks/gitleaks
51+
rev: v8.9.0
52+
hooks:
53+
- id: gitleaks
54+
55+
- repo: https://github.com/astral-sh/ruff-pre-commit
56+
rev: v0.15.5
57+
hooks:
58+
- id: ruff-check
59+
- id: ruff-format
60+
61+
- repo: https://github.com/ComPWA/taplo-pre-commit
62+
rev: v0.9.3
63+
hooks:
64+
- id: taplo-format
65+
66+
- repo: local
67+
hooks:
68+
- id: check-cmake-file-lists
69+
name: check CMake file lists
70+
entry: python tools/check_cmake_file_lists.py
71+
language: system
72+
files: ^test/.*CMakeLists\.txt$
73+
74+
- id: uv-lock
75+
name: check uv.lock is up to date
76+
entry: uv lock --check
77+
language: system
78+
pass_filenames: false
79+
files: ^(pyproject\.toml|uv\.lock)$

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ that end, we have a few ground rules that we ask people to adhere to:
5252
- **Give credit where it's due.** If you use code or ideas from other people,
5353
projects, or publications, say so. Add a comment in the source code at the
5454
point where the idea is used. If adapting code, this requirement is above and
55-
beyond any requirements placed on you by the license of the original code.
55+
beyond any requirements placed on you by the license of the original code.
5656
Additionally, any code generated by an AI tool (such as a large language model)
5757
must be clearly identified as such in the commit message using
5858
"Co-authored-by: The name of the tool". We all like recognition for our work.

LICENSE.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,3 @@ the routine and comment the changes made to the original.
230230
We will gladly answer any questions regarding the software. If a modification is
231231
done, however, it is the responsibility of the person who modified the routine
232232
to provide support.
233-

apps/HelloAndroid/ant.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
# 'key.store' for the location of your keystore and
1515
# 'key.alias' for the name of the key to use.
1616
# The password will be asked during the build when you use the 'release' target.
17-

0 commit comments

Comments
 (0)