test(ci): 第7刀 — CI 依赖缓存(C 效率)

host-mode runner 宿主机持久,给四个拉依赖的 job 挂宿主缓存目录,
消掉每次全量下载:
- go-server / e2e-smoke:挂 $HOME/.cache/pangolin-ci/{gomod,gobuild}
  → /go/pkg/mod + /root/.cache/go-build。
- flutter-client / golden:挂 $HOME/.cache/pangolin-ci/pubcache → /root/.pub-cache。

本地实测 go build:首次 204s(含全量 downloading)→ 二次 1s(0 downloading)。
testcontainers 镜像由 Docker Desktop 宿主层天然缓存,无需额外处理。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-25 21:25:38 +08:00
parent f8f4ee0ce8
commit 8356547c2f
+11
View File
@@ -76,8 +76,10 @@ jobs:
- name: flutter analyze + test + coverage
run: |
mkdir -p "$HOME/.cache/pangolin-ci/pubcache"
docker run --rm \
-v "$PWD/client:/app" -w /app \
-v "$HOME/.cache/pangolin-ci/pubcache:/root/.pub-cache" \
ghcr.io/cirruslabs/flutter:stable \
bash -c "flutter pub get && flutter analyze --no-fatal-infos && flutter test --coverage test/unit test/widget test/contract"
# 覆盖率闸(host 侧解析 lcov):防断崖,低于阈值即失败。
@@ -127,8 +129,12 @@ jobs:
- name: go build + vet + test + coverage
run: |
# 宿主持久缓存(host-mode runner):省掉每次 `go: downloading` 全量拉依赖。
mkdir -p "$HOME/.cache/pangolin-ci/gomod" "$HOME/.cache/pangolin-ci/gobuild"
docker run --rm \
-v "$PWD/server:/app" -w /app \
-v "$HOME/.cache/pangolin-ci/gomod:/go/pkg/mod" \
-v "$HOME/.cache/pangolin-ci/gobuild:/root/.cache/go-build" \
golang:1.25 \
bash -c "go build ./... && go vet ./... && go test -coverprofile=cover.out ./... && go tool cover -func=cover.out > coverage.txt"
tail -1 server/coverage.txt
@@ -149,8 +155,11 @@ jobs:
- name: 进程级端到端冒烟 (server 二进制 + miniredis + gRPC 全链路)
run: |
mkdir -p "$HOME/.cache/pangolin-ci/gomod" "$HOME/.cache/pangolin-ci/gobuild"
docker run --rm \
-v "$PWD:/repo" -w /repo \
-v "$HOME/.cache/pangolin-ci/gomod:/go/pkg/mod" \
-v "$HOME/.cache/pangolin-ci/gobuild:/root/.cache/go-build" \
golang:1.25 \
bash -c "apt-get update -qq && apt-get install -y -qq openssl curl python3 >/dev/null 2>&1 && bash scripts/e2e-smoke.sh"
@@ -185,7 +194,9 @@ jobs:
- name: flutter test golden (Linux 权威基线)
run: |
mkdir -p "$HOME/.cache/pangolin-ci/pubcache"
docker run --rm \
-v "$PWD/client:/app" -w /app \
-v "$HOME/.cache/pangolin-ci/pubcache:/root/.pub-cache" \
ghcr.io/cirruslabs/flutter:stable \
bash -c "flutter pub get && flutter test test/golden/components_golden_test.dart test/golden/auth_redesign_golden_test.dart"