返回 DeepSeek-Reasonix
validate-release-candidate-source.test.sh
根目录 / scripts / validate-release-candidate-source.test.sh
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 repo_root="$(git rev-parse --show-toplevel)"
5 root="$(mktemp -d "${TMPDIR:-/tmp}/reasonix-candidate-source-test.XXXXXX")"
6 cleanup() {
7 case "$root" in */reasonix-candidate-source-test.*) rm -rf -- "$root" ;; *) exit 1 ;; esac
8 }
9 trap cleanup EXIT
10
11 remote="$root/remote.git"
12 work="$root/work"
13 git init -q --bare "$remote"
14 git init -q -b main-v2 "$work"
15 git -C "$work" config user.name test
16 git -C "$work" config user.email test@example.invalid
17 mkdir -p "$work/release-notes"
18 printf '{"releases":[]}\n' >"$work/release-notes/releases.json"
19 git -C "$work" add .
20 git -C "$work" commit -q -m base
21 cat >"$work/release-notes/releases.json" <<'JSON'
22 {"releases":[{"version":"1.2.3","channel":"stable","status":"reviewed"}]}
23 JSON
24 git -C "$work" add .
25 git -C "$work" commit -q -m notes
26 candidate="$(git -C "$work" rev-parse HEAD)"
27 git -C "$work" commit --allow-empty -q -m "unrelated later merge"
28 git -C "$work" remote add origin "$remote"
29 git -C "$work" push -q origin main-v2
30
31 (
32 cd "$work"
33 RELEASE_REMOTE=origin "$repo_root/scripts/validate-release-candidate-source.sh" 1.2.3 "$candidate"
34 )
35
36 git -C "$work" tag v1.2.3 "$candidate"
37 git -C "$work" push -q origin v1.2.3
38 (
39 cd "$work"
40 RELEASE_REMOTE=origin "$repo_root/scripts/validate-release-candidate-source.sh" 1.2.3 "$candidate" rehearsal
41 )
42 if (
43 cd "$work"
44 RELEASE_REMOTE=origin "$repo_root/scripts/validate-release-candidate-source.sh" 1.2.3 "$candidate"
45 ); then
46 echo "existing release identity unexpectedly passed candidate preparation" >&2
47 exit 1
48 fi
49 if (
50 cd "$work"
51 RELEASE_REMOTE=origin "$repo_root/scripts/validate-release-candidate-source.sh" 1.2.3 "$candidate" unsafe
52 ); then
53 echo "unknown candidate purpose unexpectedly passed" >&2
54 exit 1
55 fi
56
57 echo "release candidate source tests: PASS"
58
58 lines BASH