mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
* fix(release): a stale local tag can no longer silently widen the changelog `release:prepare` creates `vX.Y.Z` locally at the branch commit, then the publish workflow creates the same tag at the merge SHA. After a squash merge those are different commits and the local one is not an ancestor of main, so `git describe` cannot reach it and falls back to the previous release without saying so. `git fetch --tags` does not help: it refuses to move a tag that already exists locally, and only `--force` does. On the v0.8.52 cut this produced a `v0.8.50...v0.8.52` draft that re-listed about a hundred already-shipped commits. The changelog is user-facing, and nothing in the output said the baseline was wrong. Adds a guard in the drafter: after resolving the baseline, fail if a stable tag exists locally that sits strictly between it and the release. `describe` only ever returns a reachable tag, so a tag in that range is proof it skipped one. The message names the tags and prints `git fetch origin --tags --force`. `--from` still overrides, for a deliberate baseline. Also prints the captures-gate hatch with the release PR instructions. Every release bumps packages/studio and packages/player, which scripts/check-pr-captures.mjs watches, so it demands before/after media for a version bump; its own `## No visible change` section is the intended answer and applies to a 4-line package.json diff. Verified end to end by moving a local tag onto the pre-squash commit of v0.8.51: the drafter fails with the fix, and drafts normally once restored. Six mutants of the range check are all caught by the tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * refactor(release): guard the baseline inside its resolver `resolvePreviousTag` only runs when `--from` was not supplied, so testing `!options.from` at the call site repeated a condition the `??` already expressed. Folding the guard into the resolver drops that branch, which had pushed `createDraft` to a CRAP score of exactly 30.0 and failed the audit. The assert sits outside the try/catch on purpose: `fail` exits rather than throwing today, and this keeps a catch from ever swallowing the guard if that changes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
152 lines
5.1 KiB
TypeScript
152 lines
5.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
import {
|
|
escapeForMdx,
|
|
findSkippedReleaseTags,
|
|
parseArgs,
|
|
parseCommit,
|
|
renderCommitBullet,
|
|
renderMdxCommitBullet,
|
|
shouldSkipCommit,
|
|
type RawCommit,
|
|
} from "./draft-changelog.ts";
|
|
|
|
const REPO_URL = "https://github.com/heygen-com/hyperframes";
|
|
|
|
function commit(subject: string): RawCommit {
|
|
return {
|
|
sha: "1234567890abcdef1234567890abcdef12345678",
|
|
shortSha: "1234567",
|
|
author: "Test Author",
|
|
subject,
|
|
};
|
|
}
|
|
|
|
describe("draft changelog arguments", () => {
|
|
it("parses positional, value, inline, and boolean options", () => {
|
|
assert.deepEqual(
|
|
parseArgs([
|
|
"v1.2.3",
|
|
"--from",
|
|
"v1.2.2",
|
|
"--to=HEAD",
|
|
"--date",
|
|
"2026-06-02",
|
|
"--write",
|
|
"--force",
|
|
]),
|
|
{
|
|
version: "1.2.3",
|
|
from: "v1.2.2",
|
|
to: "HEAD",
|
|
date: "2026-06-02",
|
|
write: true,
|
|
force: true,
|
|
},
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("draft changelog commit parsing", () => {
|
|
it("categorizes conventional commit types", () => {
|
|
assert.equal(parseCommit(commit("feat: add timeline markers")).category, "Features");
|
|
assert.equal(parseCommit(commit("fix: repair audio sync")).category, "Fixes");
|
|
assert.equal(parseCommit(commit("perf: reduce render startup")).category, "Performance");
|
|
assert.equal(parseCommit(commit("docs: update quickstart")).category, "Docs & Examples");
|
|
assert.equal(parseCommit(commit("test: cover frame capture")).category, "Internal");
|
|
assert.equal(parseCommit(commit("move the preview panel")).category, "Other Changes");
|
|
});
|
|
|
|
it("detects catalog changes from scope or summary", () => {
|
|
assert.equal(parseCommit(commit("feat(catalog): add kinetic title")).category, "Catalog");
|
|
assert.equal(parseCommit(commit("fix: repair registry preview metadata")).category, "Catalog");
|
|
});
|
|
|
|
it("lets breaking changes override the normal category", () => {
|
|
const parsed = parseCommit(commit("fix(cli)!: remove legacy render flag"));
|
|
|
|
assert.equal(parsed.breaking, true);
|
|
assert.equal(parsed.category, "Breaking Changes");
|
|
});
|
|
|
|
it("skips release, bump, and explicit skip commits", () => {
|
|
assert.equal(shouldSkipCommit(commit("chore: release v1.2.3")), true);
|
|
assert.equal(shouldSkipCommit(commit("chore: bump version to v1.2.3")), true);
|
|
assert.equal(shouldSkipCommit(commit("fix: internal cleanup [skip changelog]")), true);
|
|
assert.equal(shouldSkipCommit(commit("fix: real user-facing bug")), false);
|
|
});
|
|
});
|
|
|
|
describe("draft changelog rendering", () => {
|
|
it("renders commit bullets with scope and pull request links", () => {
|
|
const parsed = parseCommit(commit("feat(cli): add render hints (#42)"));
|
|
|
|
assert.equal(
|
|
renderCommitBullet(parsed),
|
|
`- **CLI:** Add render hints ([1234567](${REPO_URL}/commit/1234567890abcdef1234567890abcdef12345678), [#42](${REPO_URL}/pull/42)).`,
|
|
);
|
|
});
|
|
|
|
it("renders commit bullets without scope or pull request links", () => {
|
|
const parsed = parseCommit(commit("fix: repair playback"));
|
|
|
|
assert.equal(
|
|
renderCommitBullet(parsed),
|
|
`- Repair playback ([1234567](${REPO_URL}/commit/1234567890abcdef1234567890abcdef12345678)).`,
|
|
);
|
|
});
|
|
|
|
it("escapes MDX-sensitive characters only in docs bullets", () => {
|
|
const parsed = parseCommit(commit("feat(docs): support <Update> blocks with {tags} (#7)"));
|
|
|
|
assert.equal(
|
|
escapeForMdx("\\<Update>{tags}</Update>"),
|
|
"\\\\\\<Update\\>\\{tags\\}\\</Update\\>",
|
|
);
|
|
assert.ok(
|
|
renderMdxCommitBullet(parsed).includes("Support \\<Update\\> blocks with \\{tags\\}"),
|
|
);
|
|
assert.ok(renderCommitBullet(parsed).includes("Support <Update> blocks with {tags}"));
|
|
});
|
|
});
|
|
|
|
describe("skipped release tags", () => {
|
|
const TAGS = ["0.8.49", "0.8.50", "0.8.51"];
|
|
|
|
it("names a tag the baseline skipped", () => {
|
|
// The v0.8.52 cut: a stale local v0.8.51 was unreachable, so describe fell
|
|
// back to v0.8.50 and the draft re-listed ~100 already-released commits.
|
|
assert.deepEqual(findSkippedReleaseTags(TAGS, "v0.8.50", "0.8.52"), ["0.8.51"]);
|
|
});
|
|
|
|
it("passes when the baseline is the immediately preceding release", () => {
|
|
assert.deepEqual(findSkippedReleaseTags(TAGS, "v0.8.51", "0.8.52"), []);
|
|
});
|
|
|
|
it("excludes the baseline and the release being drafted", () => {
|
|
// Both ends are exclusive: v0.8.50 is the baseline and v0.8.51 is the
|
|
// release, so neither counts as skipped.
|
|
assert.deepEqual(findSkippedReleaseTags(TAGS, "v0.8.50", "0.8.51"), []);
|
|
});
|
|
|
|
it("reports every skipped release in ascending order", () => {
|
|
assert.deepEqual(findSkippedReleaseTags(TAGS, "v0.8.48", "0.8.52"), [
|
|
"0.8.49",
|
|
"0.8.50",
|
|
"0.8.51",
|
|
]);
|
|
});
|
|
|
|
it("compares numerically, not lexically", () => {
|
|
// "0.8.9" > "0.8.10" as strings; a string sort would miss this entirely.
|
|
assert.deepEqual(findSkippedReleaseTags(["0.8.9", "0.8.10"], "v0.8.8", "0.8.11"), [
|
|
"0.8.9",
|
|
"0.8.10",
|
|
]);
|
|
});
|
|
|
|
it("accepts a baseline with or without the v prefix", () => {
|
|
assert.deepEqual(findSkippedReleaseTags(TAGS, "0.8.50", "0.8.52"), ["0.8.51"]);
|
|
});
|
|
});
|