-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 2.63 KB
/
Copy pathci.yml
File metadata and controls
78 lines (66 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: CI
# 触发:任意分支提交、PR、以及网页手动
on:
push:
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# ---------------- 前端:类型检查 + 构建 ----------------
frontend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: frontend/package-lock.json
- run: npm ci || npm install
- run: npm run build
# ---------------- 后端:起栈 + 集成测试(安全 → 性能 → 功能)----------------
backend:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: 准备 .env(dev / mock 模型,免 Key)
run: cp .env.dev.example .env
- name: 构建并启动后端服务
run: |
docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env \
up -d --build postgres redis qdrant minio api worker-default beat
- name: 等待 API 健康
run: |
for i in $(seq 1 40); do
if docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env \
exec -T api python -c "import urllib.request;urllib.request.urlopen('http://localhost:8000/api/health',timeout=3)" 2>/dev/null; then
echo "api ready"; exit 0
fi
sleep 3
done
echo "api 未就绪"; exit 1
- name: ① 安全测试 + 静态扫描
run: |
C="docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env exec -T api"
$C bandit -q -r app -c pyproject.toml --severity-level high
$C pytest -q -m security --junitxml=/app/tests/reports/security.xml
- name: ② 性能测试(SLA 门禁)
run: |
docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env \
exec -T api python tests/perf/run_perf.py
- name: ③ 功能/完整测试
run: |
docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env \
exec -T api pytest -q -m functional --junitxml=/app/tests/reports/functional.xml
- name: 失败时输出日志
if: failure()
run: docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env logs --tail 100
- name: 清理
if: always()
run: docker compose -f docker-compose.yml -f docker-compose.dev.yml --env-file .env down -v