diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54a6279..482547c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [main] +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + jobs: backend-lint-test: runs-on: ubuntu-latest @@ -48,7 +52,7 @@ jobs: - name: Lint (ruff) run: cd backend && ruff check app/ - - name: Type check (optional) + - name: Style check (ruff) run: cd backend && ruff check app/ --select=E,W continue-on-error: true diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 425831f..783adbc 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -5,6 +5,10 @@ on: branches: [main, develop] types: [opened, synchronize, reopened] +concurrency: + group: pr-check-${{ github.ref }} + cancel-in-progress: true + jobs: pr-lint-test: name: Lint & Test (PR) @@ -49,9 +53,11 @@ jobs: pip install ruff pytest-cov - name: Backend lint + id: backend-lint run: cd backend && ruff check app/ - name: Backend tests + id: backend-tests env: DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/geo_test REDIS_URL: redis://localhost:6379/0 @@ -72,12 +78,15 @@ jobs: run: cd frontend && npm ci - name: Frontend lint + id: frontend-lint run: cd frontend && npm run lint - name: Frontend type check + id: frontend-type-check run: cd frontend && npx tsc --noEmit - name: Frontend unit tests + id: frontend-tests run: cd frontend && npm run test:ci # ── PR 状态注释 ────────────────────────────────── @@ -89,7 +98,7 @@ jobs: const { context, github } = require('@actions/github'); const status = '${{ job.status }}'; const emoji = status === 'success' ? '✅' : '❌'; - const body = `## CI 检查结果 ${emoji}\n\n**状态**: ${status}\n\n| 检查项 | 状态 |\n|--------|------|\n| 后端 Lint | ${{ steps.Backend lint.outcome || 'N/A' }} |\n| 后端测试 | ${{ steps.Backend tests.outcome || 'N/A' }} |\n| 前端 Lint | ${{ steps.Frontend lint.outcome || 'N/A' }} |\n| 前端测试 | ${{ steps.Frontend unit tests.outcome || 'N/A' }} |`; + const body = `## CI 检查结果 ${emoji}\n\n**状态**: ${status}\n\n| 检查项 | 状态 |\n|--------|------|\n| 后端 Lint | ${{ steps.backend-lint.outcome || 'N/A' }} |\n| 后端测试 | ${{ steps.backend-tests.outcome || 'N/A' }} |\n| 前端 Lint | ${{ steps.frontend-lint.outcome || 'N/A' }} |\n| 前端测试 | ${{ steps.frontend-tests.outcome || 'N/A' }} |`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner,