name: Cargo Build & Test
on:
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
build_and_test:
name: Rust project - latest
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
os:
- ubuntu-latest
- macos-latest
- windows-latest
features:
- [zstd,lzma,lz4]
include:
- toolchain: stable
os: ubuntu-latest
features: [zstd]
- toolchain: stable
os: ubuntu-latest
features: [lzma]
- toolchain: stable
os: ubuntu-latest
features: [lz4]
- toolchain: stable
os: ubuntu-latest
features: [zstd,lzma]
- toolchain: stable
os: ubuntu-latest
features: [zstd,lz4]
- toolchain: stable
os: ubuntu-latest
features: [lzma,lz4]
runs-on: ${{ matrix.os }}
env:
SCCACHE_GHA_ENABLED: on
RUSTC_WRAPPER: sccache
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ matrix.toolchain }}-${{ join(matrix.features, '_') }}-${{ hashFiles('**/Cargo.lock') }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Setup rust toolchain ${{ matrix.toolchain }}
run: |
rustup update ${{ matrix.toolchain }}
rustup default ${{ matrix.toolchain }}
rustup component add rustfmt
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@v1.15.7
- name: Check format
run: |
cargo fmt --check
- name: MSRV
run: |
cargo binstall cargo-msrv -y
cargo msrv --output-format minimal verify
- name: Test code
run: cargo test --features ${{ join(matrix.features) }} --verbose
- name: Test binary compilation
if: ${{ matrix.toolchain == 'stable' && join(matrix.features) == 'zstd,lzma,lz4' }}
run: cargo build --features zstd,lzma,lz4,build_bin,explorable_serde --verbose
- name: Build and run exemples
run: |
cargo build --examples
cargo run --example simple_create
cargo run --example simple_read
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: binary-${{ runner.os }}-jbk
path: |
target/debug/jbk
target/debug/jbk.exe
compression-level: 0
compilation_32bits:
name: Test 32 bits compilation
runs-on: ubuntu-latest
env:
SCCACHE_GHA_ENABLED: on
RUSTC_WRAPPER: sccache
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-cross32-${{ hashFiles('**/Cargo.lock') }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Install cross
run: cargo install cross
- name: Test code
run: cross test --verbose --target=i686-unknown-linux-gnu
check_publication:
name: Check we can publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Dry Run Pubish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --dry-run