mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-03 04:21:22 +08:00
🐛 fix(ci): 修复驱动发布链路变更漏掉全量重建
This commit is contained in:
@@ -514,8 +514,14 @@ for file in "${!changed_file_set[@]}"; do
|
||||
fi
|
||||
add_forced_drivers_from_tokens "$shared_delta"
|
||||
;;
|
||||
tools/compress-driver-artifact.sh)
|
||||
echo "检测到 driver-agent 压缩脚本变更;保守构建全部 driver-agent:$file" >&2
|
||||
tools/compress-driver-artifact.sh|\
|
||||
tools/package-driver-release-assets.py|\
|
||||
tools/generate-driver-release-manifest.py|\
|
||||
tools/complete-driver-release-assets.py|\
|
||||
tools/resolve-driver-release-source.py|\
|
||||
tools/validate-driver-release-manifest.sh|\
|
||||
tools/should-force-global-driver-builds.sh)
|
||||
echo "检测到 driver-agent 构建/发布链路脚本变更;保守构建全部 driver-agent:$file" >&2
|
||||
all_drivers_csv
|
||||
exit 0
|
||||
;;
|
||||
|
||||
@@ -139,4 +139,29 @@ YAMLEOF
|
||||
fi
|
||||
)
|
||||
|
||||
tmpdir_packaging="$(mktemp -d "${TMPDIR:-/tmp}/gonavi-detect-packaging-change.XXXXXX")"
|
||||
git init -q "$tmpdir_packaging"
|
||||
mkdir -p "$tmpdir_packaging/tools"
|
||||
cp tools/detect-changed-driver-agents.sh "$tmpdir_packaging/tools/detect-changed-driver-agents.sh"
|
||||
cat >"$tmpdir_packaging/tools/package-driver-release-assets.py" <<'PYEOF'
|
||||
print("package")
|
||||
PYEOF
|
||||
|
||||
(
|
||||
cd "$tmpdir_packaging"
|
||||
git add .
|
||||
git -c user.name=GoNavi -c user.email=gonavi@example.test commit -q -m initial
|
||||
base="$(git rev-parse HEAD)"
|
||||
|
||||
printf '\nprint("changed")\n' >> tools/package-driver-release-assets.py
|
||||
git add tools/package-driver-release-assets.py
|
||||
git -c user.name=GoNavi -c user.email=gonavi@example.test commit -q -m 'update packaging script'
|
||||
|
||||
actual="$(bash ./tools/detect-changed-driver-agents.sh --base "$base" --head HEAD 2>/dev/null)"
|
||||
if [[ "$actual" != *"mariadb"* || "$actual" != *"clickhouse"* || "$actual" != *"duckdb"* || "$actual" != *"elasticsearch"* ]]; then
|
||||
echo "expected packaging script change to trigger all driver builds, got: ${actual:-<empty>}" >&2
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
echo "detect-changed-driver-agents revision test passed"
|
||||
|
||||
83
tools/should-force-global-driver-builds.sh
Executable file
83
tools/should-force-global-driver-builds.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
用法:
|
||||
./tools/should-force-global-driver-builds.sh --base <ref> --head <ref>
|
||||
|
||||
输出:
|
||||
true 表示本次变更涉及 driver 构建/发布链路,平台构建阶段必须保留全局驱动重建结果
|
||||
false 表示可继续按平台 revision diff 缩小重建范围
|
||||
EOF
|
||||
}
|
||||
|
||||
base_ref=""
|
||||
head_ref=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--base)
|
||||
base_ref="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--head)
|
||||
head_ref="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "未知参数:$1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$base_ref" || -z "$head_ref" ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$base_ref" == "all" ]]; then
|
||||
echo "true"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! git rev-parse --verify "${base_ref}^{commit}" >/dev/null 2>&1; then
|
||||
echo "无法解析 base ref:$base_ref" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! git rev-parse --verify "${head_ref}^{commit}" >/dev/null 2>&1; then
|
||||
echo "无法解析 head ref:$head_ref" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while IFS= read -r file; do
|
||||
case "$file" in
|
||||
.github/workflows/dev-build.yml|\
|
||||
.github/workflows/release.yml|\
|
||||
build-driver-agents.sh|\
|
||||
tools/compress-driver-artifact.sh|\
|
||||
tools/detect-changed-driver-agents.sh|\
|
||||
tools/diff-driver-agent-revisions.sh|\
|
||||
tools/package-driver-release-assets.py|\
|
||||
tools/generate-driver-release-manifest.py|\
|
||||
tools/complete-driver-release-assets.py|\
|
||||
tools/resolve-driver-release-source.py|\
|
||||
tools/validate-driver-release-manifest.sh|\
|
||||
tools/should-force-global-driver-builds.sh)
|
||||
echo "true"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done < <(git diff --name-only "$base_ref" "$head_ref")
|
||||
|
||||
echo "false"
|
||||
80
tools/should-force-global-driver-builds.test.sh
Executable file
80
tools/should-force-global-driver-builds.test.sh
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
tmpdir="$(mktemp -d "${TMPDIR:-/tmp}/gonavi-force-global-driver-builds.XXXXXX")"
|
||||
cleanup() {
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
git init -q "$tmpdir"
|
||||
mkdir -p "$tmpdir/tools" "$tmpdir/.github/workflows" "$tmpdir/internal/db"
|
||||
cp tools/should-force-global-driver-builds.sh "$tmpdir/tools/should-force-global-driver-builds.sh"
|
||||
cat >"$tmpdir/.github/workflows/dev-build.yml" <<'YAMLEOF'
|
||||
name: Dev Build
|
||||
YAMLEOF
|
||||
cat >"$tmpdir/tools/package-driver-release-assets.py" <<'PYEOF'
|
||||
print("package")
|
||||
PYEOF
|
||||
cat >"$tmpdir/internal/db/duckdb_impl.go" <<'GOEOF'
|
||||
package db
|
||||
GOEOF
|
||||
|
||||
base_ref=""
|
||||
cd "$tmpdir"
|
||||
git add .
|
||||
git -c user.name=GoNavi -c user.email=gonavi@example.test commit -q -m initial
|
||||
base_ref="$(git rev-parse HEAD)"
|
||||
|
||||
(
|
||||
cd "$tmpdir"
|
||||
printf '\n# workflow change\n' >> .github/workflows/dev-build.yml
|
||||
git add .github/workflows/dev-build.yml
|
||||
git -c user.name=GoNavi -c user.email=gonavi@example.test commit -q -m 'workflow change'
|
||||
actual="$(bash ./tools/should-force-global-driver-builds.sh --base "$base_ref" --head HEAD)"
|
||||
if [[ "$actual" != "true" ]]; then
|
||||
echo "expected workflow change to force global driver builds, got: ${actual:-<empty>}" >&2
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
(
|
||||
cd "$tmpdir"
|
||||
git reset --hard -q "$base_ref"
|
||||
printf '\nprint("changed")\n' >> tools/package-driver-release-assets.py
|
||||
git add tools/package-driver-release-assets.py
|
||||
git -c user.name=GoNavi -c user.email=gonavi@example.test commit -q -m 'packaging change'
|
||||
actual="$(bash ./tools/should-force-global-driver-builds.sh --base "$base_ref" --head HEAD)"
|
||||
if [[ "$actual" != "true" ]]; then
|
||||
echo "expected packaging change to force global driver builds, got: ${actual:-<empty>}" >&2
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
(
|
||||
cd "$tmpdir"
|
||||
git reset --hard -q "$base_ref"
|
||||
printf '\n// source-only change\n' >> internal/db/duckdb_impl.go
|
||||
git add internal/db/duckdb_impl.go
|
||||
git -c user.name=GoNavi -c user.email=gonavi@example.test commit -q -m 'duckdb source change'
|
||||
actual="$(bash ./tools/should-force-global-driver-builds.sh --base "$base_ref" --head HEAD)"
|
||||
if [[ "$actual" != "false" ]]; then
|
||||
echo "expected source-only driver change not to force global driver builds, got: ${actual:-<empty>}" >&2
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
(
|
||||
cd "$tmpdir"
|
||||
actual="$(bash ./tools/should-force-global-driver-builds.sh --base all --head HEAD)"
|
||||
if [[ "$actual" != "true" ]]; then
|
||||
echo "expected base=all to force global driver builds, got: ${actual:-<empty>}" >&2
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
echo "should-force-global-driver-builds test passed"
|
||||
Reference in New Issue
Block a user