Skip to content

Commit b9c5bee

Browse files
authored
docs: use v1.8.0 and recommend additional_dependencies (#307)
* docs: use v1.8.0 and recommend additional_dependencies Point the README and examples at v1.8.0. Recommend pinning the clang tool wheel in additional_dependencies, so pre-commit installs it once with the hook, as mirrors-clang-format does, and note that parallel hook runs install the wheel once. * chore: drop the outdated default-version note from release notes The note said the hook always uses the latest clang tool release. Since #302 an installed wheel is reused and not upgraded, so the note was wrong. Without the note the workflow can call the shared org release-drafter workflow, like the other cpp-linter repos. --------- Co-authored-by: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
1 parent d61ef6c commit b9c5bee

4 files changed

Lines changed: 33 additions & 56 deletions

File tree

‎.github/workflows/release-drafter.yml‎

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,11 @@ on:
66
- "main"
77
workflow_dispatch:
88

9+
permissions: {}
10+
911
jobs:
1012
draft-release:
1113
permissions:
12-
# write permission is required to create a github release
1314
contents: write
14-
# write permission is required for autolabeler
15-
# otherwise, read permission is required at least
16-
pull-requests: write
17-
runs-on: ubuntu-latest
18-
steps:
19-
- name: Checkout repository
20-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21-
with:
22-
persist-credentials: false
23-
24-
- name: Generate release notes header
25-
run: |
26-
{
27-
echo "## 💡 Default Clang Tool Versions"
28-
echo ""
29-
echo "Versions are resolved dynamically from PyPI at hook runtime, always using the latest stable release by default. "
30-
echo "You can pin a specific version by adding the \`--version\` argument under \`args\` in your pre-commit config."
31-
echo "See [Custom Clang Tool Version](https://github.com/cpp-linter/cpp-linter-hooks?tab=readme-ov-file#custom-clang-tool-version) for details."
32-
echo ""
33-
} > release_notes.md
34-
cat release_notes.md
35-
36-
# Export release notes content to env variable for Release Drafter
37-
{
38-
echo "RELEASE_BODY<<EOF"
39-
cat release_notes.md
40-
echo "EOF"
41-
} >> "$GITHUB_ENV"
42-
43-
# Draft your next Release notes as Pull Requests are merged into the default branch
44-
- uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0
45-
with:
46-
commitish: 'main'
47-
header: ${{ env.RELEASE_BODY }}
48-
config-name: github:cpp-linter/.github:/.github/release-drafter.yml
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
pull-requests: read
16+
uses: cpp-linter/.github/.github/workflows/release-drafter.yml@main

‎README.md‎

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Add this configuration to your `.pre-commit-config.yaml` file:
1919
```yaml
2020
repos:
2121
- repo: https://github.com/cpp-linter/cpp-linter-hooks
22-
rev: v1.7.0
22+
rev: v1.8.0
2323
hooks:
2424
- id: clang-format
2525
args: [--style=file, --version=21]
@@ -35,12 +35,16 @@ a `compile_commands.json`, which it looks for in `build/` and a few other direct
3535
it skips clang-tidy on your machine and fails in CI (see
3636
[Compilation database](https://github.com/cpp-linter/cpp-linter-hooks#compilation-database)).
3737

38+
For teams, CI and machines behind a firewall or a company PyPI mirror, also pin the wheel in
39+
`additional_dependencies` so pre-commit installs it once, with the hook (see
40+
[Install the tool with the hook](https://github.com/cpp-linter/cpp-linter-hooks#install-the-tool-with-the-hook)).
41+
3842
## Usage
3943

4044
### Custom clang tool version
4145

4246
> [!TIP]
43-
> The `rev` tag (e.g. `v1.7.0`) is the **project** version, not the clang tool version. Without
47+
> The `rev` tag (e.g. `v1.8.0`) is the **project** version, not the clang tool version. Without
4448
> `--version`, each hook installs the newest clang-format or clang-tidy wheel on PyPI the first time
4549
> it runs and keeps it until pre-commit rebuilds the hook environment, so two machines can run
4650
> different LLVM versions with the same configuration. For production use, always pin the tool
@@ -53,12 +57,14 @@ it skips clang-tidy on your machine and fails in CI (see
5357
a wheel, the hook fails and lists some of the versions that exist.
5458
- When the hook environment already has a wheel that matches `--version` (or any wheel, without
5559
`--version`), the hook uses it and does not contact pypi.org. Otherwise it looks the version up
56-
on pypi.org and installs it, so that run needs network access.
60+
on pypi.org and installs it, so that run needs network access. pre-commit runs the hook on
61+
groups of files in parallel; one of them installs the wheel and the others wait for it.
5762

58-
### Offline and pre-commit.ci
63+
### Install the tool with the hook
5964

60-
To install the clang tool together with the hook, list the exact wheel in
61-
`additional_dependencies`:
65+
We recommend listing the exact wheel in `additional_dependencies`. pre-commit then installs the
66+
clang tool once, when it creates the hook environment, the same way
67+
[mirrors-clang-format](https://github.com/pre-commit/mirrors-clang-format) does:
6268

6369
```yaml
6470
- id: clang-format
@@ -69,11 +75,16 @@ To install the clang tool together with the hook, list the exact wheel in
6975
additional_dependencies: [clang-tidy==21.1.6]
7076
```
7177

72-
pre-commit installs `additional_dependencies` when it creates the hook environment (for example
73-
with `pre-commit install-hooks`), so the hooks need no network access when they run. Use this on
74-
[pre-commit.ci](https://pre-commit.ci/), which runs hooks without network access, and behind a
75-
firewall. The pinned wheel must match `--version`; otherwise the hook installs the `--version` one
76-
at run time.
78+
pre-commit installs `additional_dependencies` with the hook (for example on
79+
`pre-commit install-hooks`), through the same package index it uses for the hook itself. The hooks
80+
then never install anything or contact pypi.org when they run, so this works:
81+
82+
- on [pre-commit.ci](https://pre-commit.ci/), which runs hooks without network access,
83+
- behind a firewall or with a company PyPI mirror, where pypi.org may be blocked or slow,
84+
- for teams and CI, where every machine gets exactly the same wheel.
85+
86+
The pinned wheel must match `--version`; otherwise the hook installs the `--version` one at run
87+
time. Without `--version`, the hook uses the pinned wheel.
7788

7889
### clang-format
7990

@@ -204,7 +215,7 @@ See [Performance optimization](https://github.com/cpp-linter/cpp-linter-hooks#pe
204215
```yaml
205216
repos:
206217
- repo: https://github.com/cpp-linter/cpp-linter-hooks
207-
rev: v1.7.0 # includes --fix support
218+
rev: v1.8.0 # includes --fix support
208219
hooks:
209220
- id: clang-tidy
210221
args: [--fix]
@@ -227,7 +238,7 @@ repository root works too.
227238
```yaml
228239
repos:
229240
- repo: https://github.com/cpp-linter/cpp-linter-hooks
230-
rev: v1.7.0
241+
rev: v1.8.0
231242
hooks:
232243
- id: clang-tidy
233244
# Auto-detects ./build/compile_commands.json if present
@@ -282,7 +293,7 @@ Three self-contained templates plus quick snippets for other common setups.
282293

283294
```yaml
284295
- repo: https://github.com/cpp-linter/cpp-linter-hooks
285-
rev: v1.7.0
296+
rev: v1.8.0
286297
hooks:
287298
- id: clang-format
288299
args: [--style=file, --version=21]
@@ -297,7 +308,7 @@ or `-j`:
297308

298309
```yaml
299310
- repo: https://github.com/cpp-linter/cpp-linter-hooks
300-
rev: v1.7.0
311+
rev: v1.8.0
301312
hooks:
302313
- id: clang-tidy
303314
args: [--version=21, --jobs=4]
@@ -334,7 +345,7 @@ This approach ensures that only modified files are checked, further speeding up
334345
```yaml
335346
repos:
336347
- repo: https://github.com/cpp-linter/cpp-linter-hooks
337-
rev: v1.7.0
348+
rev: v1.8.0
338349
hooks:
339350
- id: clang-format
340351
args: [--style=file, --version=21, --verbose] # Shows processed files

‎examples/cmake/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you already have a CMake project, you need **two files**:
77
```yaml
88
repos:
99
- repo: https://github.com/cpp-linter/cpp-linter-hooks
10-
rev: v1.7.0
10+
rev: v1.8.0
1111
hooks:
1212
- id: clang-format
1313
args: [--style=file, --version=21]

‎examples/meson/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you already have a Meson project, configure the hooks and generate a compilat
77
```yaml
88
repos:
99
- repo: https://github.com/cpp-linter/cpp-linter-hooks
10-
rev: v1.7.0
10+
rev: v1.8.0
1111
hooks:
1212
- id: clang-format
1313
args: [--style=file, --version=21]

0 commit comments

Comments
 (0)