From d839476128410e20bd00b160a84e9b60d40dbb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=A5=E4=B8=8B=E7=BA=A2=E8=8D=AF?= Date: Fri, 16 Jan 2026 20:44:13 +0800 Subject: [PATCH] update --- .github/workflows/rust.yml | 81 ++++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 000bb2c..829cb45 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,13 +10,78 @@ env: CARGO_TERM_COLOR: always jobs: - build: - + # 代码格式检查 + fmt: + name: Code Formatting runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Check formatting + run: cargo fmt --all -- --check + + # 构建和测试 + test: + name: Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Cache target directory + uses: actions/cache@v3 + with: + path: target + key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }} + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + - name: Build examples + run: cargo build --examples --verbose + + # 测试不同的 feature 组合 + test-features: + name: Test Features + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + features: + - "" + - "mimalloc" + steps: + - uses: actions/checkout@v4 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + - name: Cache cargo registry + uses: actions/cache@v3 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + - name: Build with features + run: | + if [ -z "${{ matrix.features }}" ]; then + cargo build --verbose + else + cargo build --verbose --features "${{ matrix.features }}" + fi + - name: Test with features + run: | + if [ -z "${{ matrix.features }}" ]; then + cargo test --verbose + else + cargo test --verbose --features "${{ matrix.features }}" + fi