0
0
mirror of https://github.com/lz4/lz4 synced 2026-01-18 17:21:30 +01:00

Merge pull request #1621 from lz4/ci_reorg

Github Actions script refactoring
This commit is contained in:
Yann Collet
2025-05-26 19:50:22 -07:00
committed by GitHub
10 changed files with 827 additions and 789 deletions

View File

@@ -1,10 +1,39 @@
This directory contains [GitHub Actions](https://github.com/features/actions) workflow files.
# Workflow Organization
The CI/CD workflows are organized into focused, maintainable files:
## Core Testing Workflows
- **`compilers.yml`** - Tests compatibility across different C compilers (GCC, Clang versions)
- **`core-tests.yml`** - Core LZ4 functionality testing (benchmarks, fuzzing, frame format, ABI compatibility, etc.)
- **`sanitizers.yml`** - Memory safety testing (AddressSanitizer, MemorySanitizer, UBSan, ThreadSanitizer)
## Platform & Build System Testing
- **`cross-platform.yml`** - Cross-platform testing using QEMU emulation and native macOS builds
- **`build-systems.yml`** - Alternative build systems (Visual Studio, Meson)
- **`cmake-test.yml`** - CMake build system testing
## Code Quality & Analysis
- **`code-quality.yml`** - Static analysis tools (cppcheck, scan-build, valgrind, unicode lint)
- **`oss-fuzz.yml`** - OSS-Fuzz integration for continuous fuzzing
## Utilities & Environment
- **`release-environment.yml`** - Release validation and environment information gathering
- **`scorecard.yml`** - Security scorecard analysis
This organization provides:
- **Better maintainability** - Changes to specific test categories only affect relevant files
- **Improved parallelization** - Workflows run independently and in parallel
- **Clearer failure isolation** - Easier to identify which types of tests are failing
- **Enhanced readability** - Each workflow has a single, clear responsibility
# Known issues
## USAN, ASAN (`lz4-ubsan-x64`, `lz4-ubsan-x86`, `lz4-asan-x64`)
## Sanitizers (UBSan, ASan) - `sanitizers.yml`
For now, `lz4-ubsan-*` uses the `-fsanitize-recover=pointer-overflow` flag:
### UBSan (UndefinedBehaviorSanitizer)
For now, UBSan tests use the `-fsanitize-recover=pointer-overflow` flag:
there are known cases of pointer overflow arithmetic within `lz4.c` fast compression.
These cases are not dangerous with known architecture,
but they are not guaranteed to work by the C standard,
@@ -18,32 +47,10 @@ not active anywhere today.
Therefore, a more acceptable work-around will have to be found first.
## cppcheck (`lz4-cppcheck`)
## cppcheck - `code-quality.yml`
This test script ignores the exit code of `make cppcheck`.
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 |
| Version of tools | Environment info |
# Difference with `.travis.yml`
The following tests are not be included due to limitation of GH-Actions.
- name: aarch64 real-hw tests
- name: PPC64LE real-hw tests
- name: IBM s390x real-hw tests

109
.github/workflows/build-systems.yml vendored Normal file
View File

@@ -0,0 +1,109 @@
# Build system testing (Visual Studio, Meson)
name: Build Systems
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
windows-visual-studio:
name: ${{ matrix.system.os }} Visual Studio
runs-on: ${{ matrix.system.os }}
strategy:
fail-fast: false
matrix:
system:
- { os: windows-2022, build_path: ".\\build\\VS2022" }
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Build Win32 Debug
# Switching to debug mode, since vs2022 optimizations seem to introduce a bug since July 2024
run: |
pushd ${{ matrix.system.build_path }}
.\\build-and-test-win32-debug.bat
popd
- name: Build x64 Debug
# Switching to debug mode, since vs2022 optimizations seem to introduce a bug since July 2024
run: |
pushd ${{ matrix.system.build_path }}
.\\build-and-test-x64-debug.bat
popd
- name: Generate VS solution
run: |
pushd ".\\build\\visual"
.\\generate_vs2022.cmd
popd
- name: Upload generated VS2022 directory
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: VS2022-Build-Dir
path: "build/visual/Visual Studio 17 2022"
- name: Build executable with generated solution
run: cmake --build "build/visual/Visual Studio 17 2022" --config Debug
- name: Run minimal runtime test
run: |
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" -vvV
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" -bi1
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe"
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" -t ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe.lz4"
meson:
name: Meson + Ninja
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.x'
- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install tree ninja-build
python -m pip install --upgrade pip
pip3 install --user meson
- name: Display environment info
run: |
type clang && which clang && clang --version
type python && which python && python --version
type meson && which meson && meson --version
- name: Configure build
run: >
meson setup
--fatal-meson-warnings
--buildtype=debug
-Db_lundef=false
-Dauto_features=enabled
-Dprograms=true
-Dcontrib=true
-Dtests=true
-Dexamples=true
build/meson builddir
- name: Run tests
run: meson test -C builddir
- name: Test installation
run: |
cd builddir
DESTDIR=./staging ninja install
tree ./staging

View File

@@ -1,764 +0,0 @@
# For details, see README.md in this directory.
###############################################################
# C compilers
#
# - gcc
# - clang
#
# Known Issue
# - All test cases which described as 'fail' must be fixed and replaced with 'true'.
# - gcc-11 (x32, x86) : "../lib/lz4hc.c:148: LZ4HC_countBack: Assertion `(size_t)(match - mMin) < (1U<<31)' failed."
# - all clangs (x32, x86) : "../lib/lz4hc.c:282: int LZ4HC_InsertAndGetWiderMatch(...): Assertion `matchPtr >= lowPrefixPtr' failed."
#
name: lz4 CI
on: [push, pull_request]
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
lz4-c-compilers:
name: CC=${{ matrix.cc }}, ${{ matrix.os }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix failed.
matrix:
include: [
# You can access the following values via ${{ matrix.??? }}
#
# pkgs : apt-get package names. It can include multiple package names which are delimited by space.
# cc : C compiler executable.
# cxx : C++ compiler executable for targets `cxxtest` and `ctocxxtest`.
# x32 : Note: x32 tests do no longer work on github ci.
# Set 'true' if compiler & os support x32. Otherwise, set 'false'.
# Set 'fail' if it supports x32 but fails for now. 'fail' cases must be removed.
# x86 : Set 'true' if compiler supports x86 (-m32). Otherwise, set 'false'.
# Set 'fail' if it supports x86 but fails for now. 'fail' cases must be removed.
# cxxtest : Set 'true' if it can be compiled as C++ code. Otherwise, set 'false'.
# freestanding : Set 'true' if it can be compiled and execute freestanding code. Otherwise, set 'false'.
# Usually, it requires Linux, x86_64 and gcc/g++.
# os : GitHub Actions YAML workflow label. See https://github.com/actions/virtual-environments#available-environments
# cc
{ pkgs: '', cc: cc, cxx: c++, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'true', os: ubuntu-latest, },
# gcc - keeping system default, latest stable, and LTS version
{ pkgs: '', cc: gcc, cxx: g++, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'true', os: ubuntu-latest, },
{ pkgs: 'gcc-14 g++-14 lib32gcc-14-dev libx32gcc-14-dev', cc: gcc-14, cxx: g++-14, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'true', os: ubuntu-24.04, },
{ pkgs: 'gcc-11 g++-11 lib32gcc-11-dev libx32gcc-11-dev', cc: gcc-11, cxx: g++-11, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'true', os: ubuntu-22.04, },
# clang - keeping system default, latest stable, and older stable version
{ pkgs: 'lib32gcc-12-dev libx32gcc-12-dev', cc: clang, cxx: clang++, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'false', os: ubuntu-latest, },
{ pkgs: 'clang-18 lib32gcc-12-dev libx32gcc-12-dev', cc: clang-18, cxx: clang++-18, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'false', os: ubuntu-24.04, },
{ pkgs: 'clang-14 lib32gcc-12-dev libx32gcc-12-dev', cc: clang-14, cxx: clang++-14, x32: 'false', x86: 'true', cxxtest: 'true', freestanding: 'false', os: ubuntu-22.04, },
]
runs-on: ${{ matrix.os }}
env: # Set environment variables
# We globally set CC and CXX to improve compatibility
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
FIXME__LZ4_CI_IGNORE : ' echo Error. But we ignore it for now.'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
sudo apt-get install ${{ matrix.pkgs }}
- name: Environment info
run: |
echo && type $CC && which $CC && $CC --version
echo && type $CXX && which $CXX && $CXX --version
- name: make
if: always()
run: make -j V=1
- name: install test
if: always()
run: make -C tests test-install V=1
- name: make all
if: always()
run: make clean; CFLAGS="-Werror -O0" make -j all V=1
- name: make c_standards (C90)
if: always()
run: make clean; make -j c_standards_c90 V=1
- name: make c_standards (C11)
if: always()
run: make clean; make -j c_standards_c11 V=1
- name: c lib for c++ program
if: ${{ matrix.cxxtest == 'true' }}
run: make clean; make -j ctocxxtest V=1
- name: compiled as c++ source
if: ${{ matrix.cxxtest == 'true' }}
run: make clean; make -j cxxtest V=1
- name: make test-freestanding
if: ${{ matrix.freestanding == 'true' }}
run: make clean; make test-freestanding V=1
- name: make -C programs default -D_FORTIFY_SOURCE=2
if: always()
run: make clean; CFLAGS='-fPIC' LDFLAGS='-pie -fPIE -D_FORTIFY_SOURCE=2' make -j -C programs default V=1
- name: make -C tests test-lz4
if: always()
run: make clean; CPPFLAGS=-DLZ4IO_NO_TSAN_ONLY make -j V=1 -C tests test-lz4
- name: make -C tests test CFLAGS='-mx32'
if: ${{ matrix.x32 == 'true' }}
run: make clean; CFLAGS='-mx32' make -j -C tests test V=1
- name: make -C tests test-lz4c32
if: ${{ matrix.x86 == 'true' }}
run: make clean; CFLAGS='-Werror -O1' make -j -C tests test-lz4c32 V=1
###############################################################
# #
# Remove this block when we relevant tests run properly #
# #
- name: make -C tests test CFLAGS='-mx32' || echo Ignore failure for now.
if: ${{ matrix.x32 == 'fail' }}
run: make clean; CFLAGS='-mx32' make -C tests test V=1 || $FIXME__LZ4_CI_IGNORE
# #
###############################################################
###############################################################
# LZ4 self tests
#
# - Fullbench
# - Fuzzer
# - LZ4 Frame
# - LZ4 versions
# - Custom LZ4_DISTANCE_MAX
#
lz4-benchmark:
name: Fullbench
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: test-lz4c
run: make -j -C tests test-lz4c V=1
- name: test-fullbench
run: make -j -C tests test-fullbench V=1
- name: test-fullbench32
run: make -j -C tests test-fullbench32 V=1
lz4-fuzzer:
name: Fuzzer test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: setup
run: sudo sysctl -w vm.mmap_min_addr=4096
- name: fuzzer
run: make -j -C tests test-fuzzer V=1
- name: fuzzer32
run: make -C tests test-fuzzer32 V=1
lz4-standard-makefile-variables:
name: LZ4 Makefile - support for standard variables
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: check propagation of standard variables
run: make test_stdvars V=1
lz4-versions:
name: LZ4 versions test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: versionsTest
run: make -j -C tests versionsTest V=1
lz4-abi:
name: LZ4 inter-versions ABI compatibility test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: abiTests
run: make -j -C tests abiTests V=1
lz4-frame:
name: LZ4 frame test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: LZ4 frame test
run: make -j -C tests test-frametest V=1
- name: LZ4 frame test (32-bit)
run: make -j -C tests test-frametest32 V=1
lz4-memory-usage:
name: test different values of LZ4_MEMORY_USAGE
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: LZ4_MEMORY_USAGE
run: make V=1 -C tests test-compile-with-lz4-memory-usage
# Custom LZ4_DISTANCE_MAX ; lz4-wlib (CLI linked to dynamic library); LZ4_USER_MEMORY_FUNCTIONS
lz4-custom-distance:
name: Custom LZ4_DISTANCE_MAX
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: custom LZ4_DISTANCE_MAX; test LZ4_USER_MEMORY_FUNCTIONS
run: |
CPPFLAGS='-DLZ4_DISTANCE_MAX=8000' make V=1 check
make clean
make -C programs lz4-wlib V=1
make clean
make -C tests fullbench-wmalloc V=1 # test LZ4_USER_MEMORY_FUNCTIONS
make clean
CC="c++ -Wno-deprecated" make -C tests fullbench-wmalloc V=1 # stricter function signature check
# test block device compression #1086
lz4cli-block-device:
name: Test lz4 compression on a block device
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: create a block device, compress it with lz4 # alternative : blindly use /dev/loop0, seems to always exist
run: |
make lz4
dd if=/dev/zero of=full0.img bs=2M count=1
BLOCK_DEVICE=$(sudo losetup --show -fP full0.img)
sudo chmod 666 $BLOCK_DEVICE
./lz4 -v $BLOCK_DEVICE -c > /dev/null
sudo losetup -d $BLOCK_DEVICE
rm full0.img
###############################################################
# Check tools
#
# - cppcheck
# - scan-build
# - valgrind
# - ubsan
# - asan
# - unicode-lint
# - build examples
#
lz4-cppcheck:
name: make cppcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install cppcheck
- name: Environment info
run: echo && type cppcheck && which cppcheck && cppcheck --version
- name: cppcheck
# This test script ignores the exit code of cppcheck.
# See known issues in README.md.
run: make V=1 clean cppcheck || echo There are some cppcheck reports but we ignore it.
lz4-scan-build:
name: make staticAnalyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install clang-tools
- name: Environment info
run: |
echo && type gcc && which gcc && gcc --version
echo && type clang && which clang && clang --version
echo && type scan-build && which scan-build # scan-build doesn't have any --version equivalent option
echo && type make && which make && make -v
echo && cat /proc/cpuinfo || echo /proc/cpuinfo is not present
- name: make staticAnalyze
run: make V=1 clean staticAnalyze
lz4-valgrind:
name: valgrind
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install valgrind
- name: Environment info
run: |
echo && type cc && which cc && cc --version
echo && type valgrind && which valgrind && valgrind --version
- name: valgrind
run: make V=1 -C tests test-mem
lz4-ubsan-x64:
name: Linux x64 ubsan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: ubsan
run: |
make ubsan V=1
lz4-ubsan-x86:
name: Linux x86 ubsan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
sudo apt-get install lib32gcc-11-dev
- name: ubsan32
run: |
make clean
CC=clang make V=1 usan32
lz4-asan-x64:
name: Linux x64 ASAN
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: setup
run: sudo sysctl -w vm.mmap_min_addr=4096
- name: check lz4
run: make clean; CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address make -j check V=1
- name: frametest
run: make clean; CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address make -j -C tests test-frametest V=1
- name: fuzzer
run: make clean; CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address make -j -C tests test-fuzzer V=1
lz4-msan-x64:
name: Linux x64 MSAN
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: check lz4
run: make clean; CC=clang CFLAGS=-fsanitize=memory LDFLAGS=-fsanitize=memory make -j check V=1
- name: frametest
run: make clean; CC=clang CFLAGS=-fsanitize=memory LDFLAGS=-fsanitize=memory make -j -C tests test-frametest V=1
- name: fuzzer
run: make clean; CC=clang CFLAGS=-fsanitize=memory LDFLAGS=-fsanitize=memory make -j -C tests test-fuzzer V=1
lz4-tsan-x64:
name: Linux x64 TSAN
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: lz4 cli
run: make clean; CC=clang CPPFLAGS="-fsanitize=thread" make -j -C tests test-lz4 V=1
unicode-lint:
name: lint unicode in ./lib/, ./tests/ and ./programs/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: unicode lint
run: bash ./tests/unicode_lint.sh
lz4-examples:
name: make examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
- name: Environment info
run: |
echo && type cc && which cc && cc --version
echo && type c++ && which c++ && c++ --version
- name: examples
run: make V=1 clean examples
# lasts ~8mn
oss-fuzz:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory]
steps:
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'lz4'
dry-run: false
sanitizer: ${{ matrix.sanitizer }}
- name: Run Fuzzers (${{ matrix.sanitizer }})
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'lz4'
fuzz-seconds: 100
dry-run: false
sanitizer: ${{ matrix.sanitizer }}
- name: Upload Crash
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # https://github.com/actions/upload-artifact v4.6.2
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts
###############################################################
# Platforms
#
# - QEMU (ARM, ARM64, PPC, PPC64LE, S390X)
# - macOS
# - Windows
#
# QEMU
# All tests use QEMU (static) and gcc cross compiler.
#
lz4-qemu-platforms:
name: QEMU ${{ matrix.type }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix instance failed.
matrix:
include: [
# You can access the following values via ${{ matrix.??? }}
# type : Architecture type for `if:` statement.
# pkgs : apt-get package names. You can include multiple packages which are delimited by space.
# xcc : gcc cross C compiler executable.
# xemu : QEMU static emulator executable.
# os : GitHub Actions YAML workflow label. See https://github.com/actions/virtual-environments#available-environments
{ type: ARM, pkgs: 'qemu-system-arm gcc-arm-linux-gnueabi', xcc: arm-linux-gnueabi-gcc, xemu: qemu-arm-static, os: ubuntu-latest, makevar: "", },
{ type: ARM64, pkgs: 'qemu-system-arm gcc-aarch64-linux-gnu', xcc: aarch64-linux-gnu-gcc, xemu: qemu-aarch64-static, os: ubuntu-latest, makevar: "", },
{ type: PPC, pkgs: 'qemu-system-ppc gcc-powerpc-linux-gnu', xcc: powerpc-linux-gnu-gcc, xemu: qemu-ppc-static, os: ubuntu-latest, makevar: "", },
{ type: PPC64LE, pkgs: 'qemu-system-ppc gcc-powerpc64le-linux-gnu', xcc: powerpc64le-linux-gnu-gcc, xemu: qemu-ppc64le-static, os: ubuntu-latest, makevar: "", },
{ type: S390X, pkgs: 'qemu-system-s390x gcc-s390x-linux-gnu', xcc: s390x-linux-gnu-gcc, xemu: qemu-s390x-static, os: ubuntu-latest, makevar: "", },
{ type: MIPS, pkgs: 'qemu-system-mips gcc-mips-linux-gnu', xcc: mips-linux-gnu-gcc, xemu: qemu-mips-static, os: ubuntu-latest, makevar: "", },
{ type: M68K, pkgs: 'qemu-system-m68k gcc-m68k-linux-gnu', xcc: m68k-linux-gnu-gcc, xemu: qemu-m68k-static, os: ubuntu-latest, makevar: "HAVE_MULTITHREAD=0", }, # bug in MT mode on m68k
{ type: RISC-V, pkgs: 'qemu-system-riscv64 gcc-riscv64-linux-gnu', xcc: riscv64-linux-gnu-gcc, xemu: qemu-riscv64-static, os: ubuntu-latest, makevar: "", },
{ type: SPARC, pkgs: 'qemu-system-sparc gcc-sparc64-linux-gnu', xcc: sparc64-linux-gnu-gcc, xemu: qemu-sparc64-static, os: ubuntu-latest, makevar: "", },
]
runs-on: ${{ matrix.os }}
env: # Set environment variables
XCC: ${{ matrix.xcc }}
XEMU: ${{ matrix.xemu }}
MAKEVAR: ${{ matrix.makevar }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: apt-get install
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
sudo apt-get install qemu-utils qemu-user-static
sudo apt-get install ${{ matrix.pkgs }}
- name: Environment info
run: |
echo && type $XCC && which $XCC && $XCC --version
echo && $XCC -v # Show built-in specs
echo && type $XEMU && which $XEMU && $XEMU --version
- name: ARM-ARM64-PPC-S390X
if: ${{ matrix.type == 'ARM' || matrix.type == 'ARM64' || matrix.type == 'PPC' || matrix.type == 'S390X'}}
run: make platformTest V=1 CC=$XCC QEMU_SYS=$XEMU
- name: PPC64LE
if: ${{ matrix.type == 'PPC64LE' }}
run: CFLAGS=-m64 make platformTest V=1 CC=$XCC QEMU_SYS=$XEMU
- name: MIPS-M68K-RISCV-SPARC
if: ${{ matrix.type == 'MIPS' || matrix.type == 'M68K' || matrix.type == 'RISC-V' || matrix.type == 'SPARC' }}
run: make platformTest V=1 CC=$XCC QEMU_SYS=$XEMU $MAKEVAR
# macOS
lz4-platform-macos-latest:
name: macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: Environment info
run: |
echo && type cc && which cc && cc --version
echo && type make && which make && make -v
echo && sysctl -a | grep machdep.cpu # cpuinfo
- name: make default
run: make clean; CFLAGS="-Werror -O0" make default V=1
- name: make test
run: make clean; CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" make -j test V=1
- name: Ensure `make test` doesn't depend on the status of the console
# see issue #990 for detailed explanations
run: make -j test > /dev/null
###############################################################
# Build systems (other than make)
#
# - visual
# - meson
#
# Note: cmake tests are regrouped in cmake-test.yml
#
# Windows + Visual
lz4-platform-windows:
name: ${{ matrix.system.os }}
runs-on: ${{ matrix.system.os }}
strategy:
fail-fast: false # 'false' means Don't stop matrix workflows even if some matrix failed.
matrix:
system: [
{ os: windows-2022, build_path: ".\\build\\VS2022" },
]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: Build ${{ matrix.system.os }}, Win32
# Switching to debug mode, since vs2022 optimizations seem to introduce a bug since July 2024
run: |
pushd ${{ matrix.system.build_path }}
.\\build-and-test-win32-debug.bat
popd
- name: Build ${{ matrix.system.os }}, x64
# Switching to debug mode, since vs2022 optimizations seem to introduce a bug since July 2024
run: |
pushd ${{ matrix.system.build_path }}
.\\build-and-test-x64-debug.bat
popd
- name: VS solution generation
run: |
pushd ".\\build\\visual"
.\\generate_vs2022.cmd
popd
- name: Upload Generated VS2022 Directory
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # https://github.com/actions/upload-artifact v4.6.2
with:
name: VS2022-Build-Dir
path: "build/visual/Visual Studio 17 2022"
- name: Build executable with generated solution
run: |
cmake --build "build/visual/Visual Studio 17 2022" --config Debug
- name: Minimal runtime test
run: |
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" -vvV
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" -bi1
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe"
& ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe" -t ".\\build\\visual\\Visual Studio 17 2022\\Debug\\lz4.exe.lz4"
# Meson
lz4-build-meson:
name: Meson + Ninja
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # https://github.com/actions/setup-python v5.6.0
with:
python-version: '3.x'
- name: Install
run: |
sudo apt-get update
sudo apt-get install tree ninja-build
python -m pip install --upgrade pip
pip3 install --user meson
- name: Environment info
run: |
echo && type clang && which clang && clang --version
echo && type python && which python && python --version
echo && type meson && which meson && meson --version
- name: setup
# 'run: >' replaces all newlines in the following block with spaces
run: >
meson setup
--fatal-meson-warnings
--buildtype=debug
-Db_lundef=false
-Dauto_features=enabled
-Dprograms=true
-Dcontrib=true
-Dtests=true
-Dexamples=true
build/meson builddir
- name: test
run: |
meson test -C builddir
- name: staging
run: |
cd builddir
DESTDIR=./staging ninja install
tree ./staging
############################################################
# Check git tag for LZ4 releases
#
lz4-check-tag:
name: git version tag checking for release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: make -C tests checkTag
if: startsWith(github.ref, 'refs/tags/v') # If git tag name starts with 'v'
run: |
echo "tag=${GITHUB_REF#refs/*/}"
make -C tests checkTag
tests/checkTag ${GITHUB_REF#refs/*/}
############################################################
# Gather CI environment information.
#
lz4-env-info:
name: GH-Actions Virtual Env Info (${{ matrix.os }})
strategy:
matrix:
include: [
{ os: ubuntu-latest, }, # https://github.com/actions/runner-images/?tab=readme-ov-file#available-images
{ os: ubuntu-24.04, }, # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
{ os: ubuntu-22.04, }, # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # https://github.com/actions/checkout v4.2.2
- name: init
run: |
sudo apt-get update
- name: cc --version
run: echo && type cc && which cc && cc --version
- name: gcc --version
run: echo && type gcc && which gcc && gcc --version
- name: clang --version
run: echo && type clang && which clang && clang --version
- name: make -v
run: echo && type make && which make && make -v
- name: g++ --version
run: echo && type g++ && which g++ && g++ --version
- name: git --version
run: echo && type git && which git && git --version
- name: gcc packages (apt-cache)
run: apt-cache search gcc | grep "^gcc-[0-9\.]* " | sort
- name: lib32gcc packages for i386 (apt-cache)
run: apt-cache search lib32gcc | grep "^lib32gcc-" | sort
- name: libx32gcc packages for x32 (apt-cache)
run: apt-cache search libx32gcc | grep "^libx32gcc-" | sort
- name: gcc multilib packages (apt-cache)
run: apt-cache search multilib | grep "gcc-" | sort
- name: clang packages (apt-cache)
run: apt-cache search clang | grep "^clang-[0-9\.]* " | sort
- name: QEMU packages (apt-cache)
run: apt-cache search qemu | grep "^qemu-system-.*QEMU full system" | sort

105
.github/workflows/code-quality.yml vendored Normal file
View File

@@ -0,0 +1,105 @@
# Static analysis and code quality checks
name: Code Quality
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
cppcheck:
name: Cppcheck Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install cppcheck
run: |
sudo apt-get update
sudo apt-get install cppcheck
- name: Display cppcheck version
run: |
type cppcheck && which cppcheck && cppcheck --version
- name: Run cppcheck analysis
# This test script ignores the exit code of cppcheck.
# See known issues in README.md.
run: make V=1 clean cppcheck || echo "There are some cppcheck reports but we ignore them for now."
scan-build:
name: Clang Static Analyzer
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install clang-tools
run: |
sudo apt-get update
sudo apt-get install clang-tools
- name: Display environment info
run: |
type gcc && which gcc && gcc --version
type clang && which clang && clang --version
type scan-build && which scan-build
type make && which make && make -v
cat /proc/cpuinfo || echo "/proc/cpuinfo is not present"
- name: Run static analysis
run: make V=1 clean staticAnalyze
valgrind:
name: Valgrind Memory Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install valgrind
run: |
sudo apt-get update
sudo apt-get install valgrind
- name: Display environment info
run: |
type cc && which cc && cc --version
type valgrind && which valgrind && valgrind --version
- name: Run memory analysis
run: make V=1 -C tests test-mem
unicode-lint:
name: Unicode Linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Check for unicode issues
run: bash ./tests/unicode_lint.sh
examples:
name: Build Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: sudo apt-get update
- name: Display compiler info
run: |
type cc && which cc && cc --version
type c++ && which c++ && c++ --version
- name: Build examples
run: make V=1 clean examples

112
.github/workflows/compilers.yml vendored Normal file
View File

@@ -0,0 +1,112 @@
# Compiler compatibility testing across multiple C compilers
name: Compiler Tests
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
compiler-matrix:
name: ${{ matrix.cc }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# System default compilers
- { pkgs: '', cc: cc, cxx: c++, x86: true, cxxtest: true, freestanding: true, os: ubuntu-latest }
- { pkgs: '', cc: gcc, cxx: g++, x86: true, cxxtest: true, freestanding: true, os: ubuntu-latest }
# GCC versions - latest stable and LTS
- { pkgs: 'gcc-14 g++-14 lib32gcc-14-dev', cc: gcc-14, cxx: g++-14, x86: true, cxxtest: true, freestanding: true, os: ubuntu-24.04 }
- { pkgs: 'gcc-11 g++-11 lib32gcc-11-dev', cc: gcc-11, cxx: g++-11, x86: true, cxxtest: true, freestanding: true, os: ubuntu-22.04 }
# Clang versions - system default, latest stable, and older stable
- { pkgs: 'lib32gcc-12-dev', cc: clang, cxx: clang++, x86: true, cxxtest: true, freestanding: false, os: ubuntu-latest }
- { pkgs: 'clang-18 lib32gcc-12-dev', cc: clang-18, cxx: clang++-18, x86: true, cxxtest: true, freestanding: false, os: ubuntu-24.04 }
- { pkgs: 'clang-14 lib32gcc-12-dev', cc: clang-14, cxx: clang++-14, x86: true, cxxtest: true, freestanding: false, os: ubuntu-22.04 }
runs-on: ${{ matrix.os }}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
FIXME__LZ4_CI_IGNORE: ' echo Error. But we ignore it for now.'
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
if [ "${{ matrix.pkgs }}" != "" ]; then
sudo apt-get install ${{ matrix.pkgs }}
fi
- name: Display environment info
run: |
echo "=== Compiler Information ==="
type $CC && which $CC && $CC --version
echo "=== C++ Compiler Information ==="
type $CXX && which $CXX && $CXX --version
- name: Basic build test
run: make -j V=1
- name: Installation test
run: make -C tests test-install V=1
- name: Build all with strict flags
run: |
make clean
CFLAGS="-Werror -O0" make -j all V=1
- name: C90 standard compliance test
run: |
make clean
make -j c_standards_c90 V=1
- name: C11 standard compliance test
run: |
make clean
make -j c_standards_c11 V=1
- name: C library for C++ program test
if: ${{ matrix.cxxtest }}
run: |
make clean
make -j ctocxxtest V=1
- name: C++ compilation test
if: ${{ matrix.cxxtest }}
run: |
make clean
make -j cxxtest V=1
- name: Freestanding environment test
if: ${{ matrix.freestanding }}
run: |
make clean
make test-freestanding V=1
- name: Fortified build test
run: |
make clean
CFLAGS='-fPIC' LDFLAGS='-pie -fPIE -D_FORTIFY_SOURCE=2' make -j -C programs default V=1
- name: Core functionality test
run: |
make clean
CPPFLAGS=-DLZ4IO_NO_TSAN_ONLY make -j V=1 -C tests test-lz4
- name: 32-bit compatibility test
if: ${{ matrix.x86 }}
run: |
make clean
CFLAGS='-Werror -O1' make -j -C tests test-lz4c32 V=1

163
.github/workflows/core-tests.yml vendored Normal file
View File

@@ -0,0 +1,163 @@
# Core LZ4 functionality testing
name: Core Tests
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
benchmark:
name: Benchmark Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: Basic compression test
run: make -j -C tests test-lz4c V=1
- name: Full benchmark test
run: make -j -C tests test-fullbench V=1
- name: 32-bit benchmark test
run: make -j -C tests test-fullbench32 V=1
fuzzer:
name: Fuzzer Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: Setup memory mapping
run: sudo sysctl -w vm.mmap_min_addr=4096
- name: Fuzzer test (64-bit)
run: make -j -C tests test-fuzzer V=1
- name: Fuzzer test (32-bit)
run: make -C tests test-fuzzer32 V=1
versions:
name: Version Compatibility Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: Version compatibility test
run: make -j -C tests versionsTest V=1
abi:
name: ABI Compatibility Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: ABI compatibility test
run: make -j -C tests abiTests V=1
frame:
name: LZ4 Frame Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- name: Frame format test (64-bit)
run: make -j -C tests test-frametest V=1
- name: Frame format test (32-bit)
run: make -j -C tests test-frametest32 V=1
memory-usage:
name: Memory Usage Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Test different LZ4_MEMORY_USAGE values
run: make V=1 -C tests test-compile-with-lz4-memory-usage
custom-distance:
name: Custom Configuration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Custom LZ4_DISTANCE_MAX test
run: |
CPPFLAGS='-DLZ4_DISTANCE_MAX=8000' make V=1 check
make clean
- name: Dynamic library linking test
run: |
make -C programs lz4-wlib V=1
make clean
- name: User memory functions test
run: |
make -C tests fullbench-wmalloc V=1
make clean
CC="c++ -Wno-deprecated" make -C tests fullbench-wmalloc V=1
makefile-variables:
name: Makefile Standard Variables Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Test standard variable propagation
run: make test_stdvars V=1
block-device:
name: Block Device Compression Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Test block device compression
run: |
make lz4
dd if=/dev/zero of=full0.img bs=2M count=1
BLOCK_DEVICE=$(sudo losetup --show -fP full0.img)
sudo chmod 666 $BLOCK_DEVICE
./lz4 -v $BLOCK_DEVICE -c > /dev/null
sudo losetup -d $BLOCK_DEVICE
rm full0.img

93
.github/workflows/cross-platform.yml vendored Normal file
View File

@@ -0,0 +1,93 @@
# Cross-platform testing using QEMU emulation
name: Cross Platform
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
qemu-platforms:
name: ${{ matrix.arch }} (QEMU)
strategy:
fail-fast: false
matrix:
include:
- { arch: ARM, pkgs: 'qemu-system-arm gcc-arm-linux-gnueabi', xcc: arm-linux-gnueabi-gcc, xemu: qemu-arm-static, makevar: "" }
- { arch: ARM64, pkgs: 'qemu-system-arm gcc-aarch64-linux-gnu', xcc: aarch64-linux-gnu-gcc, xemu: qemu-aarch64-static, makevar: "" }
- { arch: PPC, pkgs: 'qemu-system-ppc gcc-powerpc-linux-gnu', xcc: powerpc-linux-gnu-gcc, xemu: qemu-ppc-static, makevar: "" }
- { arch: PPC64LE, pkgs: 'qemu-system-ppc gcc-powerpc64le-linux-gnu', xcc: powerpc64le-linux-gnu-gcc, xemu: qemu-ppc64le-static, makevar: "" }
- { arch: S390X, pkgs: 'qemu-system-s390x gcc-s390x-linux-gnu', xcc: s390x-linux-gnu-gcc, xemu: qemu-s390x-static, makevar: "" }
- { arch: MIPS, pkgs: 'qemu-system-mips gcc-mips-linux-gnu', xcc: mips-linux-gnu-gcc, xemu: qemu-mips-static, makevar: "" }
- { arch: M68K, pkgs: 'qemu-system-m68k gcc-m68k-linux-gnu', xcc: m68k-linux-gnu-gcc, xemu: qemu-m68k-static, makevar: "HAVE_MULTITHREAD=0" }
- { arch: RISC-V, pkgs: 'qemu-system-riscv64 gcc-riscv64-linux-gnu', xcc: riscv64-linux-gnu-gcc, xemu: qemu-riscv64-static, makevar: "" }
- { arch: SPARC, pkgs: 'qemu-system-sparc gcc-sparc64-linux-gnu', xcc: sparc64-linux-gnu-gcc, xemu: qemu-sparc64-static, makevar: "" }
runs-on: ubuntu-latest
env:
XCC: ${{ matrix.xcc }}
XEMU: ${{ matrix.xemu }}
MAKEVAR: ${{ matrix.makevar }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install gcc-multilib qemu-utils qemu-user-static
sudo apt-get install ${{ matrix.pkgs }}
- name: Display environment info
run: |
echo "=== Cross Compiler Information ==="
type $XCC && which $XCC && $XCC --version
$XCC -v # Show built-in specs
echo "=== QEMU Emulator Information ==="
type $XEMU && which $XEMU && $XEMU --version
- name: Run platform tests (ARM/ARM64/PPC/S390X)
if: contains(fromJSON('["ARM", "ARM64", "PPC", "S390X"]'), matrix.arch)
run: make platformTest V=1 CC=$XCC QEMU_SYS=$XEMU
- name: Run platform tests (PPC64LE)
if: matrix.arch == 'PPC64LE'
run: CFLAGS=-m64 make platformTest V=1 CC=$XCC QEMU_SYS=$XEMU
- name: Run platform tests (MIPS/M68K/RISC-V/SPARC)
if: contains(fromJSON('["MIPS", "M68K", "RISC-V", "SPARC"]'), matrix.arch)
run: make platformTest V=1 CC=$XCC QEMU_SYS=$XEMU $MAKEVAR
macos:
name: macOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Display environment info
run: |
type cc && which cc && cc --version
type make && which make && make -v
sysctl -a | grep machdep.cpu # CPU info
- name: Build with strict flags
run: |
make clean
CFLAGS="-Werror -O0" make default V=1
- name: Run comprehensive tests
run: |
make clean
CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" make -j test V=1
- name: Test console independence
# Ensure `make test` doesn't depend on the status of the console
# See issue #990 for detailed explanations
run: make -j test > /dev/null

45
.github/workflows/oss-fuzz.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
# OSS-Fuzz integration testing
name: OSS-Fuzz
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
oss-fuzz:
name: OSS-Fuzz (${{ matrix.sanitizer }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer: [address, undefined, memory]
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'lz4'
dry-run: false
sanitizer: ${{ matrix.sanitizer }}
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'lz4'
fuzz-seconds: 100
dry-run: false
sanitizer: ${{ matrix.sanitizer }}
- name: Upload Crash Artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: failure() && steps.build.outcome == 'success'
with:
name: ${{ matrix.sanitizer }}-artifacts
path: ./out/artifacts

View File

@@ -0,0 +1,69 @@
# Release and environment testing
name: Release & Environment
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
check-git-tag:
name: Git Version Tag Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate release tag
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "tag=${GITHUB_REF#refs/*/}"
make -C tests checkTag
tests/checkTag ${GITHUB_REF#refs/*/}
environment-info:
name: Environment Info (${{ matrix.os }})
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Update package list
run: sudo apt-get update
- name: Display compiler versions
run: |
echo "=== Default C Compiler ==="
type cc && which cc && cc --version
echo "=== GCC ==="
type gcc && which gcc && gcc --version
echo "=== Clang ==="
type clang && which clang && clang --version
echo "=== Make ==="
type make && which make && make -v
echo "=== G++ ==="
type g++ && which g++ && g++ --version
echo "=== Git ==="
type git && which git && git --version
- name: List available package versions
run: |
echo "=== Available GCC Packages ==="
apt-cache search gcc | grep "^gcc-[0-9\.]* " | sort
echo "=== Available lib32gcc Packages (i386) ==="
apt-cache search lib32gcc | grep "^lib32gcc-" | sort
echo "=== Available GCC Multilib Packages ==="
apt-cache search multilib | grep "gcc-" | sort
echo "=== Available Clang Packages ==="
apt-cache search clang | grep "^clang-[0-9\.]* " | sort
echo "=== Available QEMU Packages ==="
apt-cache search qemu | grep "^qemu-system-.*QEMU full system" | sort

99
.github/workflows/sanitizers.yml vendored Normal file
View File

@@ -0,0 +1,99 @@
# Sanitizer testing (AddressSanitizer, MemorySanitizer, etc.)
name: Sanitizers
on:
push:
pull_request:
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref }}
jobs:
ubsan-x64:
name: UndefinedBehaviorSanitizer (x64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run UBSan tests
run: make ubsan V=1
ubsan-x86:
name: UndefinedBehaviorSanitizer (x86)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install 32-bit dependencies
run: |
sudo apt-get update
sudo apt-get install gcc-multilib lib32gcc-11-dev
- name: Run UBSan tests (32-bit)
run: |
make clean
CC=clang make V=1 usan32
asan-x64:
name: AddressSanitizer (x64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup memory mapping
run: sudo sysctl -w vm.mmap_min_addr=4096
- name: ASan - basic check
run: |
make clean
CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address make -j check V=1
- name: ASan - frame test
run: |
make clean
CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address make -j -C tests test-frametest V=1
- name: ASan - fuzzer test
run: |
make clean
CFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address make -j -C tests test-fuzzer V=1
msan-x64:
name: MemorySanitizer (x64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: MSan - basic check
run: |
make clean
CC=clang CFLAGS=-fsanitize=memory LDFLAGS=-fsanitize=memory make -j check V=1
- name: MSan - frame test
run: |
make clean
CC=clang CFLAGS=-fsanitize=memory LDFLAGS=-fsanitize=memory make -j -C tests test-frametest V=1
- name: MSan - fuzzer test
run: |
make clean
CC=clang CFLAGS=-fsanitize=memory LDFLAGS=-fsanitize=memory make -j -C tests test-fuzzer V=1
tsan-x64:
name: ThreadSanitizer (x64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: TSan - CLI test
run: |
make clean
CC=clang CPPFLAGS="-fsanitize=thread" make -j -C tests test-lz4 V=1