fix: CI workflow concurrency groups and step ID references
- Add concurrency groups to ci.yml and pr-check.yml to cancel redundant runs - Fix pr-check.yml step IDs to kebab-case (invalid with spaces) - Rename type-check step to style-check (ruff)
This commit is contained in:
parent
c428728742
commit
4507afbbfd
|
|
@ -6,6 +6,10 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ci-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
backend-lint-test:
|
backend-lint-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -48,7 +52,7 @@ jobs:
|
||||||
- name: Lint (ruff)
|
- name: Lint (ruff)
|
||||||
run: cd backend && ruff check app/
|
run: cd backend && ruff check app/
|
||||||
|
|
||||||
- name: Type check (optional)
|
- name: Style check (ruff)
|
||||||
run: cd backend && ruff check app/ --select=E,W
|
run: cd backend && ruff check app/ --select=E,W
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ on:
|
||||||
branches: [main, develop]
|
branches: [main, develop]
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: pr-check-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pr-lint-test:
|
pr-lint-test:
|
||||||
name: Lint & Test (PR)
|
name: Lint & Test (PR)
|
||||||
|
|
@ -49,9 +53,11 @@ jobs:
|
||||||
pip install ruff pytest-cov
|
pip install ruff pytest-cov
|
||||||
|
|
||||||
- name: Backend lint
|
- name: Backend lint
|
||||||
|
id: backend-lint
|
||||||
run: cd backend && ruff check app/
|
run: cd backend && ruff check app/
|
||||||
|
|
||||||
- name: Backend tests
|
- name: Backend tests
|
||||||
|
id: backend-tests
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/geo_test
|
DATABASE_URL: postgresql+asyncpg://test:test@localhost:5432/geo_test
|
||||||
REDIS_URL: redis://localhost:6379/0
|
REDIS_URL: redis://localhost:6379/0
|
||||||
|
|
@ -72,12 +78,15 @@ jobs:
|
||||||
run: cd frontend && npm ci
|
run: cd frontend && npm ci
|
||||||
|
|
||||||
- name: Frontend lint
|
- name: Frontend lint
|
||||||
|
id: frontend-lint
|
||||||
run: cd frontend && npm run lint
|
run: cd frontend && npm run lint
|
||||||
|
|
||||||
- name: Frontend type check
|
- name: Frontend type check
|
||||||
|
id: frontend-type-check
|
||||||
run: cd frontend && npx tsc --noEmit
|
run: cd frontend && npx tsc --noEmit
|
||||||
|
|
||||||
- name: Frontend unit tests
|
- name: Frontend unit tests
|
||||||
|
id: frontend-tests
|
||||||
run: cd frontend && npm run test:ci
|
run: cd frontend && npm run test:ci
|
||||||
|
|
||||||
# ── PR 状态注释 ──────────────────────────────────
|
# ── PR 状态注释 ──────────────────────────────────
|
||||||
|
|
@ -89,7 +98,7 @@ jobs:
|
||||||
const { context, github } = require('@actions/github');
|
const { context, github } = require('@actions/github');
|
||||||
const status = '${{ job.status }}';
|
const status = '${{ job.status }}';
|
||||||
const emoji = status === 'success' ? '✅' : '❌';
|
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({
|
github.rest.issues.createComment({
|
||||||
issue_number: context.issue.number,
|
issue_number: context.issue.number,
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue