Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/examples/only-PR-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
permissions: # (1)!
pull-requests: write
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7

# ... optionally setup build env to create a compilation database

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples/only-clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7

# ... optionally setup build env to create a compilation database

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples/only-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7

# ... optionally setup build env to create a compilation database

Expand Down
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[recipes-doc]: https://cpp-linter.github.io/cpp-linter-action/examples
[permissions-doc]: https://cpp-linter.github.io/cpp-linter-action/permissions
[app-token-doc]: https://cpp-linter.github.io/cpp-linter-action/permissions/#github-app-token
[skip-doc]: https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs

[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
Expand Down Expand Up @@ -48,8 +49,17 @@ Create a new GitHub Actions workflow in your project, e.g. at [.github/workflows
The content of the file should be in the following format.

```yaml
name: cpp-linter
on: pull_request

jobs:
cpp-linter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write # to post the thread comment
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v7
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
Expand All @@ -58,7 +68,8 @@ The content of the file should be in the following format.
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' }}
# Pull requests from forks get a read-only token, so skip the comment there.
thread-comments: ${{ github.event.pull_request.head.repo.full_name == github.repository && 'update' }}
Comment thread
2bndy5 marked this conversation as resolved.
- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
run: exit 1
Expand Down Expand Up @@ -92,14 +103,13 @@ the workspace to the pull request's head commit before it lints and commits.
> [!TIP]
> Commits pushed with the default `GITHUB_TOKEN` do not start new workflow runs,
> so CI does not re-check the auto-fix commit. To change that, check out and run
> the action with a [GitHub App token][app-token-doc]. To keep a particular
> auto-fix commit from re-running CI, add `[skip ci]` to its message:
> the action with a [GitHub App token][app-token-doc].
>
> ```yaml
> with:
> auto-fix: 'true'
> auto-fix-commit-msg: 'style: apply clang-format fixes [skip ci]'
> ```
> Do not add `[skip ci]` or any other [skip instruction][skip-doc] to
> `auto-fix-commit-msg`. The auto-fix commit becomes the head of the pull request,
> so its required checks skipped for `push` or `pull_request` events would stay
> pending and may cause a gap in quality control. A squash merge can also carry
> the instruction into your default branch.
>
> See [our documented permissions][permissions-doc] for the required scopes.

Expand All @@ -116,38 +126,29 @@ See [GitHub App token][app-token-doc] for the setup steps.
## Used By

<p align="center">
<a href="https://github.com/Microsoft"><img src="https://avatars.githubusercontent.com/u/6154722?s=200&v=4" alt="Microsoft" width="28"/></a>
<strong>Microsoft</strong>&nbsp;&nbsp;
<a href="https://github.com/apache"><img src="https://avatars.githubusercontent.com/u/47359?s=200&v=4" alt="Apache" width="28"/></a>
<strong>Apache</strong>&nbsp;&nbsp;
<a href="https://github.com/nasa"><img src="https://avatars.githubusercontent.com/u/848102?s=200&v=4" alt="NASA" width="28"/></a>
<strong>NASA</strong>&nbsp;&nbsp;
<a href="https://github.com/samsung"><img src="https://avatars.githubusercontent.com/u/6210390?s=200&v=4" alt="Samsung" width="28"/></a>
<strong>Samsung</strong>&nbsp;&nbsp;
<a href="https://github.com/TheAlgorithms"><img src="https://avatars.githubusercontent.com/u/20487725?s=200&v=4" alt="TheAlgorithms" width="28"/></a>
<strong>TheAlgorithms</strong>&nbsp;&nbsp;
<a href="https://github.com/bloomberg"><img src="https://avatars.githubusercontent.com/u/1416818?s=200&v=4" alt="Bloomberg" width="28"/></a>
<strong>Bloomberg</strong>&nbsp;&nbsp;
<a href="https://github.com/qualcomm"><img src="https://avatars.githubusercontent.com/u/55295994?s=200&v=4" alt="Qualcomm" width="28"/></a>
<strong>Qualcomm</strong>&nbsp;&nbsp;
<a href="https://github.com/nextcloud"><img src="https://avatars.githubusercontent.com/u/19211038?s=200&v=4" alt="Nextcloud" width="28"/></a>
<strong>Nextcloud</strong>&nbsp;&nbsp;
<a href="https://github.com/CachyOS"><img src="https://avatars.githubusercontent.com/u/85452089?s=200&v=4" alt="CachyOS" width="28"/></a>
<strong>CachyOS</strong>&nbsp;&nbsp;
</br>
<a href="https://github.com/nextcloud"><img src="https://avatars.githubusercontent.com/u/19211038?s=200&v=4" alt="Nextcloud" width="28"/></a>
<strong>Nextcloud</strong>&nbsp;&nbsp;
<a href="https://github.com/jupyter-xeus"><img src="https://avatars.githubusercontent.com/u/58793052?s=200&v=4" alt="Jupyter" width="28"/></a>
<strong>Jupyter</strong>&nbsp;&nbsp;
<a href="https://github.com/nnstreamer"><img src="https://avatars.githubusercontent.com/u/60992508?s=200&v=4" alt="NNStreamer" width="28"/></a>
<strong>NNStreamer</strong>&nbsp;&nbsp;
<a href="https://github.com/imgproxy"><img src="https://avatars.githubusercontent.com/u/48099924?s=200&v=4" alt="imgproxy" width="28"/></a>
<strong>imgproxy</strong>&nbsp;&nbsp;
<a href="https://github.com/Zondax"><img src="https://avatars.githubusercontent.com/u/34372050?s=200&v=4" alt="Zondax" width="28"/></a>
<strong>Zondax</strong>&nbsp;&nbsp;
<a href="https://github.com/AppNeta"><img src="https://avatars.githubusercontent.com/u/3374594?s=200&v=4" alt="AppNeta" width="28"/></a>
<strong>AppNeta</strong>&nbsp;&nbsp;
</br>
<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>
<strong>Chocolate Doom</strong>
<a href="https://github.com/bloomberg"><img src="https://avatars.githubusercontent.com/u/1416818?s=200&v=4" alt="Bloomberg" width="28"/></a>
<strong>Bloomberg</strong>
<a href="https://github.com/qualcomm"><img src="https://avatars.githubusercontent.com/u/55295994?s=200&v=4" alt="Qualcomm" width="28"/></a>
<strong>Qualcomm</strong>
<strong>Chocolate Doom</strong>&nbsp;&nbsp;
<strong> and <a href="https://github.com/cpp-linter/cpp-linter-action/network/dependents">many more</a>.</strong>
</p>

Expand Down
9 changes: 6 additions & 3 deletions docs/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ in addition to any other permissions needed for other features:
Commits pushed with the default `GITHUB_TOKEN` do not start new workflow
runs, so CI does not re-check the auto-fix commit. To change that, push
with a [GitHub App token](#github-app-token) or a personal access token
that has `contents: write`; add `[skip ci]` to
[`auto-fix-commit-msg`](./inputs-outputs.md#auto-fix-commit-msg) if a
particular auto-fix commit should not start a run.
that has `contents: write`. Do not add `[skip ci]` or any other
[skip instruction](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/skip-workflow-runs)
to [`auto-fix-commit-msg`](./inputs-outputs.md#auto-fix-commit-msg): the
auto-fix commit becomes the head of the pull request, so its required
checks skipped for `push` or `pull_request` events would stay
pending and may cause a gap in quality control.

Pull requests from forks are skipped with a warning: `GITHUB_TOKEN` cannot
push to the fork's branch, and fork pull requests receive no secrets, so an
Expand Down
Loading