Files
paseo/scripts/push-current-release-tag.test.mjs
T
Mohamed Boudra 01aa8b3406 Verify releases on isolated release branches and harden shipping (#10396)
* chore(release): verify releases on isolated release branches and harden shipping

High-traffic merges on main cancel more than half of main CI runs, so waiting on main CI repeatedly stalls releases. Releases also ran duplicate post-tag CI, lacked a release-branch Desktop Packages trigger, hit unretried Apple notarytool polling errors and a finalize-rollout directory bug on macOS retries, and relied on a non-idempotent npm publish chain and conflict-prone reconcile cherry-picks.

This splits release execution into release:prep:* (reversible version commit without tagging, pushed once to release/** for isolated CI + Desktop Packages) and release:ship[:beta] (idempotent npm publishing with retry, propagation checks, automatic beta dist-tag sync on stable, and release/*-only tag push), adds conflict-free main reconciliation, and extends macOS xcrun retries to notarytool submit and wait.

* fix(release): address review findings on Docker retries, tag push, and reconciliation

Isolate manual Docker publish dispatches in their own non-cancelling concurrency group, verify HEAD matches origin/<release-branch> before release:ship publishes or tags (and remove one-shot combined scripts that bypassed release-branch checks), drop --refs from peeled annotated-tag lookups in push-current-release-tag.mjs, retry lockfile sync in reconcile-release.mjs when package-lock.json version lags package.json, and document cutting from pre-existing tags.

* fix(release): preserve TTY OTP prompts in npm publish and keep newer beta changelogs

Inherit TTY stdin/stdout for interactive npm publish and dist-tag add (plus --otp passthrough) while keeping stderr piped for retry classification, and keep newer beta or promoted stable changelog entries intact when an older beta tag is reconciled.
2026-11-21 18:32:08 +07:00

82 lines
3.5 KiB
JavaScript

import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import test from "node:test";
import { assertReleaseBranch, pushCurrentReleaseTag } from "./push-current-release-tag.mjs";
function git(cwd, args) {
return execFileSync("git", args, { cwd, encoding: "utf8" }).trim();
}
function createReleaseRepoWithBareRemote(version = "0.17.0-beta.2") {
const root = mkdtempSync(path.join(tmpdir(), "push-release-tag-"));
const remote = path.join(root, "origin.git");
const repo = path.join(root, "work");
execFileSync("git", ["init", "--bare", "-q", remote]);
execFileSync("git", ["init", "-q", repo]);
git(repo, ["config", "user.name", "Test"]);
git(repo, ["config", "user.email", "test@example.com"]);
git(repo, ["remote", "add", "origin", remote]);
git(repo, ["checkout", "-b", `release/v${version}`]);
writeFileSync(
path.join(repo, "package.json"),
`${JSON.stringify({ name: "paseo", version }, null, 2)}\n`,
);
git(repo, ["add", "package.json"]);
git(repo, ["commit", "-q", "-m", `chore(release): cut ${version}`]);
return { root, remote, repo };
}
test("accepts release/* branches for release pushes", () => {
assert.doesNotThrow(() => assertReleaseBranch("release/v0.17.0-beta.2"));
assert.doesNotThrow(() => assertReleaseBranch("release/v0.17.0"));
assert.doesNotThrow(() => assertReleaseBranch("release/0.17.1-hotfix"));
});
test("refuses main and non-release branches for release pushes", () => {
assert.throws(() => assertReleaseBranch("main"), /release\/\*/);
assert.throws(() => assertReleaseBranch("feat/something"), /release\/\*/);
assert.throws(() => assertReleaseBranch("release/"), /release\/\*/);
assert.throws(() => assertReleaseBranch(""), /release\/\*/);
});
test("refuses to ship when HEAD has not been pushed to the remote release branch", () => {
const { root, repo } = createReleaseRepoWithBareRemote("0.17.0-beta.2");
try {
// Never pushed yet: --check and full push both fail before publishing or tagging.
assert.throws(() => pushCurrentReleaseTag(["--check"], { cwd: repo }), /does not match origin/);
assert.throws(() => pushCurrentReleaseTag([], { cwd: repo }), /does not match origin/);
// Push the verified commit, then add an unpushed local commit on top.
git(repo, ["push", "-q", "-u", "origin", "HEAD"]);
assert.doesNotThrow(() => pushCurrentReleaseTag(["--check"], { cwd: repo }));
writeFileSync(path.join(repo, "extra.txt"), "unverified\n");
git(repo, ["add", "extra.txt"]);
git(repo, ["commit", "-q", "-m", "extra local commit"]);
assert.throws(() => pushCurrentReleaseTag(["--check"], { cwd: repo }), /does not match origin/);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("retrying release:push succeeds cleanly when the annotated tag already points at HEAD on origin", () => {
const { root, repo } = createReleaseRepoWithBareRemote("0.17.0-beta.2");
try {
git(repo, ["push", "-q", "-u", "origin", "HEAD"]);
const first = pushCurrentReleaseTag([], { cwd: repo });
assert.equal(first.tag, "v0.17.0-beta.2");
// Re-running after the annotated tag already exists on origin must not report a false SHA mismatch.
const second = pushCurrentReleaseTag([], { cwd: repo });
assert.equal(second.tag, "v0.17.0-beta.2");
assert.equal(second.headCommit, first.headCommit);
} finally {
rmSync(root, { recursive: true, force: true });
}
});