1- <!-- markdownlint-disable MD033 MD041-->
1+ <!-- markdownlint-disable MD041 -->
22
33[ file-annotations ] : https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#file-annotations
44[ thread-comments ] : https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#thread-comments
1010[ recipes-doc ] : https://cpp-linter.github.io/cpp-linter-action/examples
1111[ permissions-doc ] : https://cpp-linter.github.io/cpp-linter-action/permissions
1212[ app-token-doc ] : https://cpp-linter.github.io/cpp-linter-action/permissions/#github-app-token
13- [ skip -doc] : https://docs .github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs
13+ [ tools -doc] : https://cpp-linter .github.io/cpp-linter-action/required-tools
1414
1515[ format-annotations-preview ] : https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/annotations-clang-format.png
1616[ tidy-annotations-preview ] : https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/annotations-clang-tidy.png
2222
2323<!-- README-start-->
2424
25- # C/C++ Linter Action <sub ><sup >| clang-format & clang-tidy</sup ></sub >
26-
27- ![ GitHub release (latest SemVer)] ( https://img.shields.io/github/v/release/cpp-linter/cpp-linter-action )
28- [ ![ GitHub marketplace] ( https://img.shields.io/badge/marketplace-C%2FC%2B%2B%20Linter-blue?logo=github )] ( https://github.com/marketplace/actions/c-c-linter )
29- [ ![ cpp-linter] ( https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml/badge.svg )] ( https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml )
30- [ ![ MkDocs Deploy] ( https://github.com/cpp-linter/cpp-linter-action/actions/workflows/mkdocs-deploy.yml/badge.svg )] ( https://github.com/cpp-linter/cpp-linter-action/actions/workflows/mkdocs-deploy.yml )
31- [ ![ cpp-linter hub] ( https://img.shields.io/badge/%F0%9F%8F%A0_cpp--linter_hub-%E2%86%90_home-22863a )] ( https://cpp-linter.github.io/ )
25+ # cpp-linter-action
3226
33- A Github Action for linting C/C++ code integrating clang-tidy and clang-format
34- to collect feedback provided in the form of
35- [ ` file-annotations ` ] [ file-annotations ] , [ ` thread-comments ` ] [ thread-comments ] ,
36- workflow [ ` step-summary ` ] [ step-summary ] , and Pull Request reviews (with
37- [ ` tidy-review ` ] [ tidy-review ] or [ ` format-review ` ] [ format-review ] ).
27+ [ ![ release] ( https://img.shields.io/github/v/release/cpp-linter/cpp-linter-action?label=release&labelColor=454a63&color=007ec6 )] ( https://github.com/cpp-linter/cpp-linter-action/releases )
28+ [ ![ ci] ( https://img.shields.io/github/actions/workflow/status/cpp-linter/cpp-linter-action/self-test.yml?branch=main&label=ci&labelColor=454a63 )] ( https://github.com/cpp-linter/cpp-linter-action/actions/workflows/self-test.yml )
29+ [ ![ part of cpp-linter] ( https://img.shields.io/badge/part%20of-cpp--linter-ffc20a?labelColor=454a63 )] ( https://cpp-linter.github.io/ )
3830
39- > [ !TIP]
40- > Prefer pre-commit hooks over GitHub Actions? Check out
41- > [ ** cpp-linter-hooks** ] ( https://github.com/cpp-linter/cpp-linter-hooks ) —
42- > a pre-commit hook repository that runs ` clang-format ` and ` clang-tidy `
43- > consistently on developer machines and in CI, with no manual LLVM installs.
31+ A GitHub Action that checks the C and C++ files a pull request changes with clang-format and
32+ clang-tidy, and reports the findings as [ ` file-annotations ` ] [ file-annotations ] ,
33+ [ ` thread-comments ` ] [ thread-comments ] , a workflow [ ` step-summary ` ] [ step-summary ] and pull request
34+ reviews (with [ ` tidy-review ` ] [ tidy-review ] or [ ` format-review ` ] [ format-review ] ).
4435
45- ## Usage
36+ [ Website] ( https://cpp-linter.github.io/ ) ·
37+ [ Documentation] ( https://cpp-linter.github.io/cpp-linter-action/ ) ·
38+ [ Marketplace] ( https://github.com/marketplace/actions/c-c-linter ) ·
39+ [ Get started] ( https://cpp-linter.github.io/getting-started/#on-every-pull-request ) ·
40+ [ Discussions] ( https://github.com/orgs/cpp-linter/discussions )
4641
47- Create a new GitHub Actions workflow in your project, e.g. at [ .github/workflows/cpp-linter.yml ] ( https://github.com/cpp-linter/cpp-linter-action/blob/main/.github/workflows/cpp-linter.yml )
42+ ## Quick start
4843
49- The content of the file should be in the following format.
44+ Save this as ` .github/workflows/cpp-linter.yml ` :
5045
5146``` yaml
5247name : cpp-linter
@@ -57,29 +52,58 @@ jobs:
5752 runs-on : ubuntu-latest
5853 permissions :
5954 contents : read
60- pull-requests : write # to post the thread comment
55+ pull-requests : write
6156 steps :
6257 - uses : actions/checkout@v7
6358 - uses : cpp-linter/cpp-linter-action@v2
6459 id : linter
6560 env :
6661 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6762 with :
68- style : ' file' # Use .clang-format config file
69- tidy-checks : ' ' # Use .clang-tidy config file
70- # only 'update' a single comment in a pull request thread.
71- # Pull requests from forks get a read-only token, so skip the comment there.
72- thread-comments : ${{ github.event.pull_request.head.repo.full_name == github.repository && 'update' }}
73- - name : Fail fast?!
63+ version : ' 21'
64+ style : file
65+ tidy-checks : ' '
66+ format-review : true
67+ - name : Fail on lint errors
7468 if : steps.linter.outputs.checks-failed > 0
7569 run : exit 1
7670` ` `
7771
72+ - ` style: file` and `tidy-checks: ''` use your `.clang-format` and `.clang-tidy`. `version` takes
73+ an LLVM major from 12 to 23; `21` is the default.
74+ - Annotations in the diff view are on by default. `format-review`, `tidy-review` and
75+ `thread-comments` are opt-in and need `pull-requests : write`; turn on one of the two reviews, not
76+ both. `auto-fix` commits the clang-format fixes to the branch and needs `contents : write`.
77+ - The action does not fail the job by itself; the last step does, using the `checks-failed`
78+ output.
79+ - Pull requests from forks get a read-only token : annotations still appear, but reviews are not
80+ posted, and `thread-comments` would fail the step. Draft pull requests get no review.
81+
82+ # # Usage
83+
7884For all explanations of our available input parameters and output variables, see our
7985[Inputs and Outputs document][io-doc].
8086
8187See also our [example recipes][recipes-doc].
8288
89+ # ## Post a thread comment
90+
91+ Set `thread-comments` to post the findings as a comment in the pull request thread. With
92+ `update`, the action updates its existing comment instead of posting a new one :
93+
94+ ` ` ` yaml
95+ - uses: cpp-linter/cpp-linter-action@v2
96+ id: linter
97+ env:
98+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+ with:
100+ style: 'file' # Use .clang-format config file
101+ tidy-checks: '' # Use .clang-tidy config file
102+ # only 'update' a single comment in a pull request thread.
103+ # Pull requests from forks get a read-only token, so skip the comment there.
104+ thread-comments: ${{ github.event.pull_request.head.repo.full_name == github.repository && 'update' }}
105+ ` ` `
106+
83107# ## Auto-fix clang-format issues
84108
85109Set `auto-fix : ' true' ` and the action applies ` clang-format -i` to the files with style
@@ -123,35 +147,6 @@ there is no server or webhook handling to host.
123147
124148See [GitHub App token][app-token-doc] for the setup steps.
125149
126- # # Used By
127-
128- <p align="center">
129- <a href="https://github.com/apache"><img src="https://avatars.githubusercontent.com/u/47359?s=200&v=4" alt="Apache" width="28"/></a>
130- <strong>Apache</strong>
131- <a href="https://github.com/samsung"><img src="https://avatars.githubusercontent.com/u/6210390?s=200&v=4" alt="Samsung" width="28"/></a>
132- <strong>Samsung</strong>
133- <a href="https://github.com/bloomberg"><img src="https://avatars.githubusercontent.com/u/1416818?s=200&v=4" alt="Bloomberg" width="28"/></a>
134- <strong>Bloomberg</strong>
135- <a href="https://github.com/qualcomm"><img src="https://avatars.githubusercontent.com/u/55295994?s=200&v=4" alt="Qualcomm" width="28"/></a>
136- <strong>Qualcomm</strong>
137- <a href="https://github.com/nextcloud"><img src="https://avatars.githubusercontent.com/u/19211038?s=200&v=4" alt="Nextcloud" width="28"/></a>
138- <strong>Nextcloud</strong>
139- <a href="https://github.com/CachyOS"><img src="https://avatars.githubusercontent.com/u/85452089?s=200&v=4" alt="CachyOS" width="28"/></a>
140- <strong>CachyOS</strong>
141- </br>
142- <a href="https://github.com/jupyter-xeus"><img src="https://avatars.githubusercontent.com/u/58793052?s=200&v=4" alt="Jupyter" width="28"/></a>
143- <strong>Jupyter</strong>
144- <a href="https://github.com/nnstreamer"><img src="https://avatars.githubusercontent.com/u/60992508?s=200&v=4" alt="NNStreamer" width="28"/></a>
145- <strong>NNStreamer</strong>
146- <a href="https://github.com/Zondax"><img src="https://avatars.githubusercontent.com/u/34372050?s=200&v=4" alt="Zondax" width="28"/></a>
147- <strong>Zondax</strong>
148- <a href="https://github.com/AppNeta"><img src="https://avatars.githubusercontent.com/u/3374594?s=200&v=4" alt="AppNeta" width="28"/></a>
149- <strong>AppNeta</strong>
150- <a href="https://github.com/chocolate-doom"><img src="https://avatars.githubusercontent.com/u/6140118?s=200&v=4" alt="Chocolate Doom" width="28"/></a>
151- <strong>Chocolate Doom</strong>
152- <strong> and <a href="https://github.com/cpp-linter/cpp-linter-action/network/dependents">many more</a>.</strong>
153- </p>
154-
155150# # Example
156151
157152# ## Annotations
@@ -194,86 +189,41 @@ Using [`format-review`][format-review]:
194189
195190![sample format-suggestion][format-suggestion-preview]
196191
197- # # Add C/C++ Linter Action badge in README
198-
199- You can show C/C++ Linter Action status with a badge in your repository README
200-
201- Example
202-
203- ` ` ` markdown
204- [](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml)
205- ` ` `
206-
207- [](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml)
208-
209- # # Have question or feedback?
210-
211- To provide feedback (requesting a feature or reporting a bug) please post to [issues](https://github.com/cpp-linter/cpp-linter-action/issues).
212-
213- # # Required tools installed
192+ # # Supported runners
214193
215- As of v2.16.0, this action uses
194+ Linux, macOS and Windows runners are supported. On Linux, we only support a Debian-based Linux OS
195+ (like Ubuntu and many others), because we first try to use the `apt` package manager to install
196+ clang tools. Linux workflows that use a specific [`container`][gh-container-syntax] need a few
197+ packages installed first. [Required tools][tools-doc] lists them and the sources each runner
198+ installs the clang tools from.
216199
217- - [nushell] for cross-platform compatible scripting
218- - [uv] for driving a Python virtual environment
200+ # # Used by
219201
220- This action installs [nushell] and [uv] automatically.
221- Only [nushell] is added to the PATH environment variable.
222- [uv], and any standalone Python distribution it downloads, are not added to the PATH environment variable.
202+ Projects from these organizations run cpp-linter-action on their default branch :
223203
224- # ## On Linux runners
204+ [<img src="https://avatars.githubusercontent.com/u/47359?s=40&v=4" width="20" height="20" alt=""> Apache](https://github.com/apache) ·
205+ [<img src="https://avatars.githubusercontent.com/u/6210390?s=40&v=4" width="20" height="20" alt=""> Samsung](https://github.com/samsung) ·
206+ [<img src="https://avatars.githubusercontent.com/u/1416818?s=40&v=4" width="20" height="20" alt=""> Bloomberg](https://github.com/bloomberg) ·
207+ [<img src="https://avatars.githubusercontent.com/u/55295994?s=40&v=4" width="20" height="20" alt=""> Qualcomm](https://github.com/qualcomm) ·
208+ [<img src="https://avatars.githubusercontent.com/u/19211038?s=40&v=4" width="20" height="20" alt=""> Nextcloud](https://github.com/nextcloud) ·
209+ [<img src="https://avatars.githubusercontent.com/u/85452089?s=40&v=4" width="20" height="20" alt=""> CachyOS](https://github.com/CachyOS) ·
210+ [<img src="https://avatars.githubusercontent.com/u/58793052?s=40&v=4" width="20" height="20" alt=""> Jupyter Xeus](https://github.com/jupyter-xeus) ·
211+ [<img src="https://avatars.githubusercontent.com/u/60992508?s=40&v=4" width="20" height="20" alt=""> NNStreamer](https://github.com/nnstreamer) ·
212+ [<img src="https://avatars.githubusercontent.com/u/34372050?s=40&v=4" width="20" height="20" alt=""> Zondax](https://github.com/Zondax) ·
213+ [<img src="https://avatars.githubusercontent.com/u/3374594?s=40&v=4" width="20" height="20" alt=""> AppNeta](https://github.com/AppNeta) ·
214+ [<img src="https://avatars.githubusercontent.com/u/6140118?s=40&v=4" width="20" height="20" alt=""> Chocolate Doom](https://github.com/chocolate-doom)
225215
226- We only support Linux runners using a Debian-based Linux OS (like Ubuntu and many others).
227- This is because we first try to use the `apt` package manager to install clang tools.
216+ The [showcase](https://cpp-linter.github.io/showcase/) lists more projects that use it.
228217
229- Linux workflows that use a specific [`container`][gh-container-syntax] should ensure that
230- the following are installed :
218+ # # Contributing
231219
232- - GLIBC (v2.32 or later)
233- - ` wget` or `curl`
234- - ` lsb-release` (required by LLVM-provided install script)
235- - ` software-properties-common` (required by LLVM-provided install script)
236- - ` gnupg` (required by LLVM-provided install script)
237-
238- ` ` ` shell
239- apt-get update
240- apt-get install -y libc6 wget lsb-release software-properties-common gnupg
241- ` ` `
242-
243- Otherwise, [nushell] and/or the LLVM-provided bash script will fail to run.
244-
245- If installing clang tools fails using the `apt` package manager, then
246- we alternatively try the following sources in order :
247-
248- 1. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel]
249- 2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.
250-
251- # ## On macOS runners
252-
253- The specified `version` of `clang-format` and `clang-tidy` is installed via
254- the following sources in order (whichever succeeds first) :
255-
256- 1. Homebrew
257- 2. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel]
258- 3. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.
259-
260- # ## On Windows runners
261-
262- For Windows runners, we use clang tools installed via
263- the following sources in order (whichever succeeds first) :
264-
265- 1. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel]
266- 2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.
220+ Read [CONTRIBUTING.md](https://github.com/cpp-linter/cpp-linter-action/blob/main/CONTRIBUTING.md) before you open a pull request, and report bugs or request features in [issues](https://github.com/cpp-linter/cpp-linter-action/issues).
267221
268222# # License
269223
270224The scripts and documentation in this project are released under the [MIT License](https://github.com/cpp-linter/cpp-linter-action/blob/main/LICENSE)
271225
272- [nushell] : https://www.nushell.sh/
273- [uv] : https://docs.astral.sh/uv/
274- [cpp-linter/clang-tools-pip] : https://github.com/cpp-linter/clang-tools-pip
275226[gh-container-syntax] : https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainer
276- [clang-tidy-wheel] : https://pypi.org/project/clang-tidy
277- [clang-format-wheel] : https://pypi.org/project/clang-format
227+ [skip-doc] : https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs
278228
279229<!--README-end-->
0 commit comments