-
-
Notifications
You must be signed in to change notification settings - Fork 162
215 lines (183 loc) · 6.34 KB
/
linux-static-analysis.yml
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: static-analysis
on:
push:
branches:
- '*'
paths-ignore:
- 'docs/**'
- '**/*.md'
- 'LICENSE'
workflow_dispatch:
pull_request:
paths-ignore:
- 'docs/**'
- '**/*.md'
- 'LICENSE'
jobs:
build_project:
name: ci-ubuntu-24.04-build-clang-static
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install Python dependencies
run: pip install -r .github/requirements.txt
- name: Install ccache
uses: hendrikmuhs/[email protected]
- name: Cache Conan packages
id: cache-conan
uses: actions/[email protected]
env:
cache-name: cache-conan-packages
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('conanfile.txt') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Configure Conan profiles
run: |
CC=clang-18 \
CXX=clang++-18 \
conan profile detect --force --name clang-18
- name: Install Conan dependencies
run: |
conan install conanfile.txt \
-r conancenter \
-pr:b clang-18 \
-pr:h clang-18 \
-s compiler.cppstd=20 \
-s build_type=Debug \
-o "*:shared=True" \
-c:b tools.build:compiler_executables="{'c': '/usr/bin/clang-18', 'cpp': '/usr/bin/clang++-18'}" \
-c:h tools.build:compiler_executables="{'c': '/usr/bin/clang-18', 'cpp': '/usr/bin/clang++-18'}" \
--build=missing \
- name: Configure CMake
run: |
cmake -S ${{github.workspace}} --preset=unixlike-clang-debug-static \
-DCMAKE_C_COMPILER=/usr/bin/clang-18 \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++-18 \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCODE_COVERAGE:BOOL=ON \
-DBUILD_TESTING:BOOL=ON \
-DUSE_SYSTEM_DEPENDENCIES:BOOL=ON \
-DUSE_STD_FORMAT:BOOL=ON \
-DCMAKE_TOOLCHAIN_FILE=build/Debug/generators/conan_toolchain.cmake \
-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld
- name: Build library and tests
run: cmake --build --preset=unixlike-clang-debug-static
- name: Build code coverage
run: cmake --build --preset=unixlike-clang-debug-static --target=faker-ccov-all
- name: Generate code coverage report
working-directory: ${{github.workspace}}/build/unixlike-clang-debug-static
run: |
llvm-cov-18 show `cat ccov/binaries.list` -instr-profile=ccov/all-merged.profdata > coverage.txt \
&& llvm-cov-18 report `cat ccov/binaries.list` -instr-profile=ccov/all-merged.profdata
- name: Upload code coverage report to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{github.workspace}}/build/unixlike-clang-debug-static
- name: Store build artifacts
uses: actions/upload-artifact@v4
with:
name: build-directory
path: ${{github.workspace}}/build
cppcheck:
name: cppcheck
runs-on: ubuntu-24.04
needs: build_project
outputs:
build_output: ${{ steps.build_project.outputs }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install and cache apt packages
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cppcheck
version: 1.0
- name: Download build directory
uses: actions/download-artifact@v4
with:
name: build-directory
path: build
- name: Run cppcheck
run: |
cppcheck \
--template=gcc \
--suppress=missingIncludeSystem \
--suppress=variableScope \
--suppress=cppcheckError \
--suppress=internalAstError \
--suppress=unmatchedSuppression \
--suppress=passedByValue \
--suppress=syntaxError \
--suppress=preprocessorErrorDirective \
--inconclusive \
-I src \
-I src/common \
-I src/modules \
-I include \
--std=c++20 \
--enable=style \
--enable=performance \
--enable=warning \
--enable=portability \
--inline-suppr \
--cppcheck-build-dir=build/unixlike-clang-debug-static \
--project=build/unixlike-clang-debug-static/compile_commands.json
clang_tidy:
name: clang-tidy
runs-on: ubuntu-24.04
needs: build_project
outputs:
build_output: ${{ steps.build_project.outputs }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Conan packages
id: cache-conan
uses: actions/cache/[email protected]
env:
cache-name: cache-conan-packages
with:
path: ~/.conan2
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('conanfile.txt') }}
- name: Download build directory
uses: actions/download-artifact@v4
with:
name: build-directory
path: build
- name: Run clang-tidy
- run: sudo apt-get update -y
- run: sudo apt-get install -y clang-tidy
- run: clang-tidy -p "build/unixlike-clang-debug-static" --header-filter="include/*|externals/fmt/test/gtest/gtest/*" -extra-arg="-std=gnu++20 --Wno-double-promotion"
clang_format:
name: clang-format
runs-on: ubuntu-24.04
needs: build_project
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download build directory
uses: actions/download-artifact@v4
with:
name: build-directory
path: build
- name: Configure python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install Python dependencies
run: pip install pre-commit
- name: Run clang-format
# FIXME: Ignore format errors for now
run: pre-commit run clang-format --all-files --color always --verbose || true