ci: 限制 Go 门禁并发峰值 #8

Merged
chengcheng merged 1 commits from codex/fix-ci-runner-oom into main 2026-07-17 21:26:31 +08:00
3 changed files with 43 additions and 0 deletions

View File

@ -81,6 +81,9 @@ jobs:
}
- name: Verify Go code
working-directory: apps/api
env:
GOFLAGS: "-p=1"
GOMAXPROCS: "1"
run: |
go vet ./...
go test ./...

View File

@ -66,6 +66,9 @@ jobs:
}
- name: Verify Go code
working-directory: apps/api
env:
GOFLAGS: "-p=1"
GOMAXPROCS: "1"
run: |
go vet ./...
go test ./...

View File

@ -18,6 +18,42 @@ adr=$root/docs/decisions/001-production-cicd.md
runbook=$root/docs/runbooks/production-ci-cd.md
migrator=$root/apps/api/cmd/migrate/main.go
assert_bounded_go_verification() {
local quality_workflow=$1
awk '
/^[[:space:]]+GOFLAGS:/ { all_goflags++ }
/^[[:space:]]+GOMAXPROCS:/ { all_gomaxprocs++ }
/^ - name: Verify Go code$/ {
target_steps++
in_target=1
in_env=0
next
}
/^ - / {
in_target=0
in_env=0
}
in_target && /^ env:$/ {
env_blocks++
in_env=1
next
}
in_target && in_env && /^ GOFLAGS: "-p=1"$/ { target_goflags++ }
in_target && in_env && /^ GOMAXPROCS: "1"$/ { target_gomaxprocs++ }
in_target && in_env && /^ [^ ]/ { in_env=0 }
END {
exit !(target_steps == 1 && env_blocks == 1 &&
target_goflags == 1 && target_gomaxprocs == 1 &&
all_goflags == 1 && all_gomaxprocs == 1)
}
' "$quality_workflow" || {
printf '%s must limit Go parallelism exactly once in the Verify Go code step\n' \
"$quality_workflow" >&2
exit 1
}
}
for file in "$workflow" "$release_workflow" "$runner_service" "$runner_config" "$provision" "$build_images" "$validate_semver" "$validate_migrations" "$build_images_test" "$migrations_test" "$migration_base" "$adr" "$runbook" "$migrator"; do
[[ -f $file ]] || {
printf 'missing CI/CD file: %s\n' "$file" >&2
@ -128,6 +164,7 @@ for quality_workflow in "$workflow" "$release_workflow"; do
"$quality_workflow" >&2
exit 1
}
assert_bounded_go_verification "$quality_workflow"
grep -Fq 'production_base=$(cat deploy/ci/production-migration-base)' \
"$quality_workflow" || {
printf '%s does not read the versioned production migration baseline\n' \