name: CI on: push: branches: [main, develop] pull_request: branches: [main, develop] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # ───────────────────────────────────────────────────────────── # 后端:多平台 × 多 Python 版本矩阵测试 # ───────────────────────────────────────────────────────────── backend-test: name: Backend (${{ matrix.os }} / py${{ matrix.python-version }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ['3.13', '3.14'] exclude: # macOS + py3.14 暂时跳过(部分依赖未发布 wheel) - os: macos-latest python-version: '3.14' steps: - name: Checkout uses: actions/checkout@v4 - name: 安装 uv uses: astral-sh/setup-uv@v5 with: version: latest enable-cache: true cache-dependency-glob: uv.lock - name: 设置 Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: 安装依赖 run: uv sync --extra dev --frozen - name: Ruff 检查 run: uv run ruff check backend/endo tests - name: Ruff 格式检查 run: uv run ruff format --check backend/endo tests - name: 运行测试 env: PYTHONPATH: backend run: uv run pytest -v --cov=endo --cov-report=xml --cov-report=term-missing - name: 上传覆盖率 if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' uses: actions/upload-artifact@v4 with: name: coverage-${{ matrix.os }}-py${{ matrix.python-version }} path: coverage.xml retention-days: 7 # ───────────────────────────────────────────────────────────── # 前端:多平台构建验证 # ───────────────────────────────────────────────────────────── frontend-build: name: Frontend (${{ matrix.os }} / node${{ matrix.node-version }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] node-version: [20, 22] defaults: run: working-directory: frontend steps: - name: Checkout uses: actions/checkout@v4 - name: 安装 pnpm uses: pnpm/action-setup@v4 with: version: 9 - name: 设置 Node ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: pnpm cache-dependency-path: frontend/pnpm-lock.yaml - name: 安装依赖 run: pnpm install --frozen-lockfile - name: TypeScript 类型检查 run: npx tsc --noEmit -p tsconfig.app.json - name: 构建 run: pnpm run build - name: 上传构建产物 if: matrix.os == 'ubuntu-latest' && matrix.node-version == 22 uses: actions/upload-artifact@v4 with: name: frontend-dist path: frontend/dist retention-days: 7 # ───────────────────────────────────────────────────────────── # 聚合:所有测试通过后才标记完成 # ───────────────────────────────────────────────────────────── ci-pass: name: CI Pass runs-on: ubuntu-latest needs: [backend-test, frontend-build] if: always() steps: - name: 检查依赖任务结果 if: ${{ needs.backend-test.result != 'success' || needs.frontend-build.result != 'success' }} run: | echo "backend-test: ${{ needs.backend-test.result }}" echo "frontend-build: ${{ needs.frontend-build.result }}" exit 1 - name: 全部通过 run: echo "✅ 所有 CI 检查通过"