Files
gplan-2/tools/ci/domain_route.sh
T

37 lines
2.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 乙案域分流——push 触发的远端 CI 按改动域选闸(2026-11-03 用户裁)。
# 用法: tools/ci/domain_route.sh <base_sha> <head_sha>
# 输出: stdout 打印 full|docs|skip;GITHUB_OUTPUT 在位时另写 mode= 行(Actions 步骤输出)。
# 规则(唯一事实源,乙案语义):
# 1. diff 含 game/ 下非 .md 文件(行为载体:代码/场景/数据表/素材)→ full(两域全量,渲染闸随 code 域)
# 2. 否则 diff 非空(design/ 文档、reports/、根 md、game/ 下 .md 等一切非代码面)→ docs
# (乙案:文档批只跑文档域秒级闸——gdd_lint/doc_link/doc_term/pipeline/doc_ref/capability+熵增)
# 例外:diff 只含 tools/ 与 .gitea/(闸件与管线自身改动)→ skip——闸件改动不占合回全量,
# 质量义务=落批人工确认可跑通(run_all_gates.sh 头注既有口径,不在远端重复烧引擎)。
# 3. diff 空 → skip。
# 判定面说明:game/tests/** 与 game/sim/** 属 game/ 行为载体(.md 除外)→ full,
# 与 run_all_gates.sh 关联档口径一致(测量面批单元与集成测试照跑全套件)。
set -u
base="${1:-}"
head="${2:-HEAD}"
[ -n "$base" ] || { echo "用法: domain_route.sh <base_sha> <head_sha>" >&2; exit 2; }
head="$(git rev-parse --verify "${head}^{commit}" 2>/dev/null)" || { echo "坏 head: $head" >&2; exit 2; }
# base 不可用(新分支 zero-sha/被 force-push 掉)→ 回落 HEAD~1;孤提交(无父)→ docs 保守最小跑。
git cat-file -e "$base^{commit}" 2>/dev/null || base="$(git rev-parse "$head~1" 2>/dev/null || true)"
if [ -z "$base" ]; then
mode="docs"
else
files="$(git diff --name-only "$base" "$head" 2>/dev/null)"
if [ -z "$files" ]; then
mode="skip"
elif echo "$files" | grep -vE '\.md$' | grep -qE '^game/'; then
mode="full"
else
non_tools="$(echo "$files" | grep -vE '^(tools/|\.gitea/)' || true)"
if [ -n "$non_tools" ]; then mode="docs"; else mode="skip"; fi
fi
fi
if [ -n "${GITHUB_OUTPUT:-}" ]; then printf 'mode=%s\n' "$mode" >> "$GITHUB_OUTPUT"; fi
echo "$mode"
exit 0