diff --git a/docs/blog/posts/2026-12-01-cpp-linter-action-v3.md b/docs/blog/posts/2026-12-01-cpp-linter-action-v3.md new file mode 100644 index 0000000..abb6d1e --- /dev/null +++ b/docs/blog/posts/2026-12-01-cpp-linter-action-v3.md @@ -0,0 +1,183 @@ +--- +date: + created: 2026-12-01 +draft: true +categories: + - Releases +tags: + - cpp-linter-action + - cpp-linter + - clang-tidy + - clang-format + - github-actions +authors: + - shenxianpeng +description: >- + cpp-linter-action v3 runs cpp-linter 2.0, rewritten in Rust: one review with both tools' + suggestions, SARIF for code scanning, and clang tools installed for you. Moving from v2 takes one line. +--- + + + +# cpp-linter-action v3: one review for both tools, and findings where you look + +cpp-linter-action v3 is out. It runs cpp-linter 2.0, a rewrite in Rust, and for most workflows the +upgrade is one line: `@v2` becomes `@v3`. + + + +
+ The comment cpp-linter-action v2 posts on a pull request + The comment v3 posts on the same pull request + v3v2 + +
+ +
+
+ The comment cpp-linter-action v2 posts on a pull request (dark theme) + The comment v3 posts on the same pull request (dark theme) + v3v2 + +
+ +
+ + + +*The same pull request, commented on by v2 and by v3. Drag to compare.* + +## What you will notice first + +**A comment that reads at a glance.** The thread comment now opens with the verdict, then a short +table of what each tool found, then the findings per file. When there is something to fix, a +folded section says how: the command to run locally, or the patch that cpp-linter already made. +When everything passes, the comment says so in two lines. + +**One review, both tools.** v2 had `tidy-review` and `format-review`, and posted their suggestions +separately. v3 has `pr-review`, which posts one review with the clang-format and clang-tidy +suggestions together. Each inline comment names its check and links to its documentation, so the +author can apply the suggestion with one click or read why it matters. + + + +## Lighter on the runner + +cpp-linter 2.0 starts in about a millisecond instead of 65, and the linter process needs about +half the memory (40 MiB instead of 87 MiB in a full clang-tidy run of libgit2). It installs the +clang tools only when there are files for them to check. The clang-tidy run itself takes as long +as before: v2 of this action already ran files in parallel, and so does v3. + +## Findings where your team already looks + +One run can now feed every place a reviewer looks: + +| Where | How | +|---|---| +| Pull request review | `pr-review: true` | +| Pull request thread | `thread-comments: true` | +| Workflow summary | `step-summary: true` | +| Diff annotations | on by default | +| Security tab (GitHub code scanning) | `sarif-file`, then `github/codeql-action/upload-sarif` | + +The SARIF file lists clang-tidy diagnostics, so code scanning tracks them per branch and marks the +new ones on a pull request. The "GitHub code scanning" [recipe](https://cpp-linter.github.io/cpp-linter-action/examples/) +shows a complete workflow. + +![One cpp-linter run sends its findings to the pull request review, the thread comment, the step summary, diff annotations and the Security tab](../../static/blog/v3/fanout-light.svg#only-light) +![One cpp-linter run sends its findings to the pull request review, the thread comment, the step summary, diff annotations and the Security tab](../../static/blog/v3/fanout-dark.svg#only-dark) + +## No setup step for clang tools + +You no longer install clang-format and clang-tidy before the action runs. Set `version` and v3 +installs what it needs, and only for the files it is about to check: + +- a major version such as `18`, any version from LLVM 12 to 23; +- a requirement such as `>=17, <20`, or `=18.1.8` for an exact release; +- `latest`, the new default, for the newest major version cpp-linter can install. + +v3 tries the runner's package manager first, then PyPI wheels, then the static binaries that +cpp-linter builds for LLVM 12 to 23 on six platforms. We test it on Ubuntu, macOS and Windows +runners, on both x64 and Arm. + +## Fixes you can review + +With `auto-fix: true`, v2 committed clang-format fixes. v3 commits one patch with the clang-format +and the clang-tidy fixes, and also sets its path as the `fix-patch-path` output, so you can upload +it as an artifact instead of committing it. cpp-linter itself never edits your files; the action +applies the patch only when `auto-fix` is on. + +## Upgrade + +![The upgrade as a diff: @v2 becomes @v3, and format-review becomes pr-review](../../static/blog/v3/upgrade-light.svg#only-light) +![The upgrade as a diff: @v2 becomes @v3, and format-review becomes pr-review](../../static/blog/v3/upgrade-dark.svg#only-dark) + +```diff +- - uses: cpp-linter/cpp-linter-action@v2 ++ - uses: cpp-linter/cpp-linter-action@v3 + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + style: file + tidy-checks: '' +- format-review: true ++ pr-review: true +``` + + +Before you merge the upgrade, check three things: + +1. `tidy-review` and `format-review` still work, as aliases of `pr-review`. Either one now turns on + suggestions from both tools. +2. `version` defaults to `latest`. Pin a major version if you want results that do not change + when a new LLVM release comes out. +3. The new `strict` input fails the step when any check fails, so a separate step that reads + `checks-failed` is no longer needed. [TODO: say whether `strict` is on by default, and list the + other agreed default changes, once decided.] + +The [migration guide](https://cpp-linter.github.io/cpp-linter-action/migration/) lists every input +that changed, and covers workflows still on v1. + +## Staying on v2 + +Workflows that use `@v2` keep working. v2 gets bug and security fixes, and new features go into +v3. If your workflow uses `@main`, it now runs v3; pin `@v2` to stay where you are. + +## Beyond GitHub Actions + +cpp-linter 2.0 is also a command you can run anywhere: + +- install it from PyPI, npm or crates.io, or download a prebuilt binary + ([Quick start](https://cpp-linter.github.io/cpp-linter-rs/#quick-start)); +- on GitLab, `--code-quality-file` writes a Code Quality report that shows the findings in merge + requests; +- on your own machine, it checks your uncommitted changes, so you can fix them before you push. + +The command line is where 2.0 is fastest. cpp-linter 1.x checks one file at a time unless you pass +`--jobs`, and 2.0 always uses every core. On a GitHub-hosted `ubuntu-24.04` runner (4 vCPU), a +full run over the 133 C files of libgit2 with clang 18 took 270 s with 1.x and 103 s with 2.0, with +the same findings. + +![cpp-linter 1.16.1 takes 270 s and cpp-linter 2.0 takes 103 s for the same full run](../../static/blog/v3/race-light.svg#only-light) +![cpp-linter 1.16.1 takes 270 s and cpp-linter 2.0 takes 103 s for the same full run](../../static/blog/v3/race-dark.svg#only-dark) + +We measured both with hyperfine. The [benchmark workflow](https://github.com/cpp-linter/test-cpp-linter-action/blob/65bf51cadf77482bcd893fbcfd8cefb7c3c7f6c3/.github/workflows/bench.yml) +has every command, so you can run it yourself. + +## Thank you + +cpp-linter 2.0 is the result of more than two years of work by +[@2bndy5](https://github.com/2bndy5), who rewrote cpp-linter in Rust and built the clang tools +installer it relies on. Thank you also to everyone who tried the release candidates and reported +what broke. + +If v3 helps your team, a star on +[cpp-linter-action](https://github.com/cpp-linter/cpp-linter-action) helps others find it. diff --git a/docs/static/blog/v3/comment-v2-dark.webp b/docs/static/blog/v3/comment-v2-dark.webp new file mode 100644 index 0000000..7d54306 Binary files /dev/null and b/docs/static/blog/v3/comment-v2-dark.webp differ diff --git a/docs/static/blog/v3/comment-v2-light.webp b/docs/static/blog/v3/comment-v2-light.webp new file mode 100644 index 0000000..a194820 Binary files /dev/null and b/docs/static/blog/v3/comment-v2-light.webp differ diff --git a/docs/static/blog/v3/comment-v3-dark.webp b/docs/static/blog/v3/comment-v3-dark.webp new file mode 100644 index 0000000..ab1b5fd Binary files /dev/null and b/docs/static/blog/v3/comment-v3-dark.webp differ diff --git a/docs/static/blog/v3/comment-v3-light.webp b/docs/static/blog/v3/comment-v3-light.webp new file mode 100644 index 0000000..79e0c0f Binary files /dev/null and b/docs/static/blog/v3/comment-v3-light.webp differ diff --git a/docs/static/blog/v3/fanout-dark.svg b/docs/static/blog/v3/fanout-dark.svg new file mode 100644 index 0000000..49b649b --- /dev/null +++ b/docs/static/blog/v3/fanout-dark.svg @@ -0,0 +1 @@ +One cpp-linter-action v3 run, five places to read itA single run of cpp-linter-action v3 reports clang-format and clang-tidy findings in a pull request review, a thread comment, the step summary, diff annotations and the GitHub Security tab.cpp-linterOne run.Five places to read it.cpp-linter-action v3 reports the same findingswherever your reviewers already look..github/workflows/cpp-linter.yml- uses: cpp-linter/cpp-linter-action@v3 with: pr-review: true sarif-file: cpp-linter.sarifPull request reviewSuggestions from both tools, applied in one clickpr-reviewThread commentThe verdict first, then the findings per filethread-commentsStep summaryThe same report on the workflow run pagestep-summaryDiff annotationsWarnings right on the changed linesfile-annotationsSecurity tabAlerts in GitHub code scanningsarif-file diff --git a/docs/static/blog/v3/fanout-light.svg b/docs/static/blog/v3/fanout-light.svg new file mode 100644 index 0000000..dc49830 --- /dev/null +++ b/docs/static/blog/v3/fanout-light.svg @@ -0,0 +1 @@ +One cpp-linter-action v3 run, five places to read itA single run of cpp-linter-action v3 reports clang-format and clang-tidy findings in a pull request review, a thread comment, the step summary, diff annotations and the GitHub Security tab.cpp-linterOne run.Five places to read it.cpp-linter-action v3 reports the same findingswherever your reviewers already look..github/workflows/cpp-linter.yml- uses: cpp-linter/cpp-linter-action@v3 with: pr-review: true sarif-file: cpp-linter.sarifPull request reviewSuggestions from both tools, applied in one clickpr-reviewThread commentThe verdict first, then the findings per filethread-commentsStep summaryThe same report on the workflow run pagestep-summaryDiff annotationsWarnings right on the changed linesfile-annotationsSecurity tabAlerts in GitHub code scanningsarif-file diff --git a/docs/static/blog/v3/race-dark.svg b/docs/static/blog/v3/race-dark.svg new file mode 100644 index 0000000..c22c90c --- /dev/null +++ b/docs/static/blog/v3/race-dark.svg @@ -0,0 +1,3 @@ +cpp-linter 2.0 finishes a full run in 103 s; 1.x takes 270 sWith default settings on a GitHub-hosted ubuntu-24.04 runner, a full clang-tidy run over the 133 C files of libgit2 took 270 seconds with cpp-linter 1.16.1 and 103 seconds with cpp-linter 2.0, with the same findings.cpp-linterSame findings, done in 103 s instead of 270 s.Full clang-tidy run over the 133 C files of libgit2 with clang 18, default settings, on a GitHub-hostedubuntu-24.04 runner with 4 vCPU. 1.x checks one file at a time unless told otherwise; 2.0 uses every core.cpp-linter 1.16.1Python +270 scpp-linter 2.0Rust +103 s0 s60 s120 s180 s240 sWall-clock time16,237clang-tidy findings, identical in both40 MiBpeak memory, down from 87 MiB1 msto start, down from 66 ms diff --git a/docs/static/blog/v3/race-light.svg b/docs/static/blog/v3/race-light.svg new file mode 100644 index 0000000..81c5ae5 --- /dev/null +++ b/docs/static/blog/v3/race-light.svg @@ -0,0 +1,3 @@ +cpp-linter 2.0 finishes a full run in 103 s; 1.x takes 270 sWith default settings on a GitHub-hosted ubuntu-24.04 runner, a full clang-tidy run over the 133 C files of libgit2 took 270 seconds with cpp-linter 1.16.1 and 103 seconds with cpp-linter 2.0, with the same findings.cpp-linterSame findings, done in 103 s instead of 270 s.Full clang-tidy run over the 133 C files of libgit2 with clang 18, default settings, on a GitHub-hostedubuntu-24.04 runner with 4 vCPU. 1.x checks one file at a time unless told otherwise; 2.0 uses every core.cpp-linter 1.16.1Python +270 scpp-linter 2.0Rust +103 s0 s60 s120 s180 s240 sWall-clock time16,237clang-tidy findings, identical in both40 MiBpeak memory, down from 87 MiB1 msto start, down from 66 ms diff --git a/docs/static/blog/v3/upgrade-dark.svg b/docs/static/blog/v3/upgrade-dark.svg new file mode 100644 index 0000000..8a7f70a --- /dev/null +++ b/docs/static/blog/v3/upgrade-dark.svg @@ -0,0 +1,2 @@ +Upgrade to cpp-linter-action v3A workflow diff: cpp-linter-action@v2 becomes @v3, and format-review becomes pr-review, which posts one review with clang-format and clang-tidy suggestions.cpp-linterFrom v2 to v3 in one line.Change the tag. Using reviews? Rename one input..github/workflows/cpp-linter.ymlsteps: - uses: actions/checkout@v4- - uses: cpp-linter/cpp-linter-action@v2+ - uses: cpp-linter/cpp-linter-action@v3 with: style: file- format-review: true+ pr-review: true +cpp-linter-action v3One review with both tools’ suggestions diff --git a/docs/static/blog/v3/upgrade-light.svg b/docs/static/blog/v3/upgrade-light.svg new file mode 100644 index 0000000..c8a0c1f --- /dev/null +++ b/docs/static/blog/v3/upgrade-light.svg @@ -0,0 +1,2 @@ +Upgrade to cpp-linter-action v3A workflow diff: cpp-linter-action@v2 becomes @v3, and format-review becomes pr-review, which posts one review with clang-format and clang-tidy suggestions.cpp-linterFrom v2 to v3 in one line.Change the tag. Using reviews? Rename one input..github/workflows/cpp-linter.ymlsteps: - uses: actions/checkout@v4- - uses: cpp-linter/cpp-linter-action@v2+ - uses: cpp-linter/cpp-linter-action@v3 with: style: file- format-review: true+ pr-review: true +cpp-linter-action v3One review with both tools’ suggestions diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 0033f53..b52263a 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -46,3 +46,91 @@ .md-typeset .compare table:not([class]) td:first-child { font-weight: 600; } + +/* Before/after slider in blog posts: the second image is clipped to the handle's position */ +.md-typeset .cl-cmp { + position: relative; + aspect-ratio: 1712 / 1120; + max-width: 100%; + margin: 1.5em 0 0.5em; + border: 1px solid var(--md-default-fg-color--lightest); + border-radius: 0.6rem; + overflow: hidden; + background: #fff; + user-select: none; + touch-action: pan-y; +} +.md-typeset .cl-cmp.dk { display: none; background: #0d1117; } +[data-md-color-scheme="slate"] .md-typeset .cl-cmp.lt { display: none; } +[data-md-color-scheme="slate"] .md-typeset .cl-cmp.dk { display: block; } +.md-typeset .cl-cmp img { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + object-fit: cover; + object-position: top left; + pointer-events: none; +} +.md-typeset .cl-cmp .cl-new { clip-path: inset(0 calc(100% - var(--pos, 55%)) 0 0); } +.md-typeset .cl-cmp .cl-bar { + position: absolute; + top: 0; + bottom: 0; + left: var(--pos, 55%); + width: 3px; + margin-left: -1.5px; + background: #FFC20A; +} +.md-typeset .cl-cmp .cl-knob { + position: absolute; + top: 50%; + left: var(--pos, 55%); + width: 1.4rem; + height: 1.4rem; + margin: -0.7rem 0 0 -0.7rem; + border-radius: 50%; + background: #FFC20A; + display: grid; + place-items: center; +} +.md-typeset .cl-cmp .cl-knob svg { width: 0.8rem; height: 0.8rem; } +.md-typeset .cl-cmp .cl-tag { + position: absolute; + bottom: 0.6rem; + z-index: 1; + padding: 0.1rem 0.5rem; + border-radius: 999px; + font-size: 0.6rem; + font-weight: 600; + background: #F7F5EF; + color: #5A5E70; + border: 1px solid #E4DFD1; +} +.md-typeset .cl-cmp .cl-tag.l { left: 0.6rem; background: #171A2E; color: #F7F5EF; border-color: #171A2E; } +.md-typeset .cl-cmp .cl-tag.r { right: 0.6rem; } +.md-typeset .cl-cmp::after { + content: ""; + position: absolute; + left: 0; + right: 0; + bottom: 0; + height: 3.5rem; + background: linear-gradient(transparent, #fff); + pointer-events: none; +} +.md-typeset .cl-cmp.dk::after { background: linear-gradient(transparent, #0d1117); } +.md-typeset .cl-cmp input[type="range"] { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + margin: 0; + opacity: 0; + cursor: ew-resize; + z-index: 2; +} +.md-typeset .cl-cmp input[type="range"]:focus-visible ~ .cl-knob { + outline: 3px solid var(--md-accent-fg-color); + outline-offset: 2px; +}