forked from learning-process/parallel_programming_course
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (128 loc) · 4 KB
/
static-analysis-pr.yml
File metadata and controls
139 lines (128 loc) · 4 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
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') }}
jobs:
clang-tidy:
runs-on: ubuntu-24.04
container:
image: ghcr.io/learning-process/ppc-ubuntu:1.1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v5
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_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
env:
CC: clang-21
CXX: clang++-21
- name: Build project
run: |
cmake --build build --parallel
env:
CC: clang-21
CXX: clang++-21
- name: Run clang-tidy
uses: ./.github/actions/clang-tidy-native
id: review
with:
exclude: "3rdparty build"
clang_tidy_version: "21"
- 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.1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v5
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_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
-D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
env:
CC: gcc-14
CXX: g++-14
- name: Build project
run: |
cmake --build build --parallel
env:
CC: gcc-14
CXX: g++-14
- 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: "21"
- 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@v5
- name: Search for linter suppression markers
run: |
export BASE_REF=${{ github.event.pull_request.base.ref }}
export CHANGED_FILES="$(git diff --name-only origin/$BASE_REF HEAD | grep '^tasks/')"
if [ -z "$CHANGED_FILES" ]; then
echo "No changed files in tasks directory."
exit 0
fi
for file in $CHANGED_FILES; do
if grep -n "NOLINT" "$file"; then
echo "::error::Found 'NOLINT' in $file."
exit 1
fi
if grep -En 'IWYU[[:space:]]+pragma' "$file"; then
echo "::error::Found 'IWYU pragma' in $file."
exit 1
fi
done
echo "No linter suppression markers found in changed files."