173 lines
4.2 KiB
YAML
173 lines
4.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
lint:
|
|
name: Lint (${{ matrix.features }})
|
|
strategy:
|
|
matrix:
|
|
features: ["--no-default-features", "--all-features", ""]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
components: rustfmt, clippy
|
|
|
|
- name: Check formatting (once)
|
|
if: matrix.features == ''
|
|
run: cargo fmt -- --check
|
|
|
|
- name: Clippy
|
|
run: cargo clippy --all-targets ${{ matrix.features }} -- -D warnings
|
|
|
|
msrv:
|
|
name: MSRV Verification (${{ matrix.features }})
|
|
strategy:
|
|
matrix:
|
|
features: ["--no-default-features", "--all-features", ""]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Extract MSRV from Cargo.toml
|
|
id: msrv
|
|
run: |
|
|
MSRV=$(yq '.package.rust-version' Cargo.toml --unwrapScalar)
|
|
|
|
if [ -z "$MSRV" ]; then
|
|
echo "No MSRV specified in Cargo.toml, using stable"
|
|
MSRV="stable"
|
|
else
|
|
echo "msrv=$MSRV" >> $GITHUB_OUTPUT
|
|
echo "Using MSRV: $MSRV"
|
|
fi
|
|
|
|
- name: Install Rust stable
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ steps.msrv.outputs.msrv }}
|
|
|
|
- name: Install cargo-msrv
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: cargo-msrv
|
|
|
|
- name: Verify MSRV
|
|
run: cargo msrv verify ${{ matrix.features }}
|
|
|
|
test:
|
|
name: Test (${{ matrix.os }}, ${{ matrix.rust }}, ${{ matrix.features }})
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
rust: [stable, nightly]
|
|
features: ["--no-default-features", "--all-features", ""]
|
|
fail-fast: false
|
|
runs-on: ${{ matrix.os }}
|
|
continue-on-error: ${{ matrix.rust == 'nightly' }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
key: ${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('matrix.features') }}
|
|
|
|
- name: Run tests
|
|
run: cargo test --all-targets ${{ matrix.features }}
|
|
|
|
check:
|
|
name: Cargo Check (${{ matrix.features }})
|
|
strategy:
|
|
matrix:
|
|
features: ["--no-default-features", "--all-features", ""]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Cargo check
|
|
run: cargo check ${{ matrix.features }}
|
|
|
|
examples:
|
|
name: Examples
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- uses: Swatinem/rust-cache@v2
|
|
|
|
- name: Build examples
|
|
run: cargo build --examples
|
|
|
|
- name: Run all examples
|
|
run: ./scripts/run_examples.sh
|
|
|
|
# coverage:
|
|
# name: Code Coverage
|
|
# runs-on: ubuntu-latest
|
|
# steps:
|
|
# - uses: actions/checkout@v4
|
|
|
|
# - name: Install Rust
|
|
# uses: dtolnay/rust-toolchain@stable
|
|
|
|
# - name: Install cargo-tarpaulin
|
|
# - uses: taiki-e/install-action@cargo-tarpaulin
|
|
|
|
# - name: Generate code coverage
|
|
# run: cargo tarpaulin --lib --all-features --out Xml --out Lcov --output-dir coverage --fail-under 80
|
|
|
|
security:
|
|
name: Security Audit
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Install cargo-audit
|
|
uses: taiki-e/install-action@cargo-audit
|
|
|
|
- name: Run cargo audit
|
|
run: cargo audit
|
|
|
|
doc:
|
|
name: Documentation (${{ matrix.features }})
|
|
strategy:
|
|
matrix:
|
|
features: ["--no-default-features", "--all-features", ""]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Build documentation
|
|
run: cargo doc --no-deps ${{ matrix.features }}
|