name: CI
on:
push:
branches:
- main
- master
pull_request:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install pinned rustfmt
uses: dtolnay/rust-toolchain@1.97.1
with:
components: rustfmt
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Check formatting
run: cargo fmt --all -- --check
- name: Check fuzz workspace formatting
run: cargo fmt --all --manifest-path fuzz/Cargo.toml -- --check
clippy:
name: Clippy (${{ matrix.features }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- cli
- cli,server
- all
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Run clippy (${{ matrix.features }})
run: |
if [ "${{ matrix.features }}" = "all" ]; then
# wasm-api 仅 wasm32 可用(非 wasm 启用会 compile_error),从 all 腿排除;
# default 同理(all 腿显式列举 feature,不带 default)。
# http/mcp 必须在列表内:feature-matrix 只跑 cargo hack check(编译),
# clippy 仅在本腿执行——漏列即这两个 feature 的 lint 缺口。
cargo clippy --features "cli,server,time,unit,fx,numerical,ratelimit,docs,observability,icu,egraph,http,mcp" --all-targets -- -D warnings
else
cargo clippy --features ${{ matrix.features }} --all-targets -- -D warnings
fi
test:
name: Test (${{ matrix.features }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
features:
- cli
- cli,time,unit,fx
- cli,server
- cli,server,fx
- cli,numerical
- all
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Run tests (${{ matrix.features }})
run: |
if [ "${{ matrix.features }}" = "all" ]; then
# wasm-api 仅 wasm32 可用,从 all 腿排除
cargo test --features "cli,server,time,unit,fx,numerical,ratelimit,docs,observability,icu,egraph"
else
cargo test --features "${{ matrix.features }}"
fi
- name: Check single features
run: |
cargo check --features time
cargo check --features unit
cargo check --features fx
cargo check --features numerical
msrv:
name: MSRV (1.97.1)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Install Rust 1.97.1
run: |
rustup toolchain install 1.97.1 --profile minimal
rustup default 1.97.1
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Check with MSRV
run: cargo check --features "cli,server,time,unit,fx,numerical,ratelimit,docs,observability,icu,egraph"
build:
name: Build (release)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Build release
run: cargo build --release --features cli
wasm32:
name: wasm32 build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
components: clippy
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Build (no default features)
run: cargo build --lib --bins --target wasm32-unknown-unknown --no-default-features
- name: Build (cli)
run: cargo build --lib --bins --target wasm32-unknown-unknown --features cli
- name: Build (cli,wasm-api)
run: cargo build --lib --bins --target wasm32-unknown-unknown --features cli,wasm-api
- name: Clippy (wasm32, cli)
run: cargo clippy --target wasm32-unknown-unknown --features cli -- -D warnings
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 - name: Install cargo-llvm-cov
uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 with:
tool: cargo-llvm-cov
- name: Run coverage
run: cargo llvm-cov --features "cli,time,unit,fx" --fail-under-lines 95 --summary-only