|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master, dev ] |
| 6 | + pull_request: |
| 7 | + branches: [ master, dev ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + # 1. 检查阶段:Lint, Format, Typecheck |
| 11 | + check: |
| 12 | + name: Check (Rust & TS) |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + # Setup Rust |
| 18 | + - name: Install Rust |
| 19 | + uses: dtolnay/rust-toolchain@stable |
| 20 | + with: |
| 21 | + components: rustfmt, clippy |
| 22 | + |
| 23 | + # Setup Node/pnpm |
| 24 | + - uses: pnpm/action-setup@v4 |
| 25 | + with: |
| 26 | + version: 10 |
| 27 | + - uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: 20 |
| 30 | + cache: 'pnpm' |
| 31 | + |
| 32 | + # Install Dependencies |
| 33 | + - name: Install TS Dependencies |
| 34 | + run: pnpm install |
| 35 | + |
| 36 | + # Rust Checks |
| 37 | + - name: Rust Format Check |
| 38 | + run: cargo fmt --all -- --check |
| 39 | + - name: Rust Clippy |
| 40 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 41 | + |
| 42 | + # TS Checks |
| 43 | + - name: TS Biome Check |
| 44 | + run: pnpm biome check . |
| 45 | + - name: TS Typecheck |
| 46 | + run: pnpm typecheck |
| 47 | + |
| 48 | + # 2. 构建与测试阶段:Build & Test (Matrix OS) |
| 49 | + build-test: |
| 50 | + name: Build & Test |
| 51 | + needs: check |
| 52 | + runs-on: ${{ matrix.os }} |
| 53 | + strategy: |
| 54 | + matrix: |
| 55 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + |
| 59 | + # Setup Rust |
| 60 | + - name: Install Rust |
| 61 | + uses: dtolnay/rust-toolchain@stable |
| 62 | + with: |
| 63 | + targets: wasm32-wasip1 |
| 64 | + |
| 65 | + # Setup Node/pnpm |
| 66 | + - uses: pnpm/action-setup@v4 |
| 67 | + with: |
| 68 | + version: 10 |
| 69 | + - uses: actions/setup-node@v4 |
| 70 | + with: |
| 71 | + node-version: 20 |
| 72 | + cache: 'pnpm' |
| 73 | + |
| 74 | + # Install Dependencies |
| 75 | + - name: Install TS Dependencies |
| 76 | + run: pnpm install |
| 77 | + |
| 78 | + # Rust Build & Test (包括 WASM) |
| 79 | + - name: Rust Build |
| 80 | + run: cargo build --verbose |
| 81 | + - name: Rust Test |
| 82 | + run: cargo test --verbose |
| 83 | + - name: Build WASM Target |
| 84 | + run: cargo build -p hxo-target-wasm --target wasm32-wasip2 --release |
| 85 | + |
| 86 | + # TS Build & Test (直接使用同环境构建出的 WASM) |
| 87 | + - name: TS Build |
| 88 | + run: pnpm build |
| 89 | + - name: TS Test |
| 90 | + run: pnpm test |
0 commit comments