-
Notifications
You must be signed in to change notification settings - Fork 220
210 lines (177 loc) · 5.66 KB
/
Copy pathci.yml
File metadata and controls
210 lines (177 loc) · 5.66 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: CI (Build + Lint + Test)
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: ./backend
run: npm ci
- name: Run TypeScript check
working-directory: ./backend
run: npx tsc --noEmit
- name: Run ESLint
working-directory: ./backend
run: npm run lint --if-present
frontend-lint:
name: Frontend Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci
- name: Run TypeScript check
working-directory: ./frontend
run: npx tsc --noEmit
- name: Run ESLint
working-directory: ./frontend
run: npm run lint --if-present
# ADR-020 v2.2(2026-07-21):新文件行数检查(软警告,不阻断)
# 仅扫描本次 PR 中变更的 .ts/.tsx 新文件
- name: Check new file line counts (soft warning)
if: github.event_name == 'pull_request'
run: |
echo "## 新文件行数检查" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
WARN=false
git diff --name-only --diff-filter=A origin/${{ github.base_ref }}...HEAD | \
grep -E '\.(ts|tsx)$' | grep -vE '(\.test\.|\.spec\.|node_modules)' | while read f; do
if [ -f "$f" ]; then
LINES=$(wc -l < "$f")
if [ "$LINES" -gt 500 ]; then
echo "::warning file=$f::新文件 $LINES 行,超过 500 行阈值(参考 ADR-020 v2.2)" >&2
fi
fi
done
echo "✅ 检查完成(超 500 行的会在上面以 warning 标记)" >> $GITHUB_STEP_SUMMARY
architecture-check:
name: Architecture Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install root dependencies (depcruiser, madge)
run: npm ci
- name: Run architecture check
run: node scripts/check-architecture.js
- name: Run dependency-cruiser
run: npx depcruise --config .dependency-cruiser.json backend/src --output-type text
continue-on-error: false
backend-test:
name: Backend Test
runs-on: ubuntu-latest
needs: [backend-lint, architecture-check]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: ./backend
run: npm ci
- name: Run tests with coverage
working-directory: ./backend
run: npm run test:coverage
env:
JWT_SECRET: test-secret-for-ci
DOUBAO_API_KEY: test-api-key
frontend-test:
name: Frontend Test
runs-on: ubuntu-latest
needs: [frontend-lint]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci
- name: Run tests with coverage
working-directory: ./frontend
run: npm run test:coverage
frontend-build:
name: Frontend Build
runs-on: ubuntu-latest
needs: [frontend-lint, frontend-test]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
working-directory: ./frontend
run: npm ci
- name: Build
working-directory: ./frontend
run: npm run build
docker-build:
name: Docker Build (Verify)
runs-on: ubuntu-latest
needs: [backend-test, frontend-build]
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Backend (verify only)
uses: docker/build-push-action@v7
with:
context: .
file: docker/Dockerfile.backend
push: false
load: true
tags: itops-backend:ci-test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build Frontend (verify only)
uses: docker/build-push-action@v7
with:
context: .
file: docker/Dockerfile.frontend
push: false
load: true
tags: itops-frontend:ci-test
cache-from: type=gha
cache-to: type=gha,mode=max