-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 2.19 KB
/
cpp-linter.yml
File metadata and controls
68 lines (58 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Taken mostly from https://cpp-linter.github.io/cpp-linter-action/examples/
name: cpp-linter
on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize, ready_for_review]
push:
branches: [main]
jobs:
cpp-linter:
# only run on non-draft PRs, this will skip the job for drafts and report success, but drafts can not be merged anyway
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v5
# Detect if any relevant files changed
- name: Detect relevant files
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
cpp:
- '**/*.c'
- '**/*.cpp'
- '**/*.h'
- '**/*.hpp'
- '**/*.cxx'
- '**/*.hxx'
- '**/*.cc'
- '**/*.hh'
- '**/CMakeLists.txt'
- 'meson.build'
- '**/*.cmake'
# ... optionally setup build env to create a compilation database
- name: Run cpp-linter
id: linter
uses: cpp-linter/cpp-linter-action@v2
if: steps.filter.outputs.cpp == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: 21 # default is 18
style: 'file' # Use .clang-format config file.
tidy-checks: '-*' # disable clang-tidy checks.
# only 'update' a single comment in a pull request's thread.
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }}
# disable file annotations, the thread comment should be the response
file-annotations: false
# Fail the job only if the linter ran and found issues
- name: Fail fast if linter failed
if: steps.filter.outputs.cpp == 'true' && steps.linter.outputs.checks-failed > 0
run: exit 1
# Optional: print a message if no relevant files changed
- name: Skip message
if: steps.filter.outputs.cpp != 'true'
run: echo "No relevant C/C++/CMake files changed — cpp-linter skipped"