mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
103 lines
3.1 KiB
YAML
103 lines
3.1 KiB
YAML
name: Test
|
||
|
||
on:
|
||
pull_request:
|
||
push:
|
||
branches:
|
||
- main
|
||
|
||
permissions:
|
||
contents: read
|
||
|
||
# 同一分支的旧运行自动取消,避免排队浪费
|
||
concurrency:
|
||
group: test-${{ github.ref }}
|
||
cancel-in-progress: true
|
||
|
||
env:
|
||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||
|
||
jobs:
|
||
test:
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 30
|
||
steps:
|
||
- name: Checkout code
|
||
uses: actions/checkout@v5
|
||
|
||
- name: Setup pnpm and Node.js
|
||
uses: pnpm/setup@v2
|
||
with:
|
||
runtime: node@24
|
||
install: false
|
||
|
||
- name: Get pnpm store directory
|
||
shell: bash
|
||
run: |
|
||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||
|
||
- name: Setup pnpm cache
|
||
uses: actions/cache@v5
|
||
with:
|
||
path: ${{ env.STORE_PATH }}
|
||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||
restore-keys: |
|
||
${{ runner.os }}-pnpm-store-
|
||
|
||
- name: Setup Rust toolchain
|
||
uses: dtolnay/rust-toolchain@stable
|
||
with:
|
||
targets: wasm32-unknown-unknown
|
||
|
||
- name: Install wasm-pack
|
||
shell: bash
|
||
run: |
|
||
archive="$RUNNER_TEMP/wasm-pack.tar.gz"
|
||
directory="$RUNNER_TEMP/wasm-pack-v0.15.0-x86_64-unknown-linux-musl"
|
||
curl --proto '=https' --tlsv1.2 -LsSf \
|
||
https://github.com/wasm-bindgen/wasm-pack/releases/download/v0.15.0/wasm-pack-v0.15.0-x86_64-unknown-linux-musl.tar.gz \
|
||
-o "$archive"
|
||
echo "c09f971ecaed9a2efc80fdcea7a00ef6b53c7fadc8c57d1f61b53a6aa66b668a $archive" | sha256sum -c -
|
||
tar -xzf "$archive" -C "$RUNNER_TEMP"
|
||
install -m 755 "$directory/wasm-pack" "$CARGO_HOME/bin/wasm-pack"
|
||
|
||
- name: Setup Rust cache
|
||
uses: Swatinem/rust-cache@v2
|
||
with:
|
||
workspaces: packages/parser-native
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: Check workspace dependency declarations
|
||
run: pnpm run check:workspace-deps
|
||
|
||
# 共享 node_modules 的 better-sqlite3 由 pnpm install 保持 Node ABI
|
||
# (desktop 不再有 electron-rebuild postinstall),这里只需准备 CLI 专属副本。
|
||
- name: Prepare better-sqlite3 for Node tests
|
||
run: pnpm --filter chatlab-cli run ensure-native
|
||
|
||
- name: Build MCP package for workspace imports
|
||
run: pnpm --filter chatlab-mcp build
|
||
|
||
- name: Rust unit tests (parser-native)
|
||
working-directory: packages/parser-native
|
||
run: cargo test
|
||
|
||
- name: Build browser parser WASM
|
||
run: pnpm run build:parser-wasm
|
||
|
||
# Debug 构建足够触发 TS 侧 parity 测试(native 缺失时这些测试会自动 skip,
|
||
# 构建后即可在 CI 上真实覆盖 Rust/TS 双路径一致性)。
|
||
- name: Build native parser (debug)
|
||
run: pnpm --filter @openchatlab/parser-native build:debug
|
||
|
||
- name: Unit & integration tests
|
||
run: pnpm test
|
||
|
||
- name: Type check (node)
|
||
run: pnpm run type-check:node
|
||
|
||
- name: Build Web WASM
|
||
run: pnpm run build:web-wasm
|