返回 CodeWhale
generate-release-body.test.sh
根目录 / scripts / release / generate-release-body.test.sh
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
5 tmp_dir="$(mktemp -d)"
6 trap 'rm -rf "${tmp_dir}"' EXIT
7
8 cat >"${tmp_dir}/CHANGELOG.md" <<'EOF'
9 ## [Unreleased]
10
11 ## [1.2.3] - 2026-07-14
12
13 ### Fixed
14
15 - A release fix.
16
17 ### Contributors
18
19 - [@example](https://github.com/example) — report and implementation.
20
21 ## [1.2.2] - 2026-07-01
22 EOF
23
24 body="$("${repo_root}/scripts/release/generate-release-body.sh" v1.2.3 "${tmp_dir}/CHANGELOG.md")"
25
26 grep -Fq -- "- A release fix." <<<"${body}"
27 grep -Fq -- "## Contributors" <<<"${body}"
28 grep -Fq -- "[@example](https://github.com/example)" <<<"${body}"
29 grep -Fq -- 'codewhale-home:/home/codewhale/.codewhale' <<<"${body}"
30 grep -Fq -- 'codewhale-android-arm64.tar.gz' <<<"${body}"
31 grep -Fq -- 'codewhale-windows-arm64.zip' <<<"${body}"
32 grep -Fq -- 'The image ships the `codewhale` dispatcher, `codew` shim, and `codewhale-tui` runtime.' <<<"${body}"
33 grep -Fq -- '### Recommended — npm (one command, all three entrypoints)' <<<"${body}"
34 grep -Fq -- 'sha256sum -c codewhale-bundles-sha256.txt --ignore-missing' <<<"${body}"
35 grep -Fq -- 'sha256sum -c codewhale-artifacts-sha256.txt --ignore-missing' <<<"${body}"
36 grep -Fq -- 'shasum -a 256 -c codewhale-bundles-sha256.txt --ignore-missing' <<<"${body}"
37 grep -Fq -- 'shasum -a 256 -c codewhale-artifacts-sha256.txt --ignore-missing' <<<"${body}"
38
39 checksum_dir="${tmp_dir}/checksums"
40 mkdir -p "${checksum_dir}"
41 printf 'downloaded platform\n' >"${checksum_dir}/codewhale-linux-x64.tar.gz"
42 present_hash="$(sha256sum "${checksum_dir}/codewhale-linux-x64.tar.gz" | awk '{print $1}')"
43 {
44 printf '%s %s\n' "${present_hash}" "codewhale-linux-x64.tar.gz"
45 printf '%064d %s\n' 0 "codewhale-windows-x64.zip"
46 } >"${checksum_dir}/codewhale-bundles-sha256.txt"
47 (
48 cd "${checksum_dir}"
49 sha256sum -c codewhale-bundles-sha256.txt --ignore-missing >/dev/null
50 )
51 if grep -Fq -- "### Contributors" <<<"${body}"; then
52 echo "nested contributor heading leaked into generated release body" >&2
53 exit 1
54 fi
55
56 echo "generate-release-body tests passed"
57
57 lines BASH