返回 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 -- 'codewhale.bat' <<<"${body}"
33 grep -Fq -- 'The image exposes the same runtime as both `codewhale` and `codew`.' <<<"${body}"
34 grep -Fq -- '### Recommended — official GitHub release' <<<"${body}"
35 grep -Fq -- 'curl -fsSL https://codewhale.net/install.sh | CODEWHALE_VERSION="v1.2.3" sh' <<<"${body}"
36 grep -Fq -- '### Secondary packaging — npm and Cargo' <<<"${body}"
37 grep -Fq -- 'byte-identical compatibility copies' <<<"${body}"
38 grep -Fq -- 'sha256sum -c codewhale-bundles-sha256.txt --ignore-missing' <<<"${body}"
39 grep -Fq -- 'sha256sum -c codewhale-artifacts-sha256.txt --ignore-missing' <<<"${body}"
40 grep -Fq -- 'shasum -a 256 -c codewhale-bundles-sha256.txt --ignore-missing' <<<"${body}"
41 grep -Fq -- 'shasum -a 256 -c codewhale-artifacts-sha256.txt --ignore-missing' <<<"${body}"
42
43 checksum_dir="${tmp_dir}/checksums"
44 mkdir -p "${checksum_dir}"
45 printf 'downloaded platform\n' >"${checksum_dir}/codewhale-linux-x64.tar.gz"
46 present_hash="$(sha256sum "${checksum_dir}/codewhale-linux-x64.tar.gz" | awk '{print $1}')"
47 {
48 printf '%s %s\n' "${present_hash}" "codewhale-linux-x64.tar.gz"
49 printf '%064d %s\n' 0 "codewhale-windows-x64.zip"
50 } >"${checksum_dir}/codewhale-bundles-sha256.txt"
51 (
52 cd "${checksum_dir}"
53 sha256sum -c codewhale-bundles-sha256.txt --ignore-missing >/dev/null
54 )
55 if grep -Fq -- "### Contributors" <<<"${body}"; then
56 echo "nested contributor heading leaked into generated release body" >&2
57 exit 1
58 fi
59
60 echo "generate-release-body tests passed"
61
61 lines BASH