calnexus 0.2.0

A command-line math expression evaluator with 11 core and 3 optional (time/unit/fx) computation domains plus a numerical-linalg feature, symbolic calculus, REPL, batch processing, HTTP and MCP servers
Documentation
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 # v7.0.1
      - name: Install pinned rustfmt
        # 工具链钉住(不随最新 stable 漂移):本 job 原用 dtolnay/rust-toolchain@stable,
        # 而 runner 上的最新 stable rustfmt 会把混合大小写导入按小写优先重排
        # (实测 run 39446066779 对 fuzz/fuzz_targets/*.rs 要求
        # `use calnexus::{parse, AstCanonicalizer}`),本地 1.97.1(= 本仓 MSRV,见下方
        # MSRV job)的 rustfmt 1.9.0-stable 却认为现有序就是已格式化——
        # 两边互斥会使门禁变成不定量。钉到 1.97.1 后 CI 与开发环境同一口径;
        # 其余 job(clippy/test/coverage)仍跑最新 stable,保留新工具链的拦截能力。
        uses: dtolnay/rust-toolchain@1.97.1
        with:
          components: rustfmt
      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
      - name: Check formatting
        run: cargo fmt --all -- --check
      - name: Check fuzz workspace formatting
        # 不再用 `+stable` 强推:那会绕过钉住版本使本腿重新变成随 runner 镜像漂移的检查。
        # fuzz/ 目录的 rust-toolchain.toml 钉 nightly 是为 cargo-fuzz 的 -Zsanitizer,
        # 与格式化无关,此处显式用 1.97.1 统一口径。
        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 # v7.0.1
      - 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 # v2.9.3
      - 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 # v7.0.1
      - 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 # v2.9.3
      - 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 # v7.0.1
      - 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 # v2.9.3
      - name: Check with MSRV
        # wasm-api 仅 wasm32 可用,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 # v7.0.1
      - 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 # v2.9.3
      - name: Build release
        run: cargo build --release --features cli

  # wasm32 构建门禁:只覆盖 lib+bins。测试/基准目标依赖的 dev-dependencies
  # (getrandom 0.4 等)需要 wasm_js 特性,不在本 job 承诺范围。
  wasm32:
    name: wasm32 build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown
          components: clippy
      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
      - 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 # v7.0.1
      - 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 # v2.9.3
      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3
        with:
          tool: cargo-llvm-cov
      - name: Run coverage
        # 门禁 95%(发布编排统一口径)。实测基线:本命令行覆盖率 95.57%
        # (28653 行 / 1269 未覆盖),区域 95.83%;wasm-api 不在原生腿启用。
        run: cargo llvm-cov --features "cli,time,unit,fx" --fail-under-lines 95 --summary-only