From 443d4e3a1185e04191a9fcb165e1d81644cb47bd Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Mon, 6 Jul 2026 00:37:48 +0800 Subject: [PATCH] feat(ci): test.sh(go test / flutter test) Add scripts/ci/test.sh : server runs `go test ./...` inside golang:1.25 (mirrors ci.yml's go-server job docker invocation + gomod/gobuild caches + GOPROXY from _env.sh); client runs `flutter test` inside ghcr.io/cirruslabs/flutter:stable (mirrors ci.yml's flutter-client job's pub-cache mount + test dirs). Wired into deploy-server.yml's Test step already added in Task 4. Registers the script in ci.yml's shellcheck file list. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u --- .gitea/workflows/ci.yml | 3 ++- scripts/ci/test.sh | 49 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 scripts/ci/test.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 93cc05b..4f69a43 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -53,7 +53,8 @@ jobs: /mnt/scripts/ci/deploy-site.sh \ /mnt/scripts/ci/compile-backend.sh \ /mnt/scripts/ci/release-server.sh \ - /mnt/scripts/ci/deploy-server.sh + /mnt/scripts/ci/deploy-server.sh \ + /mnt/scripts/ci/test.sh # ── Job 2: OpenAPI Sync Check ──────────────────────────────────────────── openapi-check: diff --git a/scripts/ci/test.sh b/scripts/ci/test.sh new file mode 100755 index 0000000..6dd9210 --- /dev/null +++ b/scripts/ci/test.sh @@ -0,0 +1,49 @@ +#!/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) + mkdir -p "$HOME/.cache/pangolin-ci/gomod" "$HOME/.cache/pangolin-ci/gobuild" + echo "==> test: go test ./... (golang:1.25 容器)" + 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" \ + -e GOPROXY="$GOPROXY" \ + golang:1.25 \ + 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} 通过"