summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 76c4c7287c68f32bd0a6ff4552141e03a2417369 (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
459
460
461
462
# Known issues:
# - This test script ignores exit code of cppcheck which can see under
#   Job:Linux x64 scan-build + cppcheck in the GitHub Actions report.
#   Because this project doesn't 100% follow their recommendation.
#   Also sometimes it reports false positives.
#
# Notes:
# - You can investigate various information at the right pane of GitHub
#   Actions report page.
#
#   | Item                      | Section in the right pane             |
#   | ------------------------- | ------------------------------------- |
#   | OS, VM                    | Set up job                            |
#   | git repo, commit hash     | Run actions/checkout@v2               |
#   | gcc, tools                | Environment info                      |
#
# - To fail earlier, order of tests in the same job are roughly sorted by
#   elapsed time.
#
# Tests which we still leave at travis-ci
# - name: Compile OSS-Fuzz targets
# - name: tag build
# - name: aarch64 real-hw tests
# - name: PPC64LE real-hw tests
# - name: IBM s390x real-hw tests


# Name of the workflow is also displayed as a SVG badge
name: lz4 CI

on: [push, pull_request]

jobs:
  # CI Environment information
  #
  # - "ubuntu-latest" (Ubuntu 20.04) has the following software
  #   https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md
  basic-env-info:
    name: Linux x64 Environment Info (ubuntu-latest)
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: gcc
      run: echo && gcc --version

    - name: clang
      run: echo && clang --version

    - name: make
      run: echo && make -v

    - name: gcc packages
      run: apt-cache search gcc | grep "^gcc-[0-9\.]* " | sort

    - name: clang packages
      run: apt-cache search clang | grep "^clang-[0-9\.]* " | sort

    - name: QEMU packages
      run: apt-cache search qemu | grep "^qemu-system-.*QEMU full system" | sort

    - name: git
      run: echo && git --version

    - name: g++
      run: echo && g++ --version


  # travis-ci: (Precise) benchmark test
  ubuntu-benchmark:
    name: Linux x64 benchmark test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: benchmark
      run: |
        make -C tests test-lz4 test-lz4c test-fullbench


  # travis-ci: Custom LZ4_DISTANCE_MAX ; lz4-wlib (CLI linked to dynamic library); LZ4_USER_MEMORY_FUNCTIONS
  ubuntu-custom-distance:
    name: Linux x64 Custom LZ4_DISTANCE_MAX
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: custom LZ4_DISTANCE_MAX
      run: |
        MOREFLAGS=-DLZ4_DISTANCE_MAX=8000 make check
        make clean
        make -C programs lz4-wlib
        make clean
        make -C tests fullbench-wmalloc  # test LZ4_USER_MEMORY_FUNCTIONS
        make clean
        CC="c++ -Wno-deprecated" make -C tests fullbench-wmalloc  # stricter function signature check


  # travis-ci: (Precise) frame and fuzzer test
  ubuntu-frame-and-fuzzer:
    name: Linux x64 frame and fuzzer test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo sysctl -w vm.mmap_min_addr=4096
    - name: frame + fuzzer test
      run: |
        make -C tests test-frametest test-fuzzer


  # travis-ci: (Trusty) i386 frame + fuzzer test
  ubuntu-i386-frame-and-fuzzer:
    name: Linux x64 i386 frame + fuzzer test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo apt-get install gcc-multilib
        sudo sysctl -w vm.mmap_min_addr=4096
    - name: frame + fuzzer test (i386)
      run: |
        make -C tests test-frametest32 test-fuzzer32


  # travis-ci: (Trusty) i386 benchmark + version test
  ubuntu-i386-bench-and-versions:
    name: Linux x64 i386 benchmark + version test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo apt-get install gcc-multilib
    - name: benchmark & versionsTest
      run: |
        make -C tests test-lz4c32 test-fullbench32 versionsTest


  # travis-ci: x32 compatibility test
  ubuntu-x32:
    name: Linux x64 x32
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo apt-get install gcc-multilib
    - name: make -C tests
      run: |
        make -C tests test MOREFLAGS=-mx32


  # travis-ci: (Precise) g++ and clang CMake test
  ubuntu-gxx-clang-cmake-test:
    name: Linux x64 g++ and clang CMake test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: g++
      # note : This test can be merged with ubntu-latest-cc.
      run: |
        make clean cxxtest
    - name: examples
      run: |
        make clean examples
    - name: cmake
      run: |
        make clean examples
    - name: travis-install
      run: |
        make clean travis-install
    - name: clang
      # note : This test can be merged with ubntu-latest-cc.
      run: |
        make clean clangtest


  ubuntu-ctocpp:
    name: Linux x64 c-to-c++
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: c-to-c++
      run: |
        make clean ctocpptest


  ubuntu-usan:
    name: Linux x64 usan
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: usan
      run: |
        make clean usan MOREFLAGS='-Wcomma -Werror'


  ubuntu-valgrind:
    name: Linux x64 valgrind
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo apt-get install valgrind

    - name: Environment info
      run: |
        echo && gcc --version
        echo && valgrind --version

    - name: valgrind
      run: |
        make -C tests test-mem


  ubuntu-cppcheck:
    name: Linux x64 scan-build + cppcheck
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo apt-get install cppcheck clang-tools

    - name: Environment info
      run: |
        echo && gcc --version
        echo && clang --version
        echo && cppcheck --version
        echo && which scan-build # scan-build doesn't have any --version equivalent option
        echo && make -v
        echo && cat /proc/cpuinfo || echo /proc/cpuinfo is not present

    - name: staticAnalyze
      run: |
        make clean staticAnalyze

    - name: cppcheck
      run: |
        # This test script ignores exit code of cppcheck.  See knowin issues
        # at the top of this file.
        make clean cppcheck || echo There are some cppcheck reports


  # Test various C compilers
  #
  # Invoke the following commands for each C compiler
  #   make all c_standards
  #   make -C programs
  #   make -C tests
  #
  ubuntu-latest-cc:
    name: Linux x64 ${{ matrix.xcc_name }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false  # 'false' means Don't stop matrix workflows even if some matrix failed.
      matrix:
        include: [
          { xcc_name: 'gcc 7',      xcc_pkg: gcc-7,       xcc: gcc-7     },
          { xcc_name: 'gcc 8',      xcc_pkg: gcc-8,       xcc: gcc-8     },
          { xcc_name: 'gcc 9',      xcc_pkg: gcc-9,       xcc: gcc-9     },
          { xcc_name: 'gcc 10',     xcc_pkg: gcc-10,      xcc: gcc-10    },
          { xcc_name: 'clang 6',    xcc_pkg: clang-6.0,   xcc: clang-6.0 },
          { xcc_name: 'clang 7',    xcc_pkg: clang-7,     xcc: clang-7   },
          { xcc_name: 'clang 8',    xcc_pkg: clang-8,     xcc: clang-8   },
          { xcc_name: 'clang 9',    xcc_pkg: clang-9,     xcc: clang-9   },
          { xcc_name: 'clang 10',   xcc_pkg: clang-10,    xcc: clang-10  },
          { xcc_name: 'clang 11',   xcc_pkg: clang-11,    xcc: clang-11  },
        ]
    env:                        # Set environment variables
      XCC: ${{ matrix.xcc }}
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt-get install
      run: |
        sudo apt-get install gcc-multilib ${{ matrix.xcc_pkg }} 

    - name: Environment info
      run: |
        echo && which $XCC
        echo && $XCC --version

    - name: make all
      run: |
        CC=$XCC make clean all MOREFLAGS=-Werror

    - name: make c_standards
      run: |
        CC=$XCC make clean c_standards

    - name: make -C programs
      run: |
        CC=$XCC make -C programs CFLAGS=-fPIC LDFLAGS='-pie -fPIE -D_FORTIFY_SOURCE=2'

    - name: make -C tests
      run: |
        CC=$XCC make -C tests test-lz4 clean test-lz4c32 MOREFLAGS=-Werror


  ubuntu-build-meson:
    name: Linux x64 Meson + Ninja
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - uses: actions/setup-python@v2 # https://github.com/actions/setup-python
      with:
        python-version: '3.x'

    - name: install
      run: |
        sudo apt-get install tree ninja-build
        python -m pip install --upgrade pip
        pip3 install --user meson

    - name: Environment info
      run: |
        echo && clang --version
        echo && python --version
        echo && meson --version
        echo && cat /proc/cpuinfo || echo /proc/cpuinfo is not present

    - name: meson
      # 'run: >' replaces all newlines in the following block with spaces
      run: >
        meson setup
        --buildtype=debug
        -Db_lundef=false
        -Dauto_features=enabled
        -Ddefault_library=both
        -Dbin_programs=true
        -Dbin_contrib=true
        -Dbin_tests=true
        -Dbin_examples=true
        contrib/meson build

    - name: staging
      run: |
        pushd build
        DESTDIR=./staging ninja install
        tree ./staging


  ubuntu-build-cmake:
    name: Linux x64 cmake
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout

    - name: Environment info
      run: |
        echo && gcc --version
        echo && cmake --version
        echo && make -v
        echo && cat /proc/cpuinfo || echo /proc/cpuinfo is not present

    - name: cmake
      run: |
        cd build/cmake
        mkdir build
        cd build
        cmake ..
        CFLAGS=-Werror make


  # make cmake
  # note: This test can be merged with ubuntu-build-cmake
  ubuntu-cmake:
    name: Linux x64 make cmake
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: make cmake
      run: |
        make clean cmake


  # Linux, { ARM, ARM64, PPC, PPC64LE, S390X }
  # All tests are using QEMU and gcc cross compiler.
  qemu-platformtest:
    name: QEMU ${{ matrix.name }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false  # 'false' means Don't stop matrix workflows even if some matrix failed.
      matrix:
        include: [
          { name: ARM,      xcc_pkg: gcc-arm-linux-gnueabi,     xcc: arm-linux-gnueabi-gcc,     xemu_pkg: qemu-system-arm,    xemu: qemu-arm-static     },
          { name: ARM64,    xcc_pkg: gcc-aarch64-linux-gnu,     xcc: aarch64-linux-gnu-gcc,     xemu_pkg: qemu-system-arm,    xemu: qemu-aarch64-static },
          { name: PPC,      xcc_pkg: gcc-powerpc-linux-gnu,     xcc: powerpc-linux-gnu-gcc,     xemu_pkg: qemu-system-ppc,    xemu: qemu-ppc-static     },
          { name: PPC64LE,  xcc_pkg: gcc-powerpc64le-linux-gnu, xcc: powerpc64le-linux-gnu-gcc, xemu_pkg: qemu-system-ppc,    xemu: qemu-ppc64le-static },
          { name: S390X,    xcc_pkg: gcc-s390x-linux-gnu,       xcc: s390x-linux-gnu-gcc,       xemu_pkg: qemu-system-s390x,  xemu: qemu-s390x-static   },
        ]
    env:                        # Set environment variables
      XCC: ${{ matrix.xcc }}
      XEMU: ${{ matrix.xemu }}
    steps:
    - uses: actions/checkout@v2 # https://github.com/actions/checkout
    - name: apt update & install
      run: |
        sudo apt-get update
        sudo apt-get install gcc-multilib g++-multilib qemu-utils qemu-user-static
        sudo apt-get install ${{ matrix.xcc_pkg }} ${{ matrix.xemu_pkg }} 

    - name: Environment info
      run: |
        echo && which $XCC
        echo && $XCC --version
        echo && $XCC -v  # Show built-in specs
        echo && which $XEMU
        echo && $XEMU --version

    - name: ARM
      if: ${{ matrix.name == 'ARM' }}
      run: |
        make platformTest CC=$XCC QEMU_SYS=$XEMU

    - name: ARM64
      if: ${{ matrix.name == 'ARM64' }}
      run: |
        make platformTest CC=$XCC QEMU_SYS=$XEMU

    - name: PPC
      if: ${{ matrix.name == 'PPC' }}
      run: |
        make platformTest CC=$XCC QEMU_SYS=$XEMU

    - name: PPC64LE
      if: ${{ matrix.name == 'PPC64LE' }}
      run: |
        make platformTest CC=$XCC QEMU_SYS=$XEMU MOREFLAGS=-m64

    - name: S390X
      if: ${{ matrix.name == 'S390X' }}
      run: |
        make platformTest CC=$XCC QEMU_SYS=$XEMU


  # macOS
  macos-latest-general:
    name: macOS general test
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v2

    - name: Environment info
      run: |
        echo && clang --version
        echo && sysctl -a | grep machdep.cpu   # cpuinfo

    - name: make
      run: |
        CFLAGS="-Werror" make clean default

    - name: library build
      run: |
        make clean default

    - name: test
      run: |
        # test scenario where `stdout` is not the console
        make clean test MOREFLAGS='-Werror -Wconversion -Wno-sign-conversion' | tee