run the bzip2-rs
test suite
#404
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" | |
strategy: | |
matrix: | |
include: | |
- rust: stable | |
os: ubuntu-latest | |
features: "" | |
target: "x86_64-unknown-linux-gnu" | |
- rust: msrv | |
os: ubuntu-latest | |
features: "" | |
target: "x86_64-unknown-linux-gnu" | |
- rust: beta | |
os: ubuntu-latest | |
features: "" | |
target: "x86_64-unknown-linux-gnu" | |
- rust: "stable" | |
os: macos-latest | |
features: "" | |
target: "x86_64-apple-darwin" | |
- rust: "stable" | |
os: macos-14 | |
features: "" | |
target: "aarch64-apple-darwin" | |
- rust: stable-x86_64-gnu | |
os: windows-2022 | |
features: "" | |
target: "x86_64-pc-windows-gnu" | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
submodules: true | |
- name: Set target rust version | |
run: echo "TARGET_RUST_VERSION=$(if [ "${{matrix.rust}}" = "msrv" ]; then grep rust-version Cargo.toml | grep MSRV | cut -d'"' -f2; else echo "${{matrix.rust}}"; fi)" >> $GITHUB_ENV | |
if: matrix.os != 'windows-2022' | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: "${TARGET_RUST_VERSION}" | |
targets: "${{ matrix.target }}" | |
if: matrix.os != 'windows-2022' | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: "${{matrix.rust}}" | |
targets: "${{ matrix.target }}" | |
if: matrix.os == 'windows-2022' | |
- name: target | |
run: "rustc -vV | sed -n 's|host: ||p'" | |
if: matrix.os != 'windows-2022' | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8 | |
with: | |
tool: cargo-llvm-cov | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8 | |
with: | |
tool: cargo-nextest | |
- name: cargo build | |
run: cargo build --target ${{matrix.target}} ${{ matrix.features }} | |
- name: cargo build (no_std) | |
run: cargo rustc --target ${{matrix.target}} -p libbz2-rs-sys --lib --no-default-features --crate-type rlib | |
env: | |
RUSTFLAGS: -Aunused_variables -Aunused_assignments | |
- name: cargo build (no_std + rust_allocator) | |
run: cargo rustc --target ${{matrix.target}} -p libbz2-rs-sys --lib --no-default-features --features rust-allocator --crate-type rlib | |
env: | |
RUSTFLAGS: -Aunused_variables -Aunused_assignments | |
- name: cargo nextest # reports segfaults in a helpful way | |
run: cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} --no-fail-fast --workspace | |
env: | |
RUST_BACKTRACE: 1 | |
- name: cargo test with llvm-cov | |
run: cargo llvm-cov --target ${{matrix.target}} ${{ matrix.features }} --lcov --output-path lcov.info --ignore-filename-regex "test-libbz2" --workspace | |
env: | |
RUST_BACKTRACE: 1 | |
if: matrix.os != 'windows-2022' | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d | |
if: matrix.os != 'windows-2022' | |
with: | |
files: lcov.info | |
fail_ci_if_error: false | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: codecov/codecov-demo | |
build-qemu: | |
name: QEMU build & test | |
runs-on: "${{ matrix.os }}" | |
strategy: | |
matrix: | |
include: | |
- rust: stable | |
os: ubuntu-latest | |
features: "" | |
target: "s390x-unknown-linux-gnu" | |
gcc: "s390x-linux-gnu-gcc" | |
runner: "qemu-s390x -L /usr/s390x-linux-gnu" | |
- rust: stable | |
os: ubuntu-latest | |
features: "" | |
target: "i686-unknown-linux-gnu" | |
gcc: "i686-linux-gnu-gcc" | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
submodules: true | |
- uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: qemu-user qemu-user-static qemu-system-s390x gcc-s390x-linux-gnu gcc-i686-linux-gnu g++-s390x-linux-gnu | |
version: 1.0 | |
- name: Copy QEMU Cargo Config | |
run: | | |
mkdir -p .cargo | |
cp qemu-cargo-config.toml .cargo/config.toml | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: "stable" | |
targets: "${{ matrix.target }}" | |
- name: target | |
run: "rustc -vV | sed -n 's|host: ||p'" | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8 | |
with: | |
tool: cargo-nextest | |
- name: cargo build | |
run: cargo build --target ${{matrix.target}} ${{ matrix.features }} | |
- name: cargo nextest # reports segfaults in a helpful way | |
run: RUNNER="${{ matrix.runner }}" cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} | |
env: | |
RUST_BACKTRACE: 1 | |
CC: ${{matrix.gcc}} | |
clippy: | |
name: Clippy | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
features: | |
- "" | |
- '--no-default-features --features="c-allocator"' | |
- '--no-default-features --features="std,rust-allocator"' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
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@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 | |
with: | |
shared-key: "stable-${{matrix.target}}" | |
- name: Run clippy | |
run: cargo clippy --target ${{matrix.target}} ${{matrix.features}} --workspace --all-targets -- -D warnings | |
fuzz: | |
name: Smoke-test fuzzing targets | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
features: default | |
- os: ubuntu-20.04 | |
features: c-allocator | |
- os: ubuntu-20.04 | |
features: rust-allocator | |
- os: macos-14 | |
features: "" | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
submodules: true | |
- name: Install nightly toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: nightly | |
- name: Install cargo fuzz | |
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8 | |
with: | |
tool: cargo-fuzz | |
- name: Smoke-test fuzz targets | |
run: | | |
cargo fuzz build --no-default-features --features="${{ matrix.features }}" | |
for target in $(cargo fuzz list); do | |
if [ "$target" = "uncompress2" ]; then | |
features="${{ matrix.features }} disable-checksum" | |
else | |
features="${{ matrix.features }}" | |
fi | |
RUST_BACKTRACE=1 cargo fuzz run --no-default-features --features="$features" $target -- -max_total_time=10 | |
done | |
wasm32: | |
name: "wasm32" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
submodules: true | |
- name: Install wasmtime | |
run: curl https://wasmtime.dev/install.sh -sSf | bash | |
- name: Copy .cargo/config.toml | |
run: | | |
mkdir -p .cargo | |
cp qemu-cargo-config.toml .cargo/config.toml | |
- name: Install toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: "stable" | |
targets: "wasm32-wasip1" | |
- name: target | |
run: "rustc -vV | sed -n 's|host: ||p'" | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8 | |
with: | |
tool: cargo-nextest | |
- name: Download wasi-sdk | |
run: | | |
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz | tar xz | |
- name: cargo nextest (without SIMD) | |
run: | | |
export CC="$(pwd)/wasi-sdk-24.0-x86_64-linux/bin/clang" | |
export CFLAGS="-target wasm32-wasip1" | |
cargo nextest run -p libbz2-rs-sys -p test-libbz2-rs-sys --target wasm32-wasip1 \ | |
-- --skip high_level_write --skip open_and_close # These tests use temp_dir | |
env: | |
RUST_BACKTRACE: 1 | |
RUSTFLAGS: "" | |
miri: | |
name: "Miri" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
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@56ab7930c591507f833cbaed864d201386d518a8 | |
with: | |
tool: cargo-nextest | |
- name: Test public C api with miri | |
run: | | |
cargo +nightly miri nextest run -j4 -p test-libbz2-rs-sys miri_ | |
- name: Run unit tests with miri | |
run: "cargo +nightly miri nextest run -j4 -p libbz2-rs-sys" | |
link-c-dynamic-library: | |
name: vanilla dynamic library | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
features: | |
- '' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: stable | |
targets: ${{matrix.target}} | |
- name: "cdylib: default settings" | |
working-directory: libbz2-rs-sys-cdylib | |
env: | |
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps" | |
run: | | |
cargo build --release --target ${{matrix.target}} | |
cc -o bzpipe bzpipe.c target/${{matrix.target}}/release/deps/libbz2_rs.so -I ../ | |
./bzpipe < Cargo.toml | ./bzpipe -d > out.txt | |
cmp -s Cargo.toml out.txt | |
- name: "cdylib: no stdio" | |
env: | |
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps" | |
working-directory: libbz2-rs-sys-cdylib | |
run: | | |
cargo build --release --target ${{matrix.target}} --no-default-features | |
cc -DNO_STD -o bzpipe bzpipe.c target/${{matrix.target}}/release/deps/libbz2_rs.so -I ../ | |
./bzpipe < Cargo.toml | ./bzpipe -d > out.txt | |
cmp -s Cargo.toml out.txt | |
- name: "staticlib: no stdio" | |
env: | |
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps" | |
working-directory: libbz2-rs-sys-cdylib | |
run: | | |
cargo build --release --target ${{matrix.target}} --no-default-features | |
cc -o bzpipe bzpipe.c target/${{matrix.target}}/release/deps/libbz2_rs.so -I ../ | |
./bzpipe < Cargo.toml | ./bzpipe -d > out.txt | |
cmp -s Cargo.toml out.txt | |
- name: "cdylib: custom-prefix" | |
working-directory: libbz2-rs-sys-cdylib | |
env: | |
LIBBZ2_RS_SYS_PREFIX: "MY_CUSTOM_PREFIX_" | |
run: | | |
cargo build --release --target ${{matrix.target}} --features=custom-prefix | |
objdump -tT target/${{matrix.target}}/release/deps/libbz2_rs.so | grep -q "MY_CUSTOM_PREFIX_BZ2_bzCompressInit" || (echo "symbol not found!" && exit 1) | |
cargo-c-dynamic-library: | |
name: cargo-c dynamic library | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
features: | |
- '' | |
# At the time of writing, 'latest' referred to ubuntu-22 | |
# for libabigail we really need ubuntu-24, which just started getting rolled out | |
# In the future, this can likely be changed to `ubuntu-latest` again. | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 | |
with: | |
toolchain: stable | |
targets: ${{matrix.target}} | |
- name: Install cargo-c | |
env: | |
LINK: https://github.com/lu-zero/cargo-c/releases/download/v0.10.5 | |
run: | | |
curl -L "$LINK/cargo-c-x86_64-unknown-linux-musl.tar.gz" | | |
tar xz -C $HOME/.cargo/bin | |
- name: build with and test the result of cargo-c | |
working-directory: libbz2-rs-sys-cdylib | |
run: | | |
# build using cargo-c this time | |
cargo cinstall --release --destdir=/tmp/cargo-cbuild-libbzip2-rs # somehow --offline does not work here | |
tree /tmp/cargo-cbuild-libbzip2-rs | |
# verify that the SONAME is set and includes a version | |
objdump -p target/x86_64-unknown-linux-gnu/release/libbz2_rs.so | awk '/SONAME/{print $2}' | grep -E 'libbz2_rs\.so\.1' | |
# build bzpipe with our library | |
cc -o bzpipe bzpipe.c -L/tmp/cargo-cbuild-libbzip2-rs/usr/local/lib/x86_64-linux-gnu -lbz2_rs -I ../ | |
export LD_LIBRARY_PATH=/tmp/cargo-cbuild-libbzip2-rs/usr/local/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH | |
./bzpipe < Cargo.toml | ./bzpipe -d > out.txt | |
cmp -s Cargo.toml out.txt | |
- name: verify api surface with abigail | |
run: | | |
sudo apt install libbz2-dev abigail-tools | |
LIBBZ2_PATH=$(ldconfig -p | grep "x86_64-linux-gnu/libbz2.so" | head -n 1 | awk '{print $4}') | |
LIBBZ2_FILENAME=$(basename "$LIBBZ2_PATH") | |
abidw $LIBBZ2_PATH > /tmp/$LIBBZ2_FILENAME.abi | |
abidw /tmp/cargo-cbuild-libbzip2-rs/usr/local/lib/x86_64-linux-gnu/libbz2_rs.so > /tmp/liblibz_rs_sys.so.abi | |
abidiff --no-unreferenced-symbols --ignore-soname /tmp/$LIBBZ2_FILENAME.abi /tmp/liblibz_rs_sys.so.abi | |
run-bzip2-rs-test-suite: | |
name: run bzip2-rs test suite | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
features: | |
- '' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
persist-credentials: false | |
- name: run | |
run: | | |
cd .. | |
git clone [email protected]:trifectatechfoundation/bzip2-rs.git | |
cd bzip2-rs | |
sed '/^\[dependencies\.libbz2-rs-sys\]/,/^$/ s/^version = .*/path = "..\/libbzip2-rs\/libbz2-rs-sys"/' Cargo.toml | |
cargo test --no-default-features --features="libbz2-rs-sys" |