mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
test(release): share manifest check fixtures (#16505)
This commit is contained in:
1 parent
472db72f3e
commit
76cb7f37e7
1 file changed
+41
-59
@@ -153,7 +153,7 @@ beforeAll(async () => {
|
||||
await git(directory, ["add", "."]);
|
||||
await git(directory, ["commit", "-m", "chore: baseline"]);
|
||||
const base = await git(directory, ["rev-parse", "HEAD"]);
|
||||
await git(directory, ["tag", "rea-agents-6.3.0"]);
|
||||
await git(directory, ["tag", "--no-sign", "rea-agents-6.3.0"]);
|
||||
await git(directory, ["switch", "-c", "feature"]);
|
||||
await writeFile(join(directory, "feature.txt"), "capability");
|
||||
await git(directory, ["add", "."]);
|
||||
@@ -305,7 +305,19 @@ async function fixture() {
|
||||
"- Added the capability (#101; fixes #51, #52). Thanks @alice, @bob, @reporter, @second-reporter.";
|
||||
const notes = `## [6.4.0]\n\n### Highlights\n\n${bullet}\n\n### Changes\n\n### Fixes\n\n${record}`;
|
||||
await writeFile(join(directory, "CHANGELOG.md"), notes);
|
||||
return { directory, base, target, manifest, invoke, notes, record, bullet };
|
||||
const check = (...args: string[]) =>
|
||||
invoke(["check", "--manifest", manifest, ...args]);
|
||||
return {
|
||||
directory,
|
||||
base,
|
||||
target,
|
||||
manifest,
|
||||
invoke,
|
||||
check,
|
||||
notes,
|
||||
record,
|
||||
bullet,
|
||||
};
|
||||
}
|
||||
|
||||
it("inventories side branches and paginated credits, then checks and renders synchronized notes", async () => {
|
||||
@@ -341,13 +353,7 @@ it("inventories side branches and paginated credits, then checks and renders syn
|
||||
);
|
||||
const body = join(f.directory, "body.md");
|
||||
await writeFile(body, releaseBody(f.notes));
|
||||
const report = await f.invoke([
|
||||
"check",
|
||||
"--manifest",
|
||||
f.manifest,
|
||||
"--pr-body",
|
||||
body,
|
||||
]);
|
||||
const report = await f.check("--pr-body", body);
|
||||
expect(JSON.parse(report.stdout)).toMatchObject({
|
||||
commits: 3,
|
||||
pullRequests: 1,
|
||||
@@ -378,7 +384,7 @@ it("inventories side branches and paginated credits, then checks and renders syn
|
||||
"### Changes\n\n- Capability details (#101).\n- Related migration (#51).\n",
|
||||
);
|
||||
await writeFile(join(f.directory, "CHANGELOG.md"), conciseNotes);
|
||||
await f.invoke(["check", "--manifest", f.manifest]);
|
||||
await f.check();
|
||||
await writeFile(
|
||||
join(f.directory, "CHANGELOG.md"),
|
||||
conciseNotes.replace(
|
||||
@@ -386,9 +392,7 @@ it("inventories side branches and paginated credits, then checks and renders syn
|
||||
"6.3.0.contributions.json",
|
||||
),
|
||||
);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("Contribution record differs"),
|
||||
});
|
||||
await expect(
|
||||
@@ -439,9 +443,9 @@ it("rejects lost grouped credits, fabricated references, bots, and stale PR bodi
|
||||
join(f.directory, "CHANGELOG.md"),
|
||||
f.notes.replace(f.bullet, replacement!),
|
||||
);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({ stderr: expect.stringContaining(error!) });
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(error!),
|
||||
});
|
||||
}
|
||||
await writeFile(
|
||||
join(f.directory, "CHANGELOG.md"),
|
||||
@@ -450,25 +454,21 @@ it("rejects lost grouped credits, fabricated references, bots, and stale PR bodi
|
||||
f.bullet + "\n- See [#101](https://github.com/other/repo/pull/101).",
|
||||
),
|
||||
);
|
||||
await f.invoke(["check", "--manifest", f.manifest]);
|
||||
await f.check();
|
||||
await writeFile(join(f.directory, "CHANGELOG.md"), f.notes);
|
||||
const body = join(f.directory, "body.md");
|
||||
await writeFile(
|
||||
body,
|
||||
releaseBody(f.notes.replace("Added the capability", "Stale capability")),
|
||||
);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--pr-body", body]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check("--pr-body", body)).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("PR body differs"),
|
||||
});
|
||||
await writeFile(
|
||||
join(f.directory, "CHANGELOG.md"),
|
||||
f.notes.replace("### Complete contribution record", "### Missing record"),
|
||||
);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("Contribution record differs"),
|
||||
});
|
||||
});
|
||||
@@ -499,22 +499,20 @@ it("binds publication to complete recorded history and the reviewed base", async
|
||||
await git(f.directory, ["commit", "-m", "chore: release notes"]);
|
||||
const source = await git(f.directory, ["rev-parse", "HEAD"]);
|
||||
// Release PRs bump the plugin manifest version and pinned launch only.
|
||||
await f.invoke(["check", "--manifest", f.manifest, "--source", source]);
|
||||
await f.check("--source", source);
|
||||
await writeFile(join(f.directory, "product.txt"), "later product change");
|
||||
await git(f.directory, ["add", "product.txt"]);
|
||||
await git(f.directory, ["commit", "-m", "fix: later product change"]);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]),
|
||||
).rejects.toMatchObject({ stderr: expect.stringContaining("base moved") });
|
||||
await expect(f.check("--source", "HEAD")).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("base moved"),
|
||||
});
|
||||
const value = z
|
||||
.object({ commits: z.array(z.unknown()) })
|
||||
.passthrough()
|
||||
.parse(JSON.parse(await readFile(f.manifest, "utf8")));
|
||||
value.commits.pop();
|
||||
await writeFile(f.manifest, JSON.stringify(value));
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("complete local Git history"),
|
||||
});
|
||||
});
|
||||
@@ -531,9 +529,7 @@ it.each(pluginManifests)(
|
||||
);
|
||||
await git(f.directory, ["add", "CHANGELOG.md", path]);
|
||||
await git(f.directory, ["commit", "-m", "chore: release notes"]);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check("--source", "HEAD")).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
`Product changed after notes target; regenerate inventory: ${path}`,
|
||||
),
|
||||
@@ -547,14 +543,12 @@ it("allows the example's release version pin and rejects a changed workflow", as
|
||||
await writeFile(path, exampleWorkflow("6.4.0"));
|
||||
await git(f.directory, ["add", "CHANGELOG.md", githubActionsExample]);
|
||||
await git(f.directory, ["commit", "-m", "chore: release metadata"]);
|
||||
await f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]);
|
||||
await f.check("--source", "HEAD");
|
||||
|
||||
await writeFile(path, exampleWorkflow("6.4.0", "ubuntu-22.04"));
|
||||
await git(f.directory, ["add", githubActionsExample]);
|
||||
await git(f.directory, ["commit", "--amend", "--no-edit"]);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check("--source", "HEAD")).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
`Product changed after notes target; regenerate inventory: ${githubActionsExample}`,
|
||||
),
|
||||
@@ -569,7 +563,7 @@ it("accepts Release Please lockfile refreshes without allowing product changes",
|
||||
);
|
||||
await git(f.directory, ["add", "CHANGELOG.md", "package-lock.json"]);
|
||||
await git(f.directory, ["commit", "-m", "chore: release lockfiles"]);
|
||||
await f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]);
|
||||
await f.check("--source", "HEAD");
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -588,9 +582,7 @@ it.each([
|
||||
await writeFile(join(f.directory, path), JSON.stringify(content));
|
||||
await git(f.directory, ["add", "CHANGELOG.md", path]);
|
||||
await git(f.directory, ["commit", "-m", "chore: release notes"]);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check("--source", "HEAD")).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
`Product changed after notes target; regenerate inventory: ${path}`,
|
||||
),
|
||||
@@ -610,7 +602,7 @@ it("requires release notes that Release Please can extract from the PR body", as
|
||||
),
|
||||
]) {
|
||||
await writeFile(body, validBody);
|
||||
await f.invoke(["check", "--manifest", f.manifest, "--pr-body", body]);
|
||||
await f.check("--pr-body", body);
|
||||
}
|
||||
// The notes match the changelog, but metadata before the version heading
|
||||
// inside the delimiters makes Release Please publish an empty description.
|
||||
@@ -622,9 +614,7 @@ it("requires release notes that Release Please can extract from the PR body", as
|
||||
),
|
||||
]) {
|
||||
await writeFile(body, invalidBody);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--pr-body", body]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check("--pr-body", body)).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
"Release Please cannot extract 6.4.0 notes",
|
||||
),
|
||||
@@ -803,9 +793,7 @@ it.each(pluginMarketplaces)(
|
||||
);
|
||||
await git(f.directory, ["add", "CHANGELOG.md", path]);
|
||||
await git(f.directory, ["commit", "-m", "chore: release notes"]);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest, "--source", "HEAD"]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check("--source", "HEAD")).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
`Product changed after notes target; regenerate inventory: ${path}`,
|
||||
),
|
||||
@@ -855,15 +843,13 @@ it.each([
|
||||
const body = join(f.directory, "release-body.md");
|
||||
await writeFile(join(f.directory, "CHANGELOG.md"), changelog);
|
||||
await writeFile(body, releaseBody(notes));
|
||||
await f.invoke(["check", "--manifest", f.manifest, "--pr-body", body]);
|
||||
await f.check("--pr-body", body);
|
||||
|
||||
await writeFile(
|
||||
join(f.directory, "CHANGELOG.md"),
|
||||
changelog.replace(block, `${block}\n\n- Real issue #999.`),
|
||||
);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("Unknown release reference #999"),
|
||||
});
|
||||
},
|
||||
@@ -881,12 +867,10 @@ it("verifies complete bullets without counting inline code as credit or referenc
|
||||
.replace("Thanks", `Example ${example}.\n Thanks`);
|
||||
const notes = f.notes.replace(f.bullet, bullet);
|
||||
await writeFile(changelog, notes);
|
||||
await f.invoke(["check", "--manifest", f.manifest]);
|
||||
await f.check();
|
||||
|
||||
await writeFile(changelog, notes.replace(", @bob", ", `@bob`"));
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("Missing Thanks @bob for PR #101"),
|
||||
});
|
||||
});
|
||||
@@ -898,9 +882,7 @@ it("requires editorial headings in release prose outside code fences", async ()
|
||||
"~~~markdown\n### Changes\n~~~\n",
|
||||
);
|
||||
await writeFile(join(f.directory, "CHANGELOG.md"), notes);
|
||||
await expect(
|
||||
f.invoke(["check", "--manifest", f.manifest]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(f.check()).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("Missing Changes section"),
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user