https://cpp-linter.github.io/cpp-linter-action/
A Github Action for linting C/C++ code integrating clang-tidy and clang-format to collect feedback provided in the form of file-annotations, thread-comments, workflow step-summary, and Pull Request reviews.
https://cpp-linter.github.io/cpp-linter-action/
clang-format clang-tidy github-actions lint linter pull-requests static-analysis
Last synced: 13 days ago
JSON representation
A Github Action for linting C/C++ code integrating clang-tidy and clang-format to collect feedback provided in the form of file-annotations, thread-comments, workflow step-summary, and Pull Request reviews.
- Host: GitHub
- URL: https://cpp-linter.github.io/cpp-linter-action/
- Owner: cpp-linter
- License: mit
- Created: 2021-04-26T03:26:37.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-11-11T03:27:54.000Z (28 days ago)
- Last Synced: 2025-11-11T04:18:53.698Z (28 days ago)
- Topics: clang-format, clang-tidy, github-actions, lint, linter, pull-requests, static-analysis
- Homepage: https://cpp-linter.github.io/cpp-linter-action/
- Size: 2.13 MB
- Stars: 120
- Watchers: 4
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- static-analysis - cpp-linter-action - tidy and clang-format to collect feedback provided in the form of thread comments and/or annotations. (Multiple languages)
README
[file-annotations]: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#file-annotations
[thread-comments]: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#thread-comments
[step-summary]: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#step-summary
[tidy-review]: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#tidy-review
[format-review]: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs/#format-review
[io-doc]: https://cpp-linter.github.io/cpp-linter-action/inputs-outputs
[recipes-doc]: https://cpp-linter.github.io/cpp-linter-action/examples
[format-annotations-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/annotations-clang-format.png
[tidy-annotations-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/annotations-clang-tidy.png
[thread-comment-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/comment.png
[step-summary-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/step-summary.png
[tidy-review-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/tidy-review.png
[format-review-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/format-review.png
[format-suggestion-preview]: https://raw.githubusercontent.com/cpp-linter/cpp-linter-action/main/docs/images/format-suggestion.png
# C/C++ Linter Action | clang-format & clang-tidy

[](https://github.com/marketplace/actions/c-c-linter)
[](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml)
[](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/mkdocs-deploy.yml)

A Github Action for linting C/C++ code integrating clang-tidy and clang-format
to collect feedback provided in the form of
[`file-annotations`][file-annotations], [`thread-comments`][thread-comments],
workflow [`step-summary`][step-summary], and Pull Request reviews (with
[`tidy-review`][tidy-review] or [`format-review`][format-review]).
## Usage
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)
The content of the file should be in the following format.
```yaml
steps:
- uses: actions/checkout@v5
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: 'file' # Use .clang-format config file
tidy-checks: '' # Use .clang-tidy config file
# only 'update' a single comment in a pull request thread.
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }}
- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
run: exit 1
```
For all explanations of our available input parameters and output variables, see our
[Inputs and Outputs document][io-doc].
See also our [example recipes][recipes-doc].
## Used By
Microsoft
Apache
NASA
Samsung
TheAlgorithms
CachyOS
Nextcloud
Jupyter
NNStreamer
imgproxy
Zondax
AppNeta
Chocolate Doom
and many more.
## Example
### Annotations
Using [`file-annotations`][file-annotations]:
#### clang-format annotations
![clang-format annotations][format-annotations-preview]
#### clang-tidy annotations
![clang-tidy annotations][tidy-annotations-preview]
### Thread Comment
Using [`thread-comments`][thread-comments]:
![sample thread-comment][thread-comment-preview]
### Step Summary
Using [`step-summary`][step-summary]:
![step summary][step-summary-preview]
### Pull Request Review
#### Only clang-tidy
Using [`tidy-review`][tidy-review]:
![sample tidy-review][tidy-review-preview]
#### Only clang-format
Using [`format-review`][format-review]:
![sample format-review][format-review-preview]
![sample format-suggestion][format-suggestion-preview]
## Add C/C++ Linter Action badge in README
You can show C/C++ Linter Action status with a badge in your repository README
Example
```markdown
[](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml)
```
[](https://github.com/cpp-linter/cpp-linter-action/actions/workflows/cpp-linter.yml)
## Have question or feedback?
To provide feedback (requesting a feature or reporting a bug) please post to [issues](https://github.com/cpp-linter/cpp-linter-action/issues).
## Required tools installed
As of v2.16.0, this action uses
- [nushell] for cross-platform compatible scripting
- [uv] for driving a Python virtual environment
This action installs [nushell] and [uv] automatically.
Only [nushell] is added to the PATH environment variable.
[uv], and any standalone Python distribution it downloads, are not added to the PATH environment variable.
### On Linux runners
We only support Linux runners using a Debian-based Linux OS (like Ubuntu and many others).
This is because we first try to use the `apt` package manager to install clang tools.
Linux workflows that use a specific [`container`][gh-container-syntax] should ensure that
the following are installed:
- GLIBC (v2.32 or later)
- `wget` or `curl`
- `lsb-release` (required by LLVM-provided install script)
- `software-properties-common` (required by LLVM-provided install script)
- `gnupg` (required by LLVM-provided install script)
```shell
apt-get update
apt-get install -y libc6 wget lsb-release software-properties-common gnupg
```
Otherwise, [nushell] and/or the LLVM-provided bash script will fail to run.
### On macOS runners
The specified `version` of `clang-format` and `clang-tidy` is installed via Homebrew.
Failing that, we attempt to use static binaries that we built ourselves;
see [cpp-linter/clang-tools-pip] and [cpp-linter/clang-tools-static-binaries] projects for more detail.
### On Windows runners
For Windows runners, we only use clang tools built as static binaries.
See [cpp-linter/clang-tools-pip] and [cpp-linter/clang-tools-static-binaries] projects for more detail.
## License
The scripts and documentation in this project are released under the [MIT License](https://github.com/cpp-linter/cpp-linter-action/blob/main/LICENSE)
[nushell]: https://www.nushell.sh/
[uv]: https://docs.astral.sh/uv/
[cpp-linter/clang-tools-pip]: https://github.com/cpp-linter/clang-tools-pip
[cpp-linter/clang-tools-static-binaries]: https://github.com/cpp-linter/clang-tools-static-binaries
[gh-container-syntax]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainer