-
Notifications
You must be signed in to change notification settings - Fork 1
374 lines (322 loc) · 11.7 KB
/
checks.yml
File metadata and controls
374 lines (322 loc) · 11.7 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
name: checks
on:
pull_request:
branches: [master, dev/delicious233, dev/trump]
push:
branches: [master, dev/delicious233, dev/trump]
env:
GO_VERSION: "1.25"
GOLANGCI_LINT_VERSION: "v2.12.2"
NODE_VERSION: "22"
PNPM_VERSION: "10"
jobs:
# ── Go: Edge Server ──────────────────────────
go-edge:
runs-on: ubuntu-latest
defaults:
run:
working-directory: edge-server
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: edge-server/go.sum
- name: Build
run: go build ./...
- name: Lint
continue-on-error: true
uses: golangci/golangci-lint-action@v9
with:
working-directory: edge-server
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m
- name: Test (unit only, skip integration)
run: go test ./... -count=1 -short -coverprofile=coverage.out -covermode=atomic
- name: Coverage check (overall >= 75%)
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
THRESHOLD=75
echo "Overall coverage: ${COVERAGE}% (threshold: ${THRESHOLD}%)"
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
echo "::error::Coverage ${COVERAGE}% below ${THRESHOLD}% threshold"
exit 1
fi
- name: Coverage per-package minimums
run: |
echo "=== Per-package coverage minimums ==="
check_pkg() {
local pattern="$1"
local min="$2"
local label="$3"
local cov
cov=$(go tool cover -func=coverage.out | grep "$pattern" | awk '{sum+=$NF; n++} END {if(n>0) printf "%.1f", sum/n; else print "0"}')
echo " ${label}: ${cov}% (min: ${min}%)"
if (( $(echo "$cov < $min" | bc -l) )); then
echo "::error::${label} coverage ${cov}% below ${min}% minimum"
return 1
fi
}
FAILED=0
check_pkg "edge-server/internal/security/" 70 "security" || FAILED=1
check_pkg "edge-server/internal/lifecycle/" 60 "lifecycle" || FAILED=1
check_pkg "edge-server/internal/adapters/" 55 "adapters" || FAILED=1
exit $FAILED
- name: Race detection
run: go test ./... -count=1 -short -race
- name: Security scan (gosec)
continue-on-error: true
run: go run github.com/securego/gosec/v2/cmd/gosec@latest ./...
- name: Vulnerability check (govulncheck)
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
- name: Vet
run: go vet ./...
- name: Commit message check (PR only)
if: github.event_name == 'pull_request'
run: |
TYPES="init|feat|fix|docs|refactor|chore|test|perf|ci|revert"
PATTERN="^($TYPES)(\([a-z0-9._-]+\))?: .+"
FAILED=0
for commit in $(git log --format="%H %s" "origin/${{ github.base_ref }}..HEAD" 2>/dev/null || echo ""); do
sha=$(echo "$commit" | cut -d' ' -f1)
msg=$(echo "$commit" | cut -d' ' -f2-)
if ! echo "$msg" | grep -qE "$PATTERN"; then
echo "::warning ::${sha:0:7} 不符合规范: $msg"
FAILED=1
fi
done
if [ $FAILED -eq 1 ]; then
echo "::error::提交信息需符合 Conventional Commits: type(scope): 中文摘要"
exit 1
fi
echo "✓ 所有提交信息格式正确"
# ── Go: Hub Server ──────────────────────────
go-hub:
runs-on: ubuntu-latest
defaults:
run:
working-directory: hub-server
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: hub-server/go.sum
- name: Build
run: go build ./...
- name: Lint
continue-on-error: true
uses: golangci/golangci-lint-action@v9
with:
working-directory: hub-server
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m
- name: Test (unit only, skip integration)
run: go test ./... -count=1 -short -coverprofile=coverage.out -covermode=atomic
- name: Coverage check (overall >= 40%)
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}' | sed 's/%//')
THRESHOLD=40
echo "Overall coverage: ${COVERAGE}% (threshold: ${THRESHOLD}%)"
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
echo "::error::Coverage ${COVERAGE}% below ${THRESHOLD}% threshold"
exit 1
fi
- name: Race detection
run: go test ./... -count=1 -short -race
- name: Security scan (gosec)
continue-on-error: true
run: go run github.com/securego/gosec/v2/cmd/gosec@latest ./...
- name: Vulnerability check (govulncheck)
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
- name: Vet
run: go vet ./...
# ── Cross-Platform Build ─────────────────────
cross-build:
name: Cross-platform build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: |
edge-server/go.sum
hub-server/go.sum
- name: Build edge-server
run: cd edge-server && go build ./...
- name: Build hub-server
run: cd hub-server && go build ./...
- name: Test edge-server
run: cd edge-server && go test ./... -short -count=1
continue-on-error: ${{ matrix.os == 'macos-latest' }}
- name: Test hub-server
run: cd hub-server && go test ./... -short -count=1
continue-on-error: ${{ matrix.os == 'macos-latest' }}
# ── Docker: Hub Server ───────────────────────
docker:
name: Docker build (Hub Server)
runs-on: ubuntu-latest
defaults:
run:
working-directory: hub-server
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t agenthub-hub-server -f deployments/Dockerfile .
- name: Verify image
run: docker images agenthub-hub-server
# ── Benchmark Regression ─────────────────────
benchmark:
name: Benchmark regression check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: |
edge-server/go.sum
hub-server/go.sum
- name: Run benchmarks
run: |
cd edge-server && go test -bench=. -benchtime=1s ./internal/events/ ./internal/adapters/
cd ../hub-server && go test -bench=. -benchtime=1s ./internal/service/ ./internal/jwtutil/
# ── Frontend: Desktop ────────────────────────
frontend-desktop:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/desktop
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: app/pnpm-lock.yaml
- name: Install
working-directory: app
run: pnpm install --frozen-lockfile
- name: Type check
run: pnpm typecheck
- name: Lint (debt visibility)
continue-on-error: true
run: pnpm lint --max-warnings 10
- name: Test Desktop
run: pnpm test:ci
# ── Frontend: Web ────────────────────────────
frontend-web:
name: Frontend (web)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app/web
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: app/pnpm-lock.yaml
- name: Install
run: pnpm install --frozen-lockfile
- name: Lint Web
run: pnpm lint
- name: Build Web
run: pnpm build
- name: Test
run: pnpm test -- --run
# ── Frontend: Mobile ──────────────────────────
frontend-mobile:
name: Frontend (mobile)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./app/mobile
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: app/pnpm-lock.yaml
- name: Install
run: pnpm install --frozen-lockfile
- name: Typecheck
run: pnpm typecheck
- name: Build
run: pnpm build
- name: Test
run: pnpm test -- --run
# ── E2E Smoke ─────────────────────────────────
e2e-smoke:
name: E2E Smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
cache-dependency-path: app/pnpm-lock.yaml
- name: Install
run: pnpm install --frozen-lockfile
working-directory: ./app
- name: Build desktop
run: pnpm build
working-directory: ./app/desktop
- name: Smoke test
run: pnpm exec playwright test --project=chromium
working-directory: ./app
# ── Validation ───────────────────────────────
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check whitespace
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git diff --check "origin/${{ github.base_ref }}...HEAD"
elif git rev-parse --verify HEAD^ >/dev/null 2>&1; then
git diff --check HEAD^..HEAD
else
git diff --check
fi
- name: Secret guard
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
bash scripts/check-secrets.sh --range "origin/${{ github.base_ref }}...HEAD"
elif git rev-parse --verify HEAD^ >/dev/null 2>&1; then
bash scripts/check-secrets.sh --range HEAD^..HEAD
else
bash scripts/check-secrets.sh --worktree
fi
- name: Verify CI gate policy
shell: pwsh
run: ./scripts/verify-ci-gates.ps1
- name: Validate OpenAPI YAML
run: |
python -m pip install --quiet PyYAML
python -c "import pathlib, yaml; yaml.safe_load(pathlib.Path('api/openapi.yaml').read_text(encoding='utf-8')); print('yaml ok')"