summaryrefslogtreecommitdiff
path: root/.github/workflows/cmake.yml
blob: d5283761e9018af86b9cbf1311a1c137225284f3 (plain)
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
name: CI CMake
on: [push, pull_request]
jobs:
  ci-cmake:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: Ubuntu 18.04 GCC
            os: ubuntu-18.04
            compiler: gcc

          - name: Ubuntu GCC
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_SANITIZER=Address
            codecov: ubuntu_gcc

          - name: Ubuntu GCC OSB -O1 No Unaligned64
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_UNALIGNED=ON -DUNALIGNED64_OK=OFF -DWITH_SANITIZER=Undefined
            build-dir: ../build
            build-src-dir: ../zlib-ng
            codecov: ubuntu_gcc_osb
            cflags: -O1 -g3

          - name: Ubuntu GCC -O3 No Unaligned
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_UNALIGNED=OFF
            codecov: ubuntu_gcc_o3
            cflags: -O3

          - name: Ubuntu GCC No CTZLL
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_OPTIM=OFF -DHAVE_BUILTIN_CTZLL=OFF
            codecov: ubuntu_gcc_no_ctzll

          - name: Ubuntu GCC No CTZ
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_OPTIM=OFF -DHAVE_BUILTIN_CTZLL=OFF -DHAVE_BUILTIN_CTZ=OFF
            codecov: ubuntu_gcc_no_ctz

          - name: Ubuntu GCC Link Zlib
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DZLIB_DUAL_LINK=ON

          - name: Ubuntu GCC No AVX2
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_AVX2=OFF -DWITH_SANITIZER=Undefined
            codecov: ubuntu_gcc_no_avx2

          - name: Ubuntu GCC No SSE2
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_SSE2=OFF -DWITH_SANITIZER=Undefined
            codecov: ubuntu_gcc_no_sse2

          - name: Ubuntu GCC No SSE4
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_SSE4=OFF -DWITH_SANITIZER=Undefined
            codecov: ubuntu_gcc_no_sse4

          - name: Ubuntu GCC No PCLMULQDQ
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DWITH_PCLMULQDQ=OFF -DWITH_SANITIZER=Undefined
            codecov: ubuntu_gcc_no_pclmulqdq

          - name: Ubuntu GCC Compat No Opt
            os: ubuntu-latest
            compiler: gcc
            cmake-args: -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Address
            codecov: ubuntu_gcc_compat_no_opt
            cflags: -DNOT_TWEAK_COMPILER

          - name: Ubuntu GCC ARM SF
            os: ubuntu-latest
            compiler: arm-linux-gnueabi-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
            qemu-run: qemu-arm
            codecov: ubuntu_gcc_armsf

          - name: Ubuntu GCC ARM SF Compat No Opt
            os: ubuntu-latest
            compiler: arm-linux-gnueabi-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabi -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
            qemu-run: qemu-arm
            codecov: ubuntu_gcc_armsf_compat_no_opt

          - name: Ubuntu GCC ARM HF
            os: ubuntu-latest
            compiler: arm-linux-gnueabihf-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-arm-linux-gnueabihf libc-dev-armel-cross
            qemu-run: qemu-arm
            codecov: ubuntu_gcc_armhf

          - name: Ubuntu GCC ARM HF No ACLE
            os: ubuntu-latest
            compiler: arm-linux-gnueabihf-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_ACLE=OFF -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-arm-linux-gnueabihf libc-dev-armel-cross
            qemu-run: qemu-arm
            codecov: ubuntu_gcc_armhf_no_acle

          - name: Ubuntu GCC ARM HF No NEON
            os: ubuntu-latest
            compiler: arm-linux-gnueabihf-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DWITH_NEON=OFF -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-arm-linux-gnueabihf libc-dev-armel-cross
            qemu-run: qemu-arm
            codecov: ubuntu_gcc_armhf_no_neon

          - name: Ubuntu GCC ARM HF Compat No Opt
            os: ubuntu-latest
            compiler: arm-linux-gnueabihf-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm.cmake -DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-arm-linux-gnueabihf libc-dev-armel-cross
            qemu-run: qemu-arm
            codecov: ubuntu_gcc_armhf_compat_no_opt

          - name: Ubuntu GCC AARCH64
            os: ubuntu-latest
            compiler: aarch64-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
            qemu-run: qemu-aarch64
            codecov: ubuntu_gcc_aarch64

          - name: Ubuntu GCC AARCH64 No ACLE
            os: ubuntu-latest
            compiler: aarch64-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_ACLE=OFF -DWITH_SANITIZER=Undefined
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
            qemu-run: qemu-aarch64
            codecov: ubuntu_gcc_aarch64_no_acle

          - name: Ubuntu GCC AARCH64 No NEON
            os: ubuntu-latest
            compiler: aarch64-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DWITH_NEON=OFF -DWITH_SANITIZER=Undefined
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
            qemu-run: qemu-aarch64
            codecov: ubuntu_gcc_aarch64_no_neon

          - name: Ubuntu GCC AARCH64 Compat No Opt
            os: ubuntu-latest
            compiler: aarch64-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-aarch64.cmake -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF -DWITH_SANITIZER=Undefined
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
            qemu-run: qemu-aarch64
            codecov: ubuntu_gcc_aarch64_compat_no_opt

          - name: Ubuntu GCC PPC
            os: ubuntu-latest
            compiler: powerpc-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc.cmake
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross
            qemu-run: qemu-ppc
            ldflags: -static
            codecov: ubuntu_gcc_ppc

          - name: Ubuntu GCC PPC64
            os: ubuntu-latest
            compiler: powerpc64-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64.cmake
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
            qemu-run: qemu-ppc64
            ldflags: -static
            codecov: ubuntu_gcc_ppc64

          - name: Ubuntu GCC PPC64LE
            os: ubuntu-latest
            compiler: powerpc64le-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-powerpc64le.cmake
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
            qemu-run: qemu-ppc64le
            codecov: ubuntu_gcc_ppc64le

          - name: Ubuntu GCC SPARC64
            os: ubuntu-latest
            compiler: sparc64-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-sparc64.cmake
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-sparc64-linux-gnu libc-dev-sparc64-cross
            qemu-run: qemu-sparc64
            ldflags: -static
            codecov: ubuntu_gcc_sparc64

          - name: Ubuntu GCC S390X
            os: ubuntu-latest
            compiler: s390x-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
            qemu-run: qemu-s390x
            ldflags: -static
            codecov: ubuntu_gcc_s390x

          - name: Ubuntu GCC S390X DFLTCC
            os: ubuntu-latest
            compiler: s390x-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DWITH_DFLTCC_DEFLATE=ON -DWITH_DFLTCC_INFLATE=ON -DWITH_SANITIZER=Address
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
            qemu-run: qemu-s390x
            ldflags: -static
            codecov: ubuntu_gcc_s390x

          - name: Ubuntu GCC S390X DFLTCC Compat
            os: ubuntu-latest
            compiler: s390x-linux-gnu-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-s390x.cmake -DZLIB_COMPAT=ON -DWITH_DFLTCC_DEFLATE=ON -DWITH_DFLTCC_INFLATE=ON -DWITH_SANITIZER=Undefined
            asan-options: detect_leaks=0
            packages: qemu qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
            qemu-run: qemu-s390x
            ldflags: -static
            codecov: ubuntu_gcc_s390x

          - name: Ubuntu MinGW i686
            os: ubuntu-latest
            compiler: i686-w64-mingw32-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-i686.cmake
            packages: wine32 gcc-mingw-w64
            codecov: ubuntu_gcc_mingw_i686
            # Limit parallel test jobs to prevent wine errors
            parallels-jobs: 1

          - name: Ubuntu MinGW x86_64
            os: ubuntu-latest
            compiler: x86_64-w64-mingw32-gcc
            cmake-args: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-x86_64.cmake
            packages: wine-stable gcc-mingw-w64
            codecov: ubuntu_gcc_mingw_x86_64
             # Limit parallel test jobs to prevent wine errors
            parallels-jobs: 1

          - name: Ubuntu 18.04 Clang
            os: ubuntu-18.04
            compiler: clang-6.0
            packages: clang-6.0

          - name: Ubuntu Clang
            os: ubuntu-latest
            compiler: clang-11
            packages: llvm-11-tools
            gcov-exec: llvm-cov-11 gcov
            codecov: ubuntu_clang

          - name: Ubuntu Clang Inflate Strict
            os: ubuntu-latest
            compiler: clang-11
            cmake-args: -DWITH_INFLATE_STRICT=ON
            packages: llvm-11-tools
            gcov-exec: llvm-cov-11 gcov
            codecov: ubuntu_clang_inflate_strict

          - name: Ubuntu Clang Inflate Allow Invalid Dist
            os: ubuntu-latest
            compiler: clang-11
            cmake-args: -DWITH_INFLATE_ALLOW_INVALID_DIST=ON
            packages: llvm-11-tools
            gcov-exec: llvm-cov-11 gcov
            codecov: ubuntu_clang_inflate_allow_invalid_dist

          - name: Ubuntu Clang Memory Map
            os: ubuntu-latest
            compiler: clang-11
            cflags: -DUSE_MMAP
            packages: llvm-11-tools
            gcov-exec: llvm-cov-11 gcov
            codecov: ubuntu_clang_mmap

          - name: Ubuntu Clang Debug
            os: ubuntu-latest
            compiler: clang-11
            packages: llvm-11-tools
            gcov-exec: llvm-cov-11 gcov
            codecov: ubuntu_clang_debug
            build-config: Debug

          - name: Ubuntu Clang MSAN
            os: ubuntu-latest
            compiler: clang-11
            cmake-args: -GNinja -DWITH_SANITIZER=Memory
            packages:  ninja-build llvm-11-tools
            gcov-exec: llvm-cov-11 gcov
            cflags: -g3 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize-memory-track-origins
            codecov: ubuntu_clang_msan

          - name: Windows MSVC Win32
            os: windows-latest
            compiler: cl
            cmake-args: -A Win32

          - name: Windows MSVC Win64
            os: windows-latest
            compiler: cl
            cmake-args: -A x64

          - name: Windows MSVC ARM No Test
            os: windows-latest
            compiler: cl
            cmake-args: -A ARM

          - name: Windows MSVC ARM64 No Test
            os: windows-latest
            compiler: cl
            cmake-args: -A ARM64

          - name: Windows GCC
            os: windows-latest
            compiler: gcc
            cmake-args: -G Ninja
            codecov: win64_gcc

          - name: Windows GCC Compat No Opt
            os: windows-latest
            compiler: gcc
            cmake-args: -G Ninja -DZLIB_COMPAT=ON -DWITH_NEW_STRATEGIES=OFF -DWITH_OPTIM=OFF
            codecov: win64_gcc_compat_no_opt

          - name: macOS Clang
            os: macos-latest
            compiler: clang
            cmake-args: -DWITH_SANITIZER=Address
            codecov: macos_clang

          - name: macOS GCC
            os: macos-latest
            compiler: gcc-10
            cmake-args: -DWITH_SANITIZER=Undefined
            packages: gcc@10
            gcov-exec: gcov-10
            codecov: macos_gcc

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Checkout test corpora
      uses: actions/checkout@v2
      # Don't test against all corpora with MinGW due to Wine being unable to run parallel jobs
      # without connection timeout. Without parallel jobs test runs using Wine take close to an hour.
      if: contains(matrix.name, 'MinGW') == false
      with:
        repository: zlib-ng/corpora
        path: test/data/corpora

    - name: Install packages (Ubuntu)
      if: runner.os == 'Linux' && matrix.packages
      run: |
        sudo dpkg --add-architecture i386 # Required for wine32
        sudo apt-add-repository ppa:ondrej/php -y
        sudo apt-get update
        sudo apt-get install -y ${{ matrix.packages }}

    - name: Install packages (Windows)
      if: runner.os == 'Windows'
      run: |
        choco install ninja ${{ matrix.packages }} --no-progress

    - name: Install packages (macOS)
      if: runner.os == 'macOS'
      run: |
        brew install ninja ${{ matrix.packages }}
      env:
        HOMEBREW_NO_INSTALL_CLEANUP: 1

    - name: Install codecov.io tools
      if: matrix.codecov
      run: |
        python -u -m pip install codecov

    - name: Initialize Wine
      # Prevent parallel test jobs from initializing Wine at the same time
      if: contains(matrix.packages, 'wine')
      run: |
        wineboot --init

    - name: Generate project files
      # Shared libraries turned off for qemu ppc* and sparc & reduce code coverage sources
      run: |
        mkdir ${{ matrix.build-dir || '.not-used' }}
        cd ${{ matrix.build-dir || '.' }}
        cmake ${{ matrix.build-src-dir || '.' }} ${{ matrix.cmake-args }} -DCMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DBUILD_SHARED_LIBS=OFF -DWITH_FUZZERS=ON -DWITH_CODE_COVERAGE=ON -DWITH_MAINTAINER_WARNINGS=ON
      env:
        CC: ${{ matrix.compiler }}
        CFLAGS: ${{ matrix.cflags }}
        LDFLAGS: ${{ matrix.ldflags }}
        CI: true

    - name: Compile source code
      run: |
        cd ${{ matrix.build-dir || '.' }}
        cmake --build . --config ${{ matrix.build-config || 'Release' }}

    - name: Run test cases
      # Don't run tests on Windows ARM
      if: runner.os != 'Windows' || contains(matrix.name, 'ARM') == false
      run: |
        cd ${{ matrix.build-dir || '.' }}
        ctest --verbose -C Release --output-on-failure --max-width 120 -j ${{ matrix.parallels-jobs || '6' }}
      env:
        ASAN_OPTIONS: ${{ matrix.asan-options || 'verbosity=0' }}:abort_on_error=1
        MSAN_OPTIONS: ${{ matrix.msan-options || 'verbosity=0' }}:abort_on_error=1
        TSAN_OPTIONS: ${{ matrix.tsan-options || 'verbosity=0' }}:abort_on_error=1
        LSAN_OPTIONS: ${{ matrix.lsan-options || 'verbosity=0' }}:abort_on_error=1
        QEMU_RUN: ${{ matrix.qemu-run }}

    - name: Upload coverage report
      if: matrix.codecov && ( env.CODECOV_TOKEN_SECRET != '' || github.repository == 'zlib-ng/zlib-ng' )
      shell: bash
      run: |
        bash tools/codecov-upload.sh
      env:
        # Codecov does not yet support GitHub Actions
        CODECOV_TOKEN_SECRET: "${{secrets.CODECOV_TOKEN}}"
        CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN || 'e4fdf847-f541-4ab1-9d50-3d27e5913906' }}"
        CODECOV_FLAGS: "${{ matrix.codecov }}"
        CODECOV_NAME:  "${{ matrix.name }}"
        CODECOV_EXEC:  "${{ matrix.gcov-exec || 'gcov' }}"
        CODECOV_DIR:   "${{ matrix.build-dir || '.' }}"

    - name: Upload build errors
      uses: actions/upload-artifact@v2
      if: failure()
      with:
        name: ${{ matrix.name }} (cmake)
        path: |
          ${{ matrix.build-dir || '.' }}/CMakeFiles/CMakeOutput.log
          ${{ matrix.build-dir || '.' }}/CMakeFiles/CMakeError.log
          ${{ matrix.build-dir || '.' }}/Testing/Temporary/*
        retention-days: 30