libzstd-rs-sys 0.0.0

a rust implementation of zstd compression and decompression
Documentation
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
            flags: "--workspace"
            codecov: true

          - target: "i686-unknown-linux-gnu"
            rust: stable
            os: ubuntu-latest
            flags: "--workspace"
            codecov: true
            packages: gcc-i686-linux-gnu

          - target: "s390x-unknown-linux-gnu"
            rust: stable
            os: ubuntu-latest
            flags: "--workspace"
            codecov: false
            packages: gcc-s390x-linux-gnu qemu-user qemu-user-static

          - target: "aarch64-unknown-linux-gnu"
            rust: stable
            os: ubuntu-24.04-arm
            flags: "--workspace"
            codecov: true

          - target: "wasm32-wasip2"
            rust: stable
            os: ubuntu-latest
            flags: "-p libzstd-rs-sys" # cross-compiling zstd for wasm does not work
            codecov: false

          - target: "aarch64-apple-darwin"
            rust: stable
            os: macos-latest
            flags: "--workspace"
            codecov: true

          - target: "x86_64-pc-windows-gnu"
            rust: stable 
            os: windows-2022
            flags: "--workspace"
            codecov: false

          - target: "aarch64-pc-windows-msvc"
            rust: stable 
            os: windows-11-arm
            flags: "--workspace"
            codecov: false
    steps:
      - name: Checkout sources
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
        with:
          persist-credentials: false
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
        with:
          toolchain: nightly
          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@bb5b6ec0fe226d4254f80ec39794c3a8c1b6525f # v2.58.25
        with:
          tool: cargo-llvm-cov,cargo-nextest
      - name: Cache apt packages
        if: matrix.packages != ''
        uses: awalsh128/cache-apt-pkgs-action@v1
        with:
          packages: "${{ matrix.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.flags }}
      - name: cargo llvm-cov nextest
        if: matrix.codecov == false
        run: cargo nextest run --target ${{matrix.target}} ${{ matrix.flags }}
      # - name: Upload coverage to Codecov
      #   uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
      #   if: matrix.codecov && matrix.rust == 'stable'
      #   with:
      #     files: |
      #       ./lcov.info
      #       ./cdylib.lcov.info
      #     fail_ci_if_error: false
      #     flags: test-${{matrix.target}}
      #     token: ${{ secrets.CODECOV_TOKEN }}
      #     name: test
      #     verbose: true

  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"

  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@bb5b6ec0fe226d4254f80ec39794c3a8c1b6525f # v2.58.25
        with:
          tool: cargo-nextest
      #      - name: Test public C api with miri
      #        env:
      #          QUICKCHECK_TESTS: 10
      #          RUSTFLAGS: "-Awarnings"
      #        run: |
      #          cargo +nightly miri nextest run -j4 -p test-libzstd-rs-sys
      - name: Run unit tests with miri
        env:
          QUICKCHECK_TESTS: 10
          RUSTFLAGS: "-Awarnings"
        run: |
          cargo +nightly miri nextest run -j4 -p libzstd-rs-sys