name: CI
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- "--no-default-features"
- "--no-default-features --features authentication"
- "--no-default-features --features completion"
- "--no-default-features --features history"
- "--no-default-features --features async"
- "--no-default-features --features authentication,completion"
- "--no-default-features --features authentication,history"
- "--no-default-features --features completion,history"
- "--no-default-features --features completion,history,async"
- "--all-features"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Sanitize cache key
id: cache-key
run: echo "key=$(echo '${{ matrix.features }}' | sed 's/,/-/g' | sed 's/ /-/g')" >> $GITHUB_OUTPUT
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}-${{ steps.cache-key.outputs.key }}
- name: Run tests
run: cargo test ${{ matrix.features }}
clippy:
name: Clippy (Linting)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy (all features)
run: cargo clippy --all-features --all-targets -- -D warnings
- name: Run clippy (no default features)
run: cargo clippy --no-default-features --all-targets -- -D warnings
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
no-std:
name: no_std Compatibility
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: thumbv6m-none-eabi
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-nostd-${{ hashFiles('**/Cargo.lock') }}
- name: Check no_std build (no features)
run: cargo check --target thumbv6m-none-eabi --no-default-features
- name: Check no_std build (all features)
run: cargo check --target thumbv6m-none-eabi --features authentication,completion,history,async
examples:
name: Example Projects
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example:
- native
- rp-pico
- stm32f072
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: thumbv6m-none-eabi
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Check example builds
run: |
cd examples/${{ matrix.example }}
cargo check --all-features