mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
test(release): share publication verification fixture calls (#15954)
This commit is contained in:
1 parent
1d8be981a9
commit
e59e558993
1 file changed
+22
-68
@@ -634,6 +634,15 @@ it("requires release notes that Release Please can extract from the PR body", as
|
||||
|
||||
it("checks the live merged PR and exact Git snapshot before either publication route", async () => {
|
||||
const f = await fixture();
|
||||
const publication = (sourceCommit: string, ...options: string[]) =>
|
||||
f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
sourceCommit,
|
||||
...options,
|
||||
]);
|
||||
await mkdir(join(f.directory, "docs/releases"), { recursive: true });
|
||||
await writeFile(
|
||||
join(f.directory, "docs/releases/6.4.0.contributions.json"),
|
||||
@@ -666,31 +675,14 @@ it("checks the live merged PR and exact Git snapshot before either publication r
|
||||
const prFile = join(f.directory, ".git/release-pr.json");
|
||||
await writeFile(prFile, JSON.stringify(pr));
|
||||
for (const selector of [[], ["--pr", "1399"]]) {
|
||||
const result = await f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
source,
|
||||
...selector,
|
||||
]);
|
||||
const result = await publication(source, ...selector);
|
||||
expect(JSON.parse(result.stdout)).toMatchObject({
|
||||
status: "verified",
|
||||
version: "6.4.0",
|
||||
commits: 3,
|
||||
});
|
||||
}
|
||||
const branchArgs = [
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
source,
|
||||
"--pr",
|
||||
"1399",
|
||||
"--target-branch",
|
||||
"main",
|
||||
];
|
||||
const branchArgs = ["--pr", "1399", "--target-branch", "main"];
|
||||
// Matching source alone does not establish the selected release route.
|
||||
await writeFile(
|
||||
prFile,
|
||||
@@ -704,49 +696,33 @@ it("checks the live merged PR and exact Git snapshot before either publication r
|
||||
}),
|
||||
);
|
||||
for (const selector of [[], ["--pr", "1399"]]) {
|
||||
const manual = await f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
const manual = await publication(
|
||||
source,
|
||||
"--target-branch",
|
||||
"release/6.4.0",
|
||||
...selector,
|
||||
]);
|
||||
);
|
||||
expect(JSON.parse(manual.stdout)).toMatchObject({
|
||||
status: "verified",
|
||||
version: "6.4.0",
|
||||
});
|
||||
}
|
||||
await expect(f.invoke(branchArgs)).rejects.toMatchObject({
|
||||
await expect(publication(source, ...branchArgs)).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining(
|
||||
"Expected exactly one merged Release Please PR",
|
||||
),
|
||||
});
|
||||
await writeFile(prFile, JSON.stringify(pr));
|
||||
expect(JSON.parse((await f.invoke(branchArgs)).stdout)).toMatchObject({
|
||||
expect(
|
||||
JSON.parse((await publication(source, ...branchArgs)).stdout),
|
||||
).toMatchObject({
|
||||
status: "verified",
|
||||
});
|
||||
// Worktree edits cannot substitute for the reviewed source.
|
||||
await writeFile(join(f.directory, "CHANGELOG.md"), "unreviewed working text");
|
||||
await f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
source,
|
||||
]);
|
||||
await publication(source);
|
||||
await writeFile(prFile, JSON.stringify({ ...pr, body: null }));
|
||||
await expect(
|
||||
f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
source,
|
||||
]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(publication(source)).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("no release notes body"),
|
||||
});
|
||||
await writeFile(
|
||||
@@ -756,15 +732,7 @@ it("checks the live merged PR and exact Git snapshot before either publication r
|
||||
body: pr.body.replace("Added the capability", "Different release"),
|
||||
}),
|
||||
);
|
||||
await expect(
|
||||
f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
source,
|
||||
]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(publication(source)).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("PR body differs"),
|
||||
});
|
||||
await writeFile(prFile, JSON.stringify(pr));
|
||||
@@ -772,28 +740,14 @@ it("checks the live merged PR and exact Git snapshot before either publication r
|
||||
await git(f.directory, ["commit", "-m", "chore: remove inventory"]);
|
||||
const missing = await git(f.directory, ["rev-parse", "HEAD"]);
|
||||
await writeFile(prFile, JSON.stringify({ ...pr, merge_commit_sha: missing }));
|
||||
await expect(
|
||||
f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
missing,
|
||||
]),
|
||||
).rejects.toMatchObject({
|
||||
await expect(publication(missing)).rejects.toMatchObject({
|
||||
stderr: expect.stringContaining("missing its contribution inventory"),
|
||||
});
|
||||
await writeFile(
|
||||
prFile,
|
||||
JSON.stringify({ ...pr, merge_commit_sha: missing, labels: [] }),
|
||||
);
|
||||
const legacy = await f.invoke([
|
||||
"publication",
|
||||
"--repository",
|
||||
"fixture/rea",
|
||||
"--source",
|
||||
missing,
|
||||
]);
|
||||
const legacy = await publication(missing);
|
||||
expect(JSON.parse(legacy.stdout)).toMatchObject({ status: "legacy" });
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user