-
Notifications
You must be signed in to change notification settings - Fork 2
466 lines (399 loc) · 15.7 KB
/
test-cpp.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
name: C++ Code Checks
on:
push:
branches: [ "master" ]
pull_request:
workflow_dispatch:
jobs:
Code-Coverage:
name: Code Coverage
runs-on: ubuntu-22.04
# Suddenly, the upload to codecov does not work anymore and times out after 6 hours -.-.
# It's not like I used it much anyway, except to have a badge.
if: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: |
sudo apt-get -y install bzip2 cppcheck clang clang-tidy g++ lcov ninja-build wget gzip tabix pigz gztool libarchive-dev zlib1g-dev isal nasm
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: System Information
run: |
nproc
cmake --version
g++ --version
clang++ --version
cppcheck --version
- name: Code Coverage
run: |
mkdir -p build-codeov && cd -- "$_"
# It should be compiled with the same g++ version as anylzed with gcov!
# If g++ --version and gcov --version print different versions, there might be problems when creating
# the coverage report, e.g., I had: "version 'A85*', prefer 'B12*'".
# It is possible to specify a different gcov version to lcov using, e.g., lcov --gcov-tool gcov-8.
# For me it compiled with g++-8 but used gcov-11 by default!
CXX=g++ CC=gcc cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON -DCMAKE_CXX_FLAGS="-DSHORT_TESTS" ..
cmake --build . -- check
lcov --capture --directory . --base-directory "$( cd .. && pwd )" --no-external --output-file coverage.info
lcov --list coverage.info
bash <( wget -O- -q https://codecov.io/bash ) -f coverage.info
- name: Run cppcheck
# Crashes on templated variable REVERSED_BITS_LUT<T>[value] (internalAstError)
if: false
run: |
set -o pipefail
cppcheck -j $( nproc ) --enable=all --std=c++17 --suppress=unusedFunction --suppress=useStlAlgorithm \
-I src/core \
-I src/indexed_bzip2 \
-I src/rapidgzip \
-I src/rapidgzip/huffman \
src/benchmarks \
src/core \
src/indexed_bzip2 \
src/rapidgzip \
src/tests \
src/tools 2>&1 | tee cppcheck.log
if grep -E -i 'error: .* \[[^]]*\]$' cppcheck.log; then
echo -e '\e[31mThere were errors while running cppcheck!\e[0m'
exit 1
fi
Clang-Tidy:
name: Clang-Tidy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: |
sudo apt-get -y install clang clang-tidy ninja-build libarchive-dev zlib1g-dev nasm
- name: Run clang-tidy
run: |
mkdir -p build-compile-commands && cd -- "$_"
CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DUSE_SYSTEM_ZLIB=ON -DRUN_CLANG_TIDY=ON ..
cmake --build .
Check:
name: Check without Sanitizer
# And especially without -DSHORT_TESTS, which makes it non redundant to the sanitizer checks!
runs-on: ubuntu-22.04
strategy:
matrix:
use_system_zlib: [ON, OFF]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: |
sudo apt-get -y install g++ ninja-build gzip tabix pigz gztool libarchive-dev zlib1g-dev isal nasm
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: Run Tests With Sanitizers
env:
USE_SYSTEM_ZLIB: ${{ matrix.use_system_zlib }}
run: |
mkdir -p "build" && cd -- "$_"
CXX=g++ CC=gcc cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DWITH_ISAL=ON -DUSE_SYSTEM_ZLIB=$USE_SYSTEM_ZLIB ..
cmake --build . -- check
Check-Without-Isal:
name: Check without Sanitizer and without ISA-L
# And especially without -DSHORT_TESTS, which makes it non redundant to the sanitizer checks!
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-12, macos-13, windows-latest]
env:
MACOSX_DEPLOYMENT_TARGET: "10.15"
steps:
- name: System Information
if: "! startsWith(matrix.os, 'windows')"
run: |
uname -a
- name: Print Architecture
if: "startsWith(matrix.os, 'macos')"
run: |
sysctl -n machdep.cpu.brand_string
arch
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Install System Dependencies
if: "startsWith(matrix.os , 'macos')"
run: |
brew install ninja pigz zlib isa-l wget
wget 'https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2'
tar -xf htslib-1.20.tar.bz2
cd htslib* && ./configure && make install
- name: Install System Dependencies
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sudo apt-get -y install g++ ninja-build gzip tabix pigz gztool libarchive-dev zlib1g-dev isal
- name: Fix pip
if: "startsWith(matrix.os , 'macos')"
run: |
mkdir -p "$HOME/Library/Application Support/pip"
cat <<EOF >> "$HOME/Library/Application Support/pip/pip.conf"
[global]
break-system-packages = true
EOF
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'ubuntu')"
run: |
mkdir -p "build" && cd -- "$_"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DWITH_ISAL=OFF -DUSE_SYSTEM_ZLIB=OFF ..
cmake --build . -- check
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'macos')"
run: |
# For some reason MacOS ARM is much slower and runs into a timeout without -DSHORT_TESTS :/
mkdir -p "build" && cd -- "$_"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DWITH_ISAL=OFF -DUSE_SYSTEM_ZLIB=OFF -DCMAKE_CXX_FLAGS="-DSHORT_TESTS" ..
cmake --build . -- check
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'windows')"
run: |
mkdir -p "build" && cd -- "build"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DWITH_ISAL=OFF ..
cmake --build . -- check
Asan:
name: ASan
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install System Dependencies
if: "startsWith(matrix.os , 'macos')"
run: |
brew install ninja pigz zlib isa-l wget nasm
wget 'https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2'
tar -xf htslib-1.20.tar.bz2
cd htslib* && ./configure && make install
- name: Install System Dependencies
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sudo apt-get -y install clang g++ ninja-build gzip tabix pigz gztool libarchive-dev zlib1g-dev isal nasm
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'macos')"
run: |
sanitizer=address
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
cmake -G Ninja -DWITH_ISAL=OFF -DUSE_SYSTEM_ZLIB=OFF -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- check
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sanitizer=address
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
CXX=clang++ CC=clang cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- check
cmake --build .
bash ../src/tests/testRapidgzip.sh
UBSan:
name: UBSan
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install System Dependencies
if: "startsWith(matrix.os , 'macos')"
run: |
brew install ninja pigz zlib isa-l wget nasm
wget 'https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2'
tar -xf htslib-1.20.tar.bz2
cd htslib* && ./configure && make install
- name: Install System Dependencies
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sudo apt-get -y install clang g++ ninja-build gzip tabix pigz gztool libarchive-dev zlib1g-dev isal nasm
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'macos')"
run: |
sanitizer=undefined
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
cmake -G Ninja -DWITH_ISAL=OFF -DUSE_SYSTEM_ZLIB=OFF -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- testParallelGzipReader
src/tests/rapidgzip/testParallelGzipReader
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sanitizer=undefined
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
CXX=clang++ CC=clang cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- check
Safe-Stack:
name: Safe-Stack
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install System Dependencies
if: "startsWith(matrix.os , 'macos')"
run: |
brew install ninja pigz zlib isa-l wget nasm gcc
wget 'https://github.com/samtools/htslib/releases/download/1.20/htslib-1.20.tar.bz2'
tar -xf htslib-1.20.tar.bz2
cd htslib* && ./configure && make install
- name: Install System Dependencies
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sudo apt-get -y install clang g++ ninja-build gzip tabix pigz gztool libarchive-dev zlib1g-dev isal nasm
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'macos')"
run: |
sanitizer=address
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
CXX=g++ CC=gcc cmake -G Ninja -DWITH_ISAL=OFF -DUSE_SYSTEM_ZLIB=OFF -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- testParallelGzipReader
src/tests/rapidgzip/testParallelGzipReader
- name: Run Tests With Sanitizers
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sanitizer=safe-stack
mkdir -p "build-sanitized-$sanitizer" && cd -- "$_"
CXX=clang++ CC=clang cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=$sanitizer -DSHORT_TESTS" ..
cmake --build . -- check
TSan:
name: TSan
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: |
sudo apt-get -y install clang g++ ninja-build gzip tabix pigz gztool libarchive-dev zlib1g-dev isal nasm
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade-strategy eager --upgrade indexed_gzip pgzip
- name: Run Tests With Thread Sanitizer
run: |
sanitized=thread
mkdir -p "build-sanitized-$sanitized" && cd -- "$_"
#
# TSAN in clang 10 and 11 shows false positives in condition variables:
# https://github.com/google/sanitizers/issues/1259
# Similar false positives appear with GCC 10.
# NO warnings appear with: GCC 8, 9 and clang 12,
# so I'm pretty sure that these are the referenced false positives.
clangMajorVersion=$( clang++ --version | sed -n -E 's|.* ([0-9]+)[.][0-9]+[.][0-9]+.*|\1|p' | head -1 )
if [[ ( "$sanitized" == thread ) && ( "$clangMajorVersion" -le 11 ) ]]; then
g++ --version
gccMajorVersion=$( g++ --version | sed -n -E 's|.* ([0-9]+)[.][0-9]+[.][0-9]+.*|\1|p' | head -1 )
if [[ "$gccMajorVersion" -ge 10 ]]; then
echo "Could not find a compiler version without known false positives. Skipping TSAN."
continue
fi
CXX=g++
CC=gcc
else
CXX=clang++
CC=clang
fi
export CC CXX
#
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fsanitize=$sanitized -DSHORT_TESTS" ..
cmake --build . -- check
Code-Checks:
name: Check with Infer
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: |
sudo apt-get -y install ninja-build wget nasm
# Install infer
VERSION=1.1.0
wget -q -O- "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" | tar -xJ
echo "$PWD/infer-linux64-v$VERSION/bin" >> $GITHUB_PATH
- name: Run infer
run: |
mkdir -p build-compile-commands && cd -- "$_"
CC=clang CXX=clang++ cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
infer run --report-blacklist-path-regex '.*testParallelBitStringFinder.cpp' --compilation-database compile_commands.json
Ibzip2-Tests:
name: Ibzip2 Tests
# And especially without -DSHORT_TESTS, which makes it non redundant to the sanitizer checks!
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-13, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Install System Dependencies
if: "startsWith(matrix.os , 'macos')"
run: |
brew install ninja
- name: Install System Dependencies
if: "startsWith(matrix.os , 'ubuntu')"
run: |
sudo apt-get -y install g++ ninja-build
- name: Fix pip
if: "startsWith(matrix.os , 'macos')"
run: |
mkdir -p "$HOME/Library/Application Support/pip"
cat <<EOF >> "$HOME/Library/Application Support/pip/pip.conf"
[global]
break-system-packages = true
EOF
- name: Install Python Dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build
- name: Install indexed_bzip2
working-directory: python/indexed_bzip2
shell: bash
run: |
python3 -m build
python3 -m pip install dist/*.tar.gz
- name: Run Standard Tests
shell: bash
# At this step, indexed_bzip2 should be installed.
run: |
mkdir -p build-ibzip2 && cd -- "$_"
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DWITH_ISAL=OFF ..
cmake --build . -- ibzip2
set -o pipefail
bash ../src/tests/testIbzip2.sh | tee run-standard-tests.log
if grep -i 'failed' run-standard-tests.log; then
echo -e '\e[31mThere were errors while running the tests!\e[0m'
exit 1
fi