Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions packages/cli/scripts/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ export function compareVersions(a, b) {
return 0;
}

export const PACKED_SMOKE_COMMANDS = [
"deploy track",
"deploy id",
"doctor track",
"doctor id",
"update track",
"update id",
"connect id track",
];

/** Why a release stopped, said to whoever ran it without a stack. */
class Stop extends Error {}

Expand Down Expand Up @@ -388,7 +398,7 @@ async function main() {
env,
});
if (said !== version) stop(`The packed command says it is ${said}, not ${version}.`);
for (const command of ["deploy track", "deploy id", "update track", "connect id track"]) {
for (const command of PACKED_SMOKE_COMMANDS) {
const help = spawnSync(
process.execPath,
[npx, "--yes", spec, ...command.split(" "), "--help"],
Expand All @@ -398,7 +408,12 @@ async function main() {
encoding: "utf8",
},
);
if (help.status !== 0 || !help.stderr?.startsWith(`Usage: gateweave ${command} [options]`)) {
const first = help.stderr?.split(/\r?\n/, 1)[0];
if (
help.status !== 0 ||
help.stdout !== "" ||
first !== `Usage: gateweave ${command} [options]`
) {
stop(`The packed command did not show help for ${command}.`);
}
}
Expand All @@ -413,7 +428,13 @@ async function main() {
} catch {
stop("The packed command did not return JSON for an invalid option.");
}
if (invalid.status !== 2 || failure?.ok !== false || failure.code !== "usage") {
if (
invalid.status !== 2 ||
invalid.stderr !== "" ||
failure?.ok !== false ||
failure.code !== "usage" ||
typeof failure.reason !== "string"
) {
stop("The packed command did not report an invalid option as a usage error.");
}
console.log(
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/test/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
checkPackage,
compareNpmRelease,
compareVersions,
PACKED_SMOKE_COMMANDS,
readTar,
releaseKeys,
sha256sums,
Expand Down Expand Up @@ -139,6 +140,18 @@ test("compareVersions orders versions as semver does", () => {
assert.equal(compareVersions("1.2.3", "1.2.3"), 0);
});

test("the packed smoke covers every shipped command's help", () => {
assert.deepEqual(PACKED_SMOKE_COMMANDS, [
"deploy track",
"deploy id",
"doctor track",
"doctor id",
"update track",
"update id",
"connect id track",
]);
});

test("a release lives under its version, with sums sha256sum checks", () => {
assert.equal(tarballName("0.1.0"), "gateweave-0.1.0.tgz");
assert.deepEqual(releaseKeys("0.1.0"), {
Expand Down
Loading