Skip to content

Commit 175ba78

Browse files
authored
docs: improve pre-commit docs and discoverability when CI fails (#29970)
1 parent cf083bf commit 175ba78

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

.github/workflows/pre-commit.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ jobs:
4040
brew install norwoodj/tap/helm-docs
4141
- name: pre-commit
4242
run: |
43-
if ! pre-commit run --all-files; then
44-
git status
45-
git diff
43+
set +e # Don't exit immediately on failure
44+
pre-commit run --all-files
45+
if [ $? -ne 0 ] || ! git diff --quiet --exit-code; then
46+
echo "❌ Pre-commit check failed."
47+
echo "🚒 To prevent/address this CI issue, please install/use pre-commit locally."
48+
echo "📖 More details here: https://superset.apache.org/docs/contributing/development#git-hooks"
4649
exit 1
4750
fi

docs/docs/contributing/development.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,50 @@ To install run the following:
9292
pre-commit install
9393
```
9494

95-
A series of checks will now run when you make a git commit.
95+
This will install the hooks in your local repository. From now on, a series of checks will
96+
automatically run whenever you make a Git commit.
97+
98+
#### Running Pre-commit Manually
99+
100+
You can also run the pre-commit checks manually in various ways:
101+
102+
- **Run pre-commit on all files (same as CI):**
103+
104+
To run the pre-commit checks across all files in your repository, use the following command:
105+
106+
```bash
107+
pre-commit run --all-files
108+
```
109+
110+
This is the same set of checks that will run during CI, ensuring your changes meet the project's standards.
111+
112+
- **Run pre-commit on a specific file:**
113+
114+
If you want to check or fix a specific file, you can do so by specifying the file path:
115+
116+
```bash
117+
pre-commit run --files path/to/your/file.py
118+
```
119+
120+
This will only run the checks on the file(s) you specify.
121+
122+
- **Run a specific pre-commit check:**
123+
124+
To run a specific check (hook) across all files or a particular file, use the following command:
125+
126+
```bash
127+
pre-commit run <hook_id> --all-files
128+
```
129+
130+
Or for a specific file:
131+
132+
```bash
133+
pre-commit run <hook_id> --files path/to/your/file.py
134+
```
135+
136+
Replace `<hook_id>` with the ID of the specific hook you want to run. You can find the list
137+
of available hooks in the `.pre-commit-config.yaml` file.
138+
96139

97140
## Alternatives to docker-compose
98141

0 commit comments

Comments
 (0)