forked from learning-process/parallel_programming_course
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (147 loc) · 4.59 KB
/
static-analysis-pr.yml
File metadata and controls
164 lines (147 loc) · 4.59 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Static analysis
on:
pull_request:
paths:
- '**/*.cpp'
- '**/*.hpp'
- '**/*.c'
- '**/*.h'
- '**/CMakeLists.txt'
- '**/*.cmake'
- '**/.clang-tidy'
- '.github/workflows/static-analysis-pr.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: >-
${{ github.ref != 'refs/heads/master' &&
github.event_name != 'merge_group' &&
!startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
permissions:
contents: read
packages: read
jobs:
clang-tidy:
runs-on: ubuntu-24.04
container:
image: ghcr.io/learning-process/ppc-ubuntu:1.2
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-clang
create-symlink: true
max-size: 1G
- name: CMake configure
run: >
cmake -S . -B build -G Ninja
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON
env:
CC: clang-22
CXX: clang++-22
- name: Build project
run: |
cmake --build build --parallel -- --quiet
env:
CC: clang-22
CXX: clang++-22
- name: Show ccache stats
run: ccache --show-stats
- name: Run clang-tidy
uses: ./.github/actions/clang-tidy-native
id: review
with:
exclude: "3rdparty build"
clang_tidy_version: "22"
- if: steps.review.outputs.total_comments > 0
run: |
echo "clang-tidy run has failed. See previous 'Run clang-tidy' stage logs"
exit 1
clang-tidy-for-gcc-build:
needs:
- clang-tidy
runs-on: ubuntu-24.04
container:
image: ghcr.io/learning-process/ppc-ubuntu:1.2
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-gcc
create-symlink: true
max-size: 1G
- name: CMake configure
run: >
cmake -S . -B build -G Ninja
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON
env:
CC: gcc-14
CXX: g++-14
- name: Build project
run: |
cmake --build build --parallel -- --quiet
env:
CC: gcc-14
CXX: g++-14
- name: Show ccache stats
run: ccache --show-stats
- name: Run clang-tidy
uses: ./.github/actions/clang-tidy-native
id: review
with:
exclude: "3rdparty build docs_venv .git .pytest_cache .ruff_cache xml"
clang_tidy_version: "22"
- if: steps.review.outputs.total_comments > 0
run: |
echo "clang-tidy run has failed. See previous 'Run clang-tidy' stage logs"
exit 1
nolint-check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Search for linter suppression markers
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.sha }}
run: |
set -euo pipefail
CHANGED_FILES="$(git diff --name-only "$BASE_SHA"..."$HEAD_SHA" -- 'tasks/')"
if [ -z "$CHANGED_FILES" ]; then
echo "No changed files in tasks directory."
exit 0
fi
markers=(
"NOLINT::Found 'NOLINT'"
"IWYU[[:space:]]+pragma::Found 'IWYU pragma'"
"LCOV_EXCL_START::Found 'LCOV_EXCL_START'"
"LCOV_EXCL_STOP::Found 'LCOV_EXCL_STOP'"
"GCOVR_EXCL_LINE::Found 'GCOVR_EXCL_LINE'"
"GCOVR_EXCL_START::Found 'GCOVR_EXCL_START'"
"GCOVR_EXCL_STOP::Found 'GCOVR_EXCL_STOP'"
)
for file in $CHANGED_FILES; do
for marker in "${markers[@]}"; do
pattern="${marker%%::*}"
message="${marker#*::}"
if grep -Eq "$pattern" "$file"; then
echo "::error::${message} in $file."
exit 1
fi
done
done
echo "No linter suppression markers found in changed files."