Skip to content

Commit 2d9df07

Browse files
committed
docs: tighten the copy in the clang-tidy guide
1 parent 22fecba commit 2d9df07

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

‎docs/blog/posts/2026-09-20-clang-tidy-pull-requests-github-actions.md‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ get stuck: clang-tidy needs the real compile flags or it reports missing headers
2222
an existing code base produces thousands of findings nobody asked for, and the output ends up in a
2323
CI log that contributors do not open.
2424

25-
This guide sets up one GitHub Actions job that solves those three problems. When it is done,
26-
clang-tidy findings appear as review comments on the lines a pull request changed, and the check
27-
turns red when something is left unfixed.
25+
With the GitHub Actions job below, clang-tidy findings appear as review comments on the lines a
26+
pull request changed, and the check turns red when something is left unfixed.
2827

2928
<!-- more -->
3029

31-
## Step 1: start with a small `.clang-tidy`
30+
## Step 1: Start with a small `.clang-tidy`
3231

3332
Put the configuration in the repository, not in the workflow. The same file is then used by CI,
3433
by editors (clangd, CLion, Qt Creator, Visual Studio) and by anyone running clang-tidy by hand.
@@ -63,7 +62,7 @@ $ clang-tidy --verify-config
6362
No config errors detected.
6463
```
6564

66-
## Step 2: generate `compile_commands.json`
65+
## Step 2: Generate `compile_commands.json`
6766

6867
clang-tidy parses each file the way the compiler does, so it needs the include paths, defines and
6968
language standard of the real build. It reads them from a compilation database,
@@ -113,7 +112,7 @@ Two things commonly go wrong here:
113112
- **Generated headers.** Protobuf output, `config.h` and similar files only exist after the build
114113
step that produces them. Build those targets before running clang-tidy.
115114

116-
## Step 3: add the workflow
115+
## Step 3: Add the workflow
117116

118117
```yaml title=".github/workflows/clang-tidy.yml"
119118
name: clang-tidy
@@ -155,15 +154,13 @@ jobs:
155154
| --- | --- |
156155
| `version: '21'` | Installs clang-tidy 21 on the runner. Pin it, and use the same major version locally; new LLVM releases add and move checks. |
157156
| `style: ''` | Turns clang-format off, so this job is clang-tidy only. Set it to `file` to check formatting against your `.clang-format` in the same step. |
158-
| `tidy-checks: ''` | Uses your `.clang-tidy` and nothing else. The default value is a broad list of check groups that is **appended** to the `Checks` in your file, which is the usual reason CI reports more than a local run. |
157+
| `tidy-checks: ''` | Uses your `.clang-tidy` and nothing else. The default value is a broad list of check groups that is appended to the `Checks` in your file, so CI reports more than a local run with the same `.clang-tidy`. |
159158
| `database: build` | The directory that contains `compile_commands.json`. |
160159
| `lines-changed-only: true` | Reports findings only on lines the pull request added or modified. |
161160
| `tidy-review: true` | Posts the findings as a pull request review. |
162161
| `step-summary: true` | Writes the same report to the workflow run's summary page. |
163162

164-
## Step 4: report only what the pull request changed
165-
166-
This is the setting that makes clang-tidy acceptable on a code base that has never used it.
163+
## Step 4: Report only what the pull request changed
167164

168165
- `files-changed-only` defaults to `true`: only files touched by the pull request are analyzed.
169166
- `lines-changed-only` filters what is reported inside those files:
@@ -182,7 +179,7 @@ base gets cleaner in the places that are actively worked on, and nobody has to l
182179
clang-tidy still parses the whole translation unit, so the run time depends on how many files
183180
changed, not on how many lines.
184181

185-
## Step 5: choose where the feedback appears
182+
## Step 5: Choose where the feedback appears
186183

187184
| Feedback | Input | Default | Token permission |
188185
| --- | --- | --- | --- |
@@ -207,7 +204,7 @@ Things to know about reviews:
207204
Approving requires the repository setting "Allow GitHub Actions to create and approve pull
208205
requests". Set `passive-reviews: true` if the bot should only comment.
209206

210-
## Step 6: decide when the check fails
207+
## Step 6: Decide when the check fails
211208

212209
The action reports; it does not fail the job by itself. The last step in the workflow does that,
213210
using the `clang-tidy-checks-failed` output (there is also `clang-format-checks-failed`, and
@@ -237,7 +234,7 @@ arbitrary code execution for anyone who opens a pull request.
237234
| Nothing is reported for headers | `HeaderFilterRegex` does not match your header paths. |
238235
| Findings from vendored code | Narrow `HeaderFilterRegex`, and exclude the sources with `ignore: 'third_party|build'`. |
239236
| No review shows up | The pull request is a draft, comes from a fork, or the job lacks `pull-requests: write`. |
240-
| The job is slow | Keep `files-changed-only` on. The analysis already uses every core (`jobs: 0`); the time usually goes into installing dependencies and configuring, so cache those. |
237+
| The job is slow | Keep `files-changed-only` on. The analysis already uses every core (`jobs: 0`). Check the step timings in the run; if installing dependencies or configuring takes longer than the analysis, cache those. |
241238

242239
## Run the same checks before the commit
243240

0 commit comments

Comments
 (0)