ci: gate on the fast tests (about 20s); slow end-to-end tests run in parallel with the image build [CI]
This commit is contained in:
1 parent
c9c21f8056
commit
2d31bd091e
11 files changed
+65
-6
No files matched your search
+11
-1
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# 后端测试,带增量编译:把后端源码同步到一个固定目录,在那里 dotnet build / test。
|
||||
# 用法:verify-backend.sh [fast|slow]
|
||||
# fast(默认):除了标了 Category=Slow 的以外的全部测试,约 20 秒,出镜像之前要过;
|
||||
# slow:只跑标了 Category=Slow 的端到端测试(真实时间的阶梯、要等测量块出来,合起来一百来秒),和出镜像并行跑,失败照样红,但不拦着出镜像。
|
||||
#
|
||||
# 为什么:每条流水线的工作区都是新克隆的(路径、文件时间都是新的),MSBuild 没法增量,每次从零编译整个解决方案要两分钟。
|
||||
# 固定目录里 obj/bin 留着,同步时只更新内容真的变了的文件(按内容比较,没变的文件时间不动),MSBuild 就只重编译受影响的项目;
|
||||
@@ -9,6 +12,12 @@
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
mode="${1:-fast}"
|
||||
case "$mode" in
|
||||
fast) filter=(--filter-not-trait "Category=Slow") ;;
|
||||
slow) filter=(--filter-trait "Category=Slow") ;;
|
||||
*) echo "usage: verify-backend.sh [fast|slow]" >&2; exit 2 ;;
|
||||
esac
|
||||
cache="${MOSHIRO_CI_CACHE:-/home/justme/woodpecker/cache/backend-tests}"
|
||||
src="$cache/src"
|
||||
mkdir -p "$cache"
|
||||
@@ -58,7 +67,8 @@ fi
|
||||
# 测试在缓存目录里跑完整的解决方案(不再重复编译)
|
||||
log="$cache/last-test.log"
|
||||
status=0
|
||||
(cd "$src/backend" && dotnet test --solution MoShiro.slnx -c Release --no-build) 2>&1 | tee "$log" || status=${PIPESTATUS[0]}
|
||||
# 别的程序集里没有匹配的测试会因为「零个测试」返回 8,忽略它
|
||||
(cd "$src/backend" && dotnet test --solution MoShiro.slnx -c Release --no-build "${filter[@]}" --ignore-exit-code 8) 2>&1 | tee "$log" || status=${PIPESTATUS[0]}
|
||||
[[ "$status" == 0 ]] && exit 0
|
||||
|
||||
# 个别端到端测试会偶发失败(比如 Hy2 阶梯测试里探针掉线):失败的测试单独重跑(最多两次),重跑通过就当通过(日志里留着第一次的失败);
|
||||
|
||||
Reference in new issue
Block a user