Skip to content

checks

checks #876

Workflow file for this run

name: checks
permissions:
contents: read
on:
push:
branches:
- main
- 'release/**'
pull_request:
branches-ignore:
- 'release/**'
schedule:
- cron: '0 4 * * *'
merge_group:
branches:
- main
jobs:
build:
name: Build and test
runs-on: "${{ matrix.os }}"
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-Awarnings"
# i686-unknown-linux-gnu
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-gcc
# s390x-unknown-linux-gnu
CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER: s390x-linux-gnu-gcc
CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER: qemu-s390x -L /usr/s390x-linux-gnu
# wasm32-wasip2
WASI_SDK_PATH: /tmp/wasi-sdk-24.0-x86_64-linux
CC_wasm32_wasip2: /tmp/wasi-sdk-24.0-x86_64-linux/bin/clang
AR_wasm32_wasip2: /tmp/wasi-sdk-24.0-x86_64-linux/bin/llvm-ar
CARGO_TARGET_WASM32_WASIP2_RUNNER: "wasmtime"
BINDGEN_EXTRA_CLANG_ARGS_wasm32_wasip2: "--sysroot=/tmp/wasi-sdk-24.0-x86_64-linux/share/wasi-sysroot"
strategy:
matrix:
include:
- target: "x86_64-unknown-linux-gnu"
rust: stable
os: ubuntu-latest
codecov: true
- target: "i686-unknown-linux-gnu"
rust: stable
os: ubuntu-latest
codecov: true
apt-packages: gcc-i686-linux-gnu
- target: "s390x-unknown-linux-gnu"
rust: stable
os: ubuntu-latest
apt-packages: gcc-s390x-linux-gnu qemu-user qemu-user-static
- target: "aarch64-unknown-linux-gnu"
rust: stable
os: ubuntu-24.04-arm
codecov: true
- target: "wasm32-wasip2"
rust: stable
os: ubuntu-latest
packages: "-p libzstd-rs-sys" # cross-compiling zstd-sys for wasm does not work
- target: "aarch64-apple-darwin"
rust: stable
os: macos-latest
codecov: true
- target: "x86_64-pc-windows-gnu"
rust: stable
os: windows-2022
- target: "aarch64-pc-windows-msvc"
rust: stable
os: windows-11-arm
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
persist-credentials: false
- name: Install toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
targets: "${{ matrix.target }}"
- name: target
run: "rustc -vV | sed -n 's|host: ||p'"
if: matrix.os != 'windows-2022'
- name: Install cargo-llvm-cov & cargo-nextest
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
with:
tool: cargo-llvm-cov,cargo-nextest
- name: Cache apt packages
if: matrix.apt-packages != ''
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: "${{ matrix.apt-packages }}"
version: 2
- name: Download wasmtime & wasi-sdk
if: matrix.target == 'wasm32-wasip2'
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz | tar xz --directory /tmp
- name: cargo llvm-cov nextest
if: matrix.codecov
run: cargo llvm-cov nextest --lcov --output-path lcov.info --ignore-filename-regex "test-" --target ${{matrix.target}} ${{ matrix.packages || '--workspace' }}
- name: cargo llvm-cov nextest
if: ${{ (matrix.codecov || false) == false }}
run: cargo nextest run --target ${{matrix.target}} ${{ matrix.packages || '--workspace' }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
if: matrix.codecov
with:
files: |
./lcov.info
./cdylib.lcov.info
fail_ci_if_error: false
flags: test-${{matrix.target}}
token: ${{ secrets.CODECOV_TOKEN }}
name: test
verbose: true
clippy:
name: Clippy
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
features:
- ""
- '--no-default-features --features="c-allocator"'
- '--no-default-features --features="rust-allocator"'
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
persist-credentials: false
submodules: true
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
with:
toolchain: stable
components: clippy
targets: ${{matrix.target}}
- name: Rust cache
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1
with:
shared-key: "stable-${{matrix.target}}"
- name: Run clippy
run: cargo clippy --target ${{matrix.target}} ${{matrix.features}} --workspace --all-targets -- -D warnings
fuzz-decompress:
name: fuzz-decompress
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
persist-credentials: false
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: nightly
- name: Install cargo fuzz
run: cargo install cargo-fuzz
- name: Download custom decompression corpus
run: |
wget https://github.com/trifectatechfoundation/compression-corpus/releases/download/2025-08-27-084941/zstd-files.zip
unzip zstd-files.zip -d zstd-files
- name: run the fuzzer
run: |
cargo fuzz run decompress zstd-files/compressed -- -max_total_time=10
cargo fuzz run decompress_overlapping zstd-files/compressed -- -max_total_time=10
env:
RUSTFLAGS: "-Awarnings"
fuzz-dictionary:
name: fuzz-dictionary
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
persist-credentials: false
- name: Install nightly toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: nightly
- name: Install cargo fuzz
run: cargo install cargo-fuzz
- name: run the fuzzer
run: |
cargo fuzz run dictionary_round_trip -- -max_total_time=10
cargo fuzz run dictionary_train -- -dict=./fuzz/dictionaries/dictionary_train.txt -max_total_time=60
cargo fuzz run dictionary_train_fast -- -dict=./fuzz/dictionaries/dictionary_train.txt -max_total_time=60
cargo fuzz run dictionary_train_legacy -- -dict=./fuzz/dictionaries/dictionary_train.txt -max_total_time=60
env:
RUSTFLAGS: "-Awarnings"
miri:
name: "Miri"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
persist-credentials: false
submodules: true
- name: Install Miri
run: |
rustup toolchain install nightly --component miri
cargo +nightly miri setup
- name: Install cargo-nextest
uses: taiki-e/install-action@44c6d64aa62cd779e873306675c7a58e86d6d532 # v2.62.49
with:
tool: cargo-nextest
- name: Run unit tests with miri
env:
QUICKCHECK_TESTS: 10
RUSTFLAGS: "-Awarnings"
run: |
MIRIFLAGS="-Zmiri-tree-borrows" cargo +nightly miri nextest run -j4 --workspace
zstreamtest:
name: "zstreamtest"
runs-on: "${{ matrix.os }}"
env:
RUST_BACKTRACE: 1
strategy:
fail-fast: false
matrix:
include:
- target: "x86_64-unknown-linux-gnu"
os: ubuntu-latest
- target: "aarch64-unknown-linux-gnu"
os: ubuntu-24.04-arm
- target: "aarch64-apple-darwin"
os: macos-latest
- target: "x86_64-pc-windows-gnu"
os: windows-2022
flags: "-lws2_32 -lbcrypt -lntdll -lkernel32 -luserenv -ladvapi32 -lmsvcrt"
steps:
- name: Checkout sources
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
persist-credentials: false
submodules: true
- name: Install toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: stable
targets: "${{ matrix.target }}"
# NOTE: explicitly specifying the target is required on windows where we build for gnu, but the system is msvc.
- name: build staticlib
run: |
cargo build --target ${{ matrix.target }} --features=export-symbols -p libzstd-rs-sys --release --lib
ls target/${{ matrix.target }}/release
env:
RUSTFLAGS: "-C debug-assertions=true"
- name: show the symbols
run: nm -g --defined-only target/${{ matrix.target }}/release/liblibzstd_rs_sys.a | grep "T ZSTD_"
if: matrix.target == 'x86_64-unknown-linux-gnu'
- name: build binary with gcc
shell: bash
run: |
${CC:-gcc} \
-o zstreamtest \
-g \
tests/zstreamtest.c \
programs/timefn.c tests/external_matchfinder.c tests/seqgen.c programs/datagen.c lib/common/xxhash.c lib/common/error_private.c \
target/${{ matrix.target }}/release/liblibzstd_rs_sys.a ${{ matrix.flags }} \
-Itests/ -Iprograms/ -Ilib/ -Ilib/common -Ilib/compress
- name: run test
run: ./zstreamtest -T60s