forked from N-Coder/ogdf
-
Notifications
You must be signed in to change notification settings - Fork 0
358 lines (342 loc) · 13 KB
/
check-build-test.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: Check, Build and Test
on:
pull_request:
push:
# # Debug setup:
# env:
# OGDF_UTILS_PREQUEL: "set -x"
# CCACHE_DEBUG: 1
# CCACHE_DEBUGDIR: ${{ github.workspace }}/ccache-debug
# VERBOSE: 1
jobs:
# We don't want to run the CI twice for PRs from branches within the repo, so for a push event we only run the CI if
# the push was to the master branch or to a fork of the repo, while running the CI for all (in- and cross-repo) PRs.
# Workflows skipped due to filters block PRs from being merged (their required jobs count as "pending"),
# while jobs skipped due to conditions still count as success, so we apply the filter here.
precheck:
name: "Check whether to run the CI"
runs-on: ubuntu-latest
if: github.event.repository.full_name != 'ogdf/ogdf' || github.event_name != 'push' || github.event.ref == 'refs/heads/master'
steps:
- run: echo "Running CI pipeline!"
style:
needs: [ precheck ]
name: "Check code style"
runs-on: ubuntu-latest
container: docker.io/ogdf/clang:15
steps:
- name: "Add workspace as a safe directory in containers"
run: git config --system --add safe.directory $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Run style checks
run: util/style/test_all.sh
- name: Generate patch with style fixes upon failure
run: |
echo "Please download the artifact and apply style-fixes.patch to fix code style problems."
util/style/test_all.sh -f
git diff > style-fixes.patch
git status
if: failure()
- name: Store patch with style fixes
uses: actions/upload-artifact@v4
if: failure()
with:
name: style-fixes
path: style-fixes.patch
dirs:
needs: [ precheck ]
name: "Check directory structure"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Test directory structure
run: util/test_directory_structure.sh
docs:
needs: [ precheck ]
name: "Check Doxygen"
runs-on: ubuntu-latest
container: docker.io/ogdf/clang:15
steps:
- uses: actions/checkout@v4
- run: util/test_doxygen.sh
self-sufficiency:
needs: [ precheck ]
name: "Test self-sufficiency"
runs-on: ubuntu-latest
env:
CCACHE_COMPILERCHECK: "%compiler% -v"
steps:
- uses: actions/checkout@v4
- name: Set-up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
- name: Test self-sufficiency
run: |
# the script calls gcc directly, so ensure that it finds the ccache version instead
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
util/test_self-sufficiency.sh
- uses: actions/upload-artifact@v4
name: Upload ccache debug info
if: ${{ env.CCACHE_DEBUG == 1 }}
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/ccache-debug
static-analysis:
name: "Static Analysis"
runs-on: ubuntu-latest
container: docker.io/ogdf/clang:15
needs: [ style, dirs, self-sufficiency, docs ]
env:
CCACHE_COMPILERCHECK: "%compiler% -v"
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
STEPS_CONTEXT: ${{ toJson(steps) }}
RUNNER_CONTEXT: ${{ toJson(runner) }}
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: |
env
- name: "Add workspace as a safe directory in containers"
run: git config --system --add safe.directory $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Set-up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
- name: Restore clang-tidy cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/.ctcache
key: clang-tidy-cache-${{ github.run_id }}.${{ github.run_attempt }}
restore-keys: clang-tidy-cache
- name: Run analysis
env:
CTCACHE_LOCAL: 1
CTCACHE_DIR: ${{ github.workspace }}/.ctcache
CTCACHE_SAVE_OUTPUT: 1
CTCACHE_IGNORE_OUTPUT: 1
# CTCACHE_DUMP: ${{ env.CCACHE_DEBUG }} # defining the var is enough to enable
# CTCACHE_DUMP_DIR: ${{ github.workspace }}/ctcache-debug
run: |
clang-tidy-cache --zero-stats
util/test_static_analysis.sh -DOGDF_ARCH=haswell -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cat static-analysis/clang-tidy.txt | python3 -m clang_tidy_converter sq > static-analysis/clang-tidy.json
clang-tidy-cache --show-stats
du -sh $CTCACHE_DIR
find .ctcache -mindepth 1 -type f -atime +7 -delete
find .ctcache -mindepth 1 -type d -empty -delete
du -sh $CTCACHE_DIR
shell: bash
- name: Report unused files
run: |
cat static-analysis/unused-headers.txt
- name: Save PR number
if: github.event_name == 'pull_request'
run: |
echo ${{ github.event.number }} > static-analysis/PR-NUMBER
- name: Store static analysis results
uses: actions/upload-artifact@v4
if: always()
with:
name: static-analysis
path: static-analysis/
- name: Clean binaries
run: |
cd build-static-analysis
make clean
- name: Store static analysis results
uses: actions/upload-artifact@v4
if: always()
with:
name: build-static-analysis
path: build-static-analysis/
- uses: actions/upload-artifact@v4
name: Upload ccache debug info
if: ${{ env.CCACHE_DEBUG == 1 || env.CTCACHE_DUMP == 1 }}
with:
name: ${{ github.job }}
path: |
${{ github.workspace }}/ccache-debug
${{ github.workspace }}/ctcache-debug
- name: Save clang-tidy cache
uses: actions/cache/save@v4
if: always()
with:
path: ${{ github.workspace }}/.ctcache
key: clang-tidy-cache-${{ github.run_id }}.${{ github.run_attempt }}
coverage:
name: "Analyze Test Coverage"
runs-on: ubuntu-latest
container: docker.io/ogdf/clang:18
needs: [ style, dirs, self-sufficiency, docs ]
env:
CCACHE_COMPILERCHECK: "%compiler% -v"
steps:
- name: "Add workspace as a safe directory in containers"
run: git config --system --add safe.directory $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Set-up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
- name: Run analysis
run: |
util/test_coverage.sh -DOGDF_ARCH=haswell -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
shell: bash
- name: Store coverage data
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage
path: coverage/
- uses: actions/upload-artifact@v4
name: Upload ccache debug info
if: ${{ env.CCACHE_DEBUG == 1 }}
with:
name: ${{ github.job }}
path: ${{ github.workspace }}/ccache-debug
build-linux:
name: "Test ${{ matrix.mode }} build on Linux with ${{ matrix.compiler }}"
strategy:
matrix: # when updating compilers, also update the prune-all-caches script
mode: [ debug, release ]
compiler: [ 'gcc:9', 'gcc:13', 'clang:15' ]
runs-on: ubuntu-latest
container: docker.io/ogdf/${{ matrix.compiler }}
needs: [ style, dirs, self-sufficiency, docs ]
env:
CCACHE_COMPILERCHECK: "%compiler% -v"
steps:
- name: Process compiler name
# artifact names may not contain colons and GHA has no string splitting function, so we do it in bash
run: |
S="${{ matrix.compiler }}"
A=(${S//:/ })
echo "GH_COMPILER_NAME=${A[0]}" >> "$GITHUB_ENV"
echo "GH_COMPILER_VER=${A[1]}" >> "$GITHUB_ENV"
shell: bash
- name: "Add workspace as a safe directory in containers"
run: git config --system --add safe.directory $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Set-up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.compiler }}-${{ matrix.mode }}
- name: Check ccache version
run: ccache --version
- name: Check CPU model
run: |
lscpu
echo "Hard limits"
ulimit -Ha
echo
echo "Soft limits"
ulimit -Sa
- name: Test ${{ matrix.mode }} build with ${{ matrix.compiler }} and run
run: |
util/test_build_and_run.sh \
${{ matrix.compiler == 'gcc:9' && 'dynamic' || 'static' }} \
${{ matrix.mode }} \
${{ env.GH_COMPILER_NAME }} \
default_s \
${{ matrix.compiler != 'clang:15' && '-DOGDF_INCLUDE_CGAL=ON -DOGDF_USE_ASSERT_EXCEPTIONS=ON' || '' }} \
-DOGDF_USE_ASSERT_EXCEPTIONS=ON -DOGDF_ARCH=haswell \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
# extra flags used when collecting coverage (on clang:15) are disabled here
# ---
# see "Cloud hosts used by GitHub-hosted runners" in the GH Actions docs
# for the oldest used microarchitecture to use with OGDF_ARCH
- uses: actions/upload-artifact@v4
name: Upload ccache debug info
if: ${{ env.CCACHE_DEBUG == 1 }}
with:
# artifact names may not contain colons, so we need to be more careful with the compiler variable
name: ${{ github.job }}-${{ env.GH_COMPILER_NAME }}-${{ env.GH_COMPILER_VER }}-${{ matrix.mode }}
path: ${{ github.workspace }}/ccache-debug
- name: Store failed test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-tests-logs-${{ github.job }}-${{ env.GH_COMPILER_NAME }}-${{ env.GH_COMPILER_VER }}-${{ matrix.mode }}
path: "./failed-tests-logs"
build-macos:
name: "Test ${{ matrix.mode }} build on ${{ matrix.os }}"
strategy:
matrix: # when updating macos versions, also update the prune-all-caches script
mode: [ debug, release ]
os: [ macos-13 ] # latest/14 is with M1, while macos-13 is intel
runs-on: ${{ matrix.os }}
needs: [ style, dirs, self-sufficiency, docs ]
steps:
- uses: actions/checkout@v4
- run: brew install coreutils findutils
- name: Set-up ccache
uses: hendrikmuhs/[email protected]
with:
key: build-${{ matrix.os }}-${{ matrix.mode }}
- name: Check CPU model
run: |
uname -av
sysctl machdep.cpu
system_profiler system_profiler SPSoftwareDataType SPHardwareDataType
echo "Hard limits"
ulimit -Ha
echo
echo "Soft limits"
ulimit -Sa
- name: Test ${{ matrix.mode }} build and run
run: |
util/test_build_and_run.sh \
static \
${{ matrix.mode }} \
default_c \
default_s \
-DOGDF_USE_ASSERT_EXCEPTIONS=ON -DOGDF_ARCH=ivybridge \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
# ivybridge is the oldest arch we encountered from SIGILL ccaching problems
- uses: actions/upload-artifact@v4
name: Upload ccache debug info
if: ${{ env.CCACHE_DEBUG == 1 }}
with:
name: build-${{ matrix.os }}-${{ matrix.mode }}
path: ${{ github.workspace }}/ccache-debug
- name: Store failed test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-tests-logs-build-${{ matrix.os }}-${{ matrix.mode }}
path: "./failed-tests-logs"
build-windows:
name: "Test ${{ matrix.mode }} build on Windows"
strategy:
matrix:
mode: [ debug, release ]
runs-on: windows-latest
needs: [ style, dirs, self-sufficiency, docs ]
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Set-up ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}-${{ matrix.mode }}
- name: Test ${{ matrix.mode }} build and run
run: powershell util\test_build_and_run.ps1 ${{ matrix.mode == 'debug' && '-debug' }}
env:
CMAKE_C_COMPILER_LAUNCHER: ccache.exe
CMAKE_CXX_COMPILER_LAUNCHER: ccache.exe
- uses: actions/upload-artifact@v4
name: Upload ccache debug info
if: ${{ env.CCACHE_DEBUG == 1 }}
with:
name: ${{ github.job }}-${{ matrix.mode }}
path: ${{ github.workspace }}/ccache-debug
# this is mostly used to keep the required status checks for PR merging simple
summary:
needs: [ build-linux, build-macos, build-windows, static-analysis, coverage ]
name: "All tests succeeded"
runs-on: ubuntu-latest
steps:
- run: echo "Everything worked!"