name: CI
on:
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
name: ${{ matrix.label || matrix.rust }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
continue-on-error: ${{ matrix.rust == 'beta' }}
strategy:
fail-fast: false
matrix:
include:
- rust: "1.91"
label: msrv
os: ubuntu-latest
- rust: stable
os: ubuntu-latest
- rust: stable
os: macos-latest
- rust: stable
os: windows-latest
- rust: beta
os: ubuntu-latest
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with:
toolchain: ${{ matrix.rust }}
components: ${{ matrix.label != 'msrv' && 'rustfmt, clippy' || '' }}
- name: Cache cargo registry
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
cache-all-crates: true
- name: Check formatting
if: matrix.rust == 'stable'
run: cargo fmt --check
- name: Run clippy
if: matrix.label != 'msrv'
run: cargo clippy --all-features -- -D warnings
- name: Run tests (all features)
run: cargo test --all-features
- name: Run FFI tests
if: matrix.rust == 'stable'
run: cargo test --features ffi
- name: Run clippy (encryption, SDK config)
if: matrix.rust == 'stable'
run: cargo clippy --features encryption --all-targets -- -D warnings
- name: Run tests (encryption, SDK config)
if: matrix.rust == 'stable'
run: cargo test --features encryption
wasm32:
name: wasm32 / ratio-product vector
runs-on: ubuntu-latest
timeout-minutes: 20
env:
WASM_BINDGEN_VERSION: "0.2.121"
WASM_BINDGEN_SHA256: "3039f38f65fe237b640cf06a140c919ca8d717ec5012146d145d3f27bb4d6b28" steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
cache-all-crates: true
- name: Guard wasm-bindgen lockfile drift
run: |
locked=$(cargo pkgid wasm-bindgen | sed 's/.*[@#]//')
if [ "$locked" != "$WASM_BINDGEN_VERSION" ]; then
echo "::error::Cargo.lock has wasm-bindgen $locked but this job pins the $WASM_BINDGEN_VERSION test runner. Update WASM_BINDGEN_VERSION, WASM_BINDGEN_SHA256 and the wasm-bindgen-test pin in Cargo.toml together."
exit 1
fi
- name: Install Node (wasm-bindgen-test-runner host)
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 with:
node-version: "22"
- name: Install wasm-bindgen-test-runner
run: |
curl -sSfL --retry 3 -o /tmp/wbg.tar.gz \
"https://github.com/wasm-bindgen/wasm-bindgen/releases/download/${WASM_BINDGEN_VERSION}/wasm-bindgen-${WASM_BINDGEN_VERSION}-x86_64-unknown-linux-musl.tar.gz"
echo "${WASM_BINDGEN_SHA256} /tmp/wbg.tar.gz" | sha256sum -c -
tar -xzf /tmp/wbg.tar.gz -C /tmp
mkdir -p "$HOME/.wbg-bin"
install -m 0755 "/tmp/wasm-bindgen-${WASM_BINDGEN_VERSION}-x86_64-unknown-linux-musl/wasm-bindgen-test-runner" "$HOME/.wbg-bin/"
echo "$HOME/.wbg-bin" >> "$GITHUB_PATH"
- name: Run the ratio-product vector on wasm32
shell: bash
env:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: wasm-bindgen-test-runner
run: |
cargo test --target wasm32-unknown-unknown --features wasm \
--test wire_format_constructed 2>&1 | tee wasm32-test.log
grep -qxF 'test envelope_ratio_product_wraps_32_bits ... ok' wasm32-test.log
grep -qE '^test result: ok\. 1 passed; 0 failed' wasm32-test.log
- name: Run the LZ4 compress-bound round trip on wasm32
shell: bash
env:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: wasm-bindgen-test-runner
run: |
cargo test --target wasm32-unknown-unknown --features wasm \
--test compress_bound_32_bits 2>&1 | tee wasm32-compress-bound.log
grep -qxF 'test store_retrieve_past_32_bit_compress_bound ... ok' wasm32-compress-bound.log
grep -qE '^test result: ok\. 1 passed; 0 failed' wasm32-compress-bound.log
perf-ir:
name: perf-ir / instruction counts vs base
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 with:
persist-credentials: false
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8
- name: Cache cargo registry
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
cache-all-crates: true
- name: Install valgrind
run: |
sudo apt-get update -q
sudo apt-get install -y -q --no-install-recommends valgrind
- name: Gate Ir/op against the merge-base
env:
BASE_REF: origin/${{ github.base_ref }}
run: scripts/perf-ir-vs-base.sh "$BASE_REF"
security:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8
- name: Cache cargo registry
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
cache-all-crates: true
- name: Install security tools
run: cargo install cargo-deny cargo-audit
- name: Check dependencies (licenses & security advisories)
run: cargo deny check
- name: Run cargo audit
run: cargo audit