Integrate LZ4 library, compress the ramdisk
All checks were successful
Build documentation / build-and-deploy (push) Successful in 1m53s

This commit is contained in:
2026-03-07 02:54:26 +01:00
parent eaec32975a
commit b9e8a8bf1d
234 changed files with 52373 additions and 13 deletions

56
lz4/.github/workflows/README.md vendored Normal file
View File

@@ -0,0 +1,56 @@
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
## Sanitizers (UBSan, ASan) - `sanitizers.yml`
### 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,
which means that, in some future, some new architecture or some new compiler
may decide to do something funny that could break this behavior.
Hence, in anticipation, it's better to remove them.
This has been already achieved in `lz4hc.c`.
However, the same attempt in `lz4.c` resulted in massive speed losses,
which is not an acceptable cost for preemptively solving a "potential future" problem
not active anywhere today.
Therefore, a more acceptable work-around will have to be found first.
## 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.

109
lz4/.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.event.pull_request.number || github.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.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

127
lz4/.github/workflows/cmake-test.yml vendored Normal file
View File

@@ -0,0 +1,127 @@
# Simplified CMake Build Tests
name: CMake Build Tests
on:
push:
branches: ['dev', 'release', '*cmake*']
pull_request:
branches: ['dev', 'release']
permissions:
contents: read
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
jobs:
# Core functionality test - multi-platform
cmake-core-tests:
name: Core Tests (${{ matrix.os }}, ${{ matrix.build_type }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
build_type: Release
generator: ""
- os: ubuntu-latest
build_type: Debug
generator: ""
- os: windows-latest
build_type: Release
generator: '-G "Visual Studio 17 2022" -A x64'
- os: macos-latest
build_type: Release
generator: ""
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Set up MSVC (Windows)
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v2
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: latest
- name: Configure and Build
shell: bash
run: |
mkdir cmakebuild && cd cmakebuild
cmake ../build/cmake ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build . --config ${{ matrix.build_type }}
- name: Test Installation (Linux only)
if: runner.os == 'Linux'
shell: bash
run: |
cd cmakebuild
cmake --install . --prefix install-test
test -f "install-test/lib/liblz4.a" || test -f "install-test/lib/liblz4.so"
test -f "install-test/include/lz4.h"
# CMake compatibility and integration tests
cmake-extended-tests:
name: Extended Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_type:
- cmake_versions
- static_lib
- integration
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ matrix.test_type == 'cmake_versions' && '3.10.0' || 'latest' }}
- name: CMake Version Compatibility Test
if: matrix.test_type == 'cmake_versions'
run: |
mkdir cmakebuild && cd cmakebuild
cmake ../build/cmake
cmake --build .
- name: Static Library Test
if: matrix.test_type == 'static_lib'
run: |
# Build and install static library
CFLAGS="-Werror -O1" cmake -S build/cmake -B build -DBUILD_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install
cmake --build build --target install
# Test find_package with static library
cmake -S tests/cmake -B build_test -DCMAKE_PREFIX_PATH=$PWD/install
cmake --build build_test
- name: Integration Test
if: matrix.test_type == 'integration'
run: |
# Build and install
cmake -S build/cmake -B build -DCMAKE_INSTALL_PREFIX=$PWD/install
cmake --build build --target install
# Test find_package
cmake -S tests/cmake -B test_build -DCMAKE_PREFIX_PATH=$PWD/install
cmake --build test_build
cd test_build && ctest -V
# Makefile wrapper test
make-cmake-test:
name: Make CMake
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.2
- name: Test via Makefile
run: make clean && make cmakebuild

105
lz4/.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.event.pull_request.number || github.ref }}
jobs:
cppcheck:
name: Cppcheck Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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 examples

112
lz4/.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.event.pull_request.number || github.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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
lz4/.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.event.pull_request.number || github.ref }}
jobs:
benchmark:
name: Benchmark Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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

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.event.pull_request.number || github.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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
lz4/.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.event.pull_request.number || github.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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
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.event.pull_request.number || github.ref }}
jobs:
check-git-tag:
name: Git Version Tag Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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
lz4/.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.event.pull_request.number || github.ref }}
jobs:
ubsan-x64:
name: UndefinedBehaviorSanitizer (x64)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: TSan - CLI test
run: |
make clean
CC=clang CPPFLAGS="-fsanitize=thread" make -j -C tests test-lz4 V=1

65
lz4/.github/workflows/scorecard.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.
name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '23 22 * * 3'
push:
branches: [ "dev" ]
# Declare default permissions as read only.
permissions: read-all
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
steps:
- name: "Checkout code"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# you want to enable the Branch-Protection check on a *public* repository
# To create the PAT, follow the steps in
# https://github.com/ossf/scorecard-action#authentication-with-fine-grained-pat-optional
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
publish_results: true
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: SARIF file
path: results.sarif
retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
with:
sarif_file: results.sarif