#!/usr/bin/env bash # test.sh — run the test suite for one side of the repo. # Invoked directly on the nas runner (see deploy-server.yml's "Test" step), # so this script itself owns the docker invocation — Go/Flutter are not on # the host. # # server: `go test ./...` inside golang:1.25, mirroring the go-server job's # docker invocation in .gitea/workflows/ci.yml (mounts + gomod/gobuild # caches), plus GOPROXY from _env.sh so it doesn't hit proxy.golang.org. # client: `flutter test` inside ghcr.io/cirruslabs/flutter:stable, mirroring # the flutter-client job's docker invocation in .gitea/workflows/ci.yml # (pub-cache volume, same test dirs); analyze/coverage stay in that job. # # Run from the repo root (relative paths below assume this). set -euo pipefail # shellcheck source=scripts/ci/_env.sh . scripts/ci/_env.sh TARGET="${1:-}" case "$TARGET" in server) # 直接在 runner 跑(不嵌套 docker,避免 DinD 挂载失败)。go.mod 要求的 # go 1.25.x 若高于 runner 自带版本,Go 工具链会经 GOPROXY(_env.sh)自动下载。 echo "==> test: go test ./..." ( cd server && go test ./... ) ;; client) mkdir -p "$HOME/.cache/pangolin-ci/pubcache" echo "==> test: flutter test (ghcr.io/cirruslabs/flutter:stable 容器)" 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/unit test/widget test/contract" ;; *) echo "usage: scripts/ci/test.sh " >&2 exit 1 ;; esac echo "==> test: ${TARGET} 通过"