mirror of
https://gitcode.com/JianFeeeee/webui4frpc.git
synced 2026-10-31 06:17:20 +00:00
test(criteria): 判据自行补齐前端嵌入产物,保证在干净 clone 上可复现
internal/httpapi 用 //go:embed all:dist 嵌入前端,dist 是构建期产物且被 .gitignore 排除。干净 clone 上直接 go build 会报 "pattern all:dist: no matching files found"——这是基线既有状态,与本判据 要验证的东西无关,但会让判据在任意 checkout 上都红,失去可复现性。 现在若 dist 缺失就先 cd web 构建并拷回 internal/httpapi/dist(无 npm 时 给出明确的失败原因与手工步骤)。已实测:删掉 dist 后跑判据可自动补齐并全绿。
This commit is contained in:
@ -37,6 +37,21 @@ assert_died_before_listen() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ---- 0. 前端嵌入产物 ----
|
||||||
|
# internal/httpapi 用 //go:embed all:dist 嵌入前端,而 dist 是构建期产物、
|
||||||
|
# 被 .gitignore 排除。干净 clone 上不先构建前端,go build 会直接报
|
||||||
|
# "pattern all:dist: no matching files found"——那是基线既有状态,与本判据
|
||||||
|
# 无关,所以这里先补齐,让判据在任何 checkout 上都能复现。
|
||||||
|
if [ ! -f internal/httpapi/dist/index.html ]; then
|
||||||
|
command -v npm >/dev/null 2>&1 \
|
||||||
|
|| fail "缺少前端构建产物 internal/httpapi/dist 且没有 npm;请在有 node 的环境跑,或先手工 cd web && npm ci && npm run build && cp -r dist ../internal/httpapi/dist"
|
||||||
|
( cd web \
|
||||||
|
&& { [ -d node_modules ] || npm ci --no-audit --no-fund >/dev/null 2>&1; } \
|
||||||
|
&& npm run build >/dev/null 2>&1 ) || fail "前端构建失败(cd web && npm run build)"
|
||||||
|
rm -rf internal/httpapi/dist && mkdir -p internal/httpapi/dist
|
||||||
|
cp -r web/dist/. internal/httpapi/dist/ || fail "拷贝前端产物失败"
|
||||||
|
fi
|
||||||
|
|
||||||
# ---- 1. 构建与全量测试 ----
|
# ---- 1. 构建与全量测试 ----
|
||||||
go build ./... || fail "go build ./..."
|
go build ./... || fail "go build ./..."
|
||||||
go test ./... > "$WORK/test.log" 2>&1 || { cat "$WORK/test.log"; fail "go test ./..."; }
|
go test ./... > "$WORK/test.log" 2>&1 || { cat "$WORK/test.log"; fail "go test ./..."; }
|
||||||
|
|||||||
Reference in New Issue
Block a user