feat: 重构 CI 工作流,合并 lint、类型检查和测试步骤

This commit is contained in:
2026-07-21 17:31:44 +08:00
parent cbc04fea4f
commit 04082820b0

View File

@@ -7,34 +7,53 @@ on:
push: push:
branches: [main] branches: [main]
# 同一分支有新提交时取消旧任务,避免旧任务持续占用 Gitea runner。
concurrency:
group: ci-${{ gitea.ref }}
cancel-in-progress: true
jobs: jobs:
lint: verify:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30
env:
CI: 'true'
TURBO_UI: stream
steps: steps:
- uses: actions/checkout@v4 - name: 检出代码
- uses: actions/setup-node@v4 uses: actions/checkout@v4
with: timeout-minutes: 3
node-version: '22'
- run: npm ci
- run: npm run lint
typecheck: - name: 安装 Node.js
runs-on: ubuntu-latest uses: actions/setup-node@v4
steps: timeout-minutes: 3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: with:
node-version: '22' node-version: '22'
- run: npm ci cache: npm
- run: npm run typecheck
test: - name: 安装依赖
runs-on: ubuntu-latest run: npm ci --no-audit --no-fund
needs: [lint, typecheck] timeout-minutes: 10
steps:
- uses: actions/checkout@v4 - name: 代码检查
- uses: actions/setup-node@v4 # 后端原 lint 脚本带 --fixCI 中追加 --no-fix避免检查时修改工作区。
with: run: |
node-version: '22' npm run lint -w @gongxue/admin
- run: npm ci npm run lint -w @gongxue/server -- --no-fix
- run: npm run test timeout-minutes: 5
- name: 类型检查
run: npm run typecheck
timeout-minutes: 8
- name: 后端测试
run: npm run test -w @gongxue/server -- --runInBand --forceExit
timeout-minutes: 10
- name: 安装 Chromium
run: npx playwright install --with-deps chromium
timeout-minutes: 10
- name: 前端测试
run: npm run test -w @gongxue/admin
timeout-minutes: 10