Skip to content

Commit e044072

Browse files
authored
docs: rework the README to the org layout and move required tools to the docs (#493)
Follow the layout the other cpp-linter READMEs move to: name, three badges, one sentence, a link line, then Quick start, Usage, Example, Supported runners, Used by, Contributing and License. The Quick start is the website's Get started workflow. The thread comment step from #491 stays under Usage, unchanged. Move "Required tools installed" to a new docs page, Required Tools, word for word except for the install order: clang-tools 1.3.0 tries the static binaries first and falls back to the PyPI wheels, not the other way round. The README keeps a short Supported runners section. docs/index.md never defined skip-doc, so the docs home page printed "[skip instruction][skip-doc]" as text. The README now defines it inside the included range.
1 parent f2e4501 commit e044072

4 files changed

Lines changed: 139 additions & 126 deletions

File tree

‎README.md‎

Lines changed: 76 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
@@ -10,7 +10,7 @@
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
@@ -22,31 +22,26 @@
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
5247
name: 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+
7884
For all explanations of our available input parameters and output variables, see our
7985
[Inputs and Outputs document][io-doc].
8086

8187
See 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

85109
Set `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

124148
See [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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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-
[![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)
205-
```
206-
207-
[![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)
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

270224
The 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-->

‎docs/index.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[recipes-doc]: examples/index.md
99
[permissions-doc]: permissions.md
1010
[app-token-doc]: permissions.md#github-app-token
11+
[tools-doc]: required-tools.md
1112

1213
[format-annotations-preview]: images/annotations-clang-format.png
1314
[tidy-annotations-preview]: images/annotations-clang-tidy.png

‎docs/required-tools.md‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Required Tools
2+
3+
As of v2.16.0, this action uses
4+
5+
- [nushell] for cross-platform compatible scripting
6+
- [uv] for driving a Python virtual environment
7+
8+
This action installs [nushell] and [uv] automatically.
9+
Only [nushell] is added to the PATH environment variable.
10+
[uv], and any standalone Python distribution it downloads, are not added to the PATH environment variable.
11+
12+
## On Linux runners
13+
14+
We only support Linux runners using a Debian-based Linux OS (like Ubuntu and many others).
15+
This is because we first try to use the `apt` package manager to install clang tools.
16+
17+
Linux workflows that use a specific [`container`][gh-container-syntax] should ensure that
18+
the following are installed:
19+
20+
- GLIBC (v2.32 or later)
21+
- `wget` or `curl`
22+
- `lsb-release` (required by LLVM-provided install script)
23+
- `software-properties-common` (required by LLVM-provided install script)
24+
- `gnupg` (required by LLVM-provided install script)
25+
26+
```shell
27+
apt-get update
28+
apt-get install -y libc6 wget lsb-release software-properties-common gnupg
29+
```
30+
31+
Otherwise, [nushell] and/or the LLVM-provided bash script will fail to run.
32+
33+
If installing clang tools fails using the `apt` package manager, then
34+
we alternatively try the following sources in order:
35+
36+
1. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.
37+
2. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel]
38+
39+
## On macOS runners
40+
41+
The specified `version` of `clang-format` and `clang-tidy` is installed via
42+
the following sources in order (whichever succeeds first):
43+
44+
1. Homebrew
45+
2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.
46+
3. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel]
47+
48+
## On Windows runners
49+
50+
For Windows runners, we use clang tools installed via
51+
the following sources in order (whichever succeeds first):
52+
53+
1. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.
54+
2. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel]
55+
56+
[nushell]: https://www.nushell.sh/
57+
[uv]: https://docs.astral.sh/uv/
58+
[cpp-linter/clang-tools-pip]: https://github.com/cpp-linter/clang-tools-pip
59+
[gh-container-syntax]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainer
60+
[clang-tidy-wheel]: https://pypi.org/project/clang-tidy
61+
[clang-format-wheel]: https://pypi.org/project/clang-format

‎mkdocs.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nav:
99
- inputs-outputs.md
1010
- pr-review-caveats.md
1111
- permissions.md
12+
- required-tools.md
1213
- examples/index.md
1314
- contributing-guidelines.md
1415
- "← cpp-linter hub": https://cpp-linter.github.io/

0 commit comments

Comments
 (0)