Skip to content

chore: 删除过时的copilot指令文档 #40

chore: 删除过时的copilot指令文档

chore: 删除过时的copilot指令文档 #40

Workflow file for this run

# Continuous Integration - 业界最佳实践
# 并行测试、代码质量检查、缓存优化
name: ⚡ CI
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
workflow_dispatch:
# 最小权限
permissions:
contents: read
pull-requests: write
checks: write
# 并发控制
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NODE_VERSION: '22.14.0'
jobs:
# ========== 变更检测 ==========
changes:
name: 📋 Detect Changes
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
backend: ${{ steps.filter.outputs.backend }}
config: ${{ steps.filter.outputs.config }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
frontend:
- 'src/**'
- 'public/**'
- 'index.html'
- 'package*.json'
- 'vite.config.ts'
- 'tsconfig*.json'
- 'tailwind.config.*'
- '.github/workflows/ci.yml'
backend:
- 'server/**'
- '.github/workflows/ci.yml'
config:
- '.github/workflows/**'
# ========== 前端测试矩阵 ==========
frontend:
name: 🎨 Frontend (${{ matrix.runner }})
runs-on: ${{ matrix.runner }}
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' || github.event_name == 'workflow_dispatch' }}
strategy:
fail-fast: false
matrix:
runner: [ubuntu-latest]
node: ['22.14.0']
include:
- runner: ubuntu-latest
node: '22.14.0'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
# 智能缓存
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules/.cache
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node${{ matrix.node }}-
${{ runner.os }}-
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install dependencies
run: npm ci --prefer-offline --no-audit
# 并行质量检查
- name: Run type check
run: npm run typecheck
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test:run -- --coverage
env:
CI: true
- name: Check formatting
run: npm run format:check
# 构建测试
- name: Test build
run: npm run build
env:
NODE_ENV: production
# 上传覆盖率
- name: Upload coverage
uses: codecov/codecov-action@v4
if: matrix.runner == 'ubuntu-latest' && matrix.node == '22.14.0'
with:
files: ./coverage/lcov.info
fail_ci_if_error: false
verbose: false
# ========== 后端测试 ==========
backend:
name: ⚙️ Backend
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' || github.event_name == 'workflow_dispatch' }}
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: server/requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest black flake8
- name: Lint with flake8
run: flake8 app --count --select=E9,F63,F7,F82 --show-source --statistics || true
- name: Format check with black
run: black --check app || true
- name: Type check
run: python -m compileall app
- name: Test import
run: |
python -c "from app.main import app; print('✅ Backend imports successfully')"
# ========== 总结状态 ==========
status:
name: 📊 CI Status
runs-on: ubuntu-latest
needs: [frontend, backend]
if: always() && !cancelled()
steps:
- name: Check all jobs status
if: ${{ contains(needs.*.result, 'failure') || cancelled() }}
run: |
echo "❌ CI failed"
exit 1
- name: Report success
run: echo "✅ All CI checks passed"