Skip to content

init: vibe coding 企业级起点 (SDD+TDD+Harness+CI+AgentOps) #1

init: vibe coding 企业级起点 (SDD+TDD+Harness+CI+AgentOps)

init: vibe coding 企业级起点 (SDD+TDD+Harness+CI+AgentOps) #1

Workflow file for this run

name: CI · 12 门硬关
on:
pull_request:
push:
branches: [main]
# 取消旧 run,避免重复跑
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# 通用:checkout + 缓存
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 } # 需要 diff
- uses: actions/setup-python@v5
with: { python-version: '3.10', cache: pip }
- run: pip install -r requirements.txt -r requirements-dev.txt
- uses: actions/cache@v4
with:
path: .pytest_cache
key: pytest-${{ github.sha }}
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements*.txt') }}
test:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.10', cache: pip }
- run: pip install -r requirements.txt -r requirements-dev.txt
- name: 单元 + 集成
run: pytest -q
- name: 覆盖率门槛
run: pytest --cov=app --cov-fail-under=80
contract:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-python@v5
with: { python-version: '3.10' }
- run: pip install oasdiff spectral-cli
- name: 契约 diff
run: oasdiff diff origin/main HEAD --format github
- name: 契约 lint
run: spectral lint openapi.yaml --ruleset .spectral.yaml
lint:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: '3.10' }
- run: pip install ruff bandit
- name: ruff
run: ruff check .
- name: mypy
run: mypy app/
security:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-python@v5
with: { python-version: '3.10' }
- run: pip install bandit safety
- name: SAST (bandit)
run: bandit -r app/ -ll
- name: SCA (safety)
run: safety check
- name: Secrets (gitleaks)
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: [test, contract, lint, security]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: 构建镜像
run: docker build -t app:${{ github.sha }} .
- name: 镜像扫描
uses: aquasecurity/trivy-action@master
with:
image-ref: app:${{ github.sha }}
severity: HIGH,CRITICAL
exit-code: '1'
ignore-unfixed: true