Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci(release): separate merge-back from next plan (#7292)

Cindy Zhang0686fad6b6c9
diff --git a/.github/scripts/release-publish-workflow.test.mjs b/.github/scripts/release-publish-workflow.test.mjs
index e90072565e..3660d2ead4 100644
--- a/.github/scripts/release-publish-workflow.test.mjs
+++ b/.github/scripts/release-publish-workflow.test.mjs
@@ -84,9 +84,24 @@ describe('stable and canary publication authority', () => {
expect(publish).not.toContain('--tag canary');
});
- it('keeps canary ephemeral and unable to mutate stable authority', () => {
+ it('publishes canaries only while main is strictly ahead of stable', () => {
+ const eligibility = step(
+ canary,
+ 'Decide whether main may publish a canary',
+ );
+ expect(eligibility.run).toContain("'refs/tags/v*:refs/tags/v*'");
+ expect(eligibility.run).toContain('canary-eligibility');
+ for (const name of [
+ 'Setup Node and pnpm',
+ 'Build all packages',
+ 'Publish canary versions',
+ 'Prune old canary versions',
+ ]) {
+ expect(step(canary, name).if).toBe(
+ "steps.canary-scope.outputs.publish == 'true'",
+ );
+ }
const publish = step(canary, 'Publish canary versions').run;
- // FR46: canaries carry the next version main declares.
expect(publish).toContain(
'DECLARED_VERSION=$(node -p "require(\'./packages/core/package.json\').version")',
);
@@ -94,59 +109,60 @@ describe('stable and canary publication authority', () => {
expect(publish).toContain('--tag canary');
expect(publish).not.toContain('--tag latest');
const canaryText = JSON.stringify(canary);
- expect(canaryText).not.toContain('.release/');
+ expect(canaryText).not.toContain('.release/active.json');
expect(canaryText).not.toContain('release-publish-receipt');
- expect(canaryText).not.toContain('active-release.mjs');
});
- it('validates every main sync against trusted base policy and the immutable tag', () => {
- const sync = ci.jobs['release-sync'];
- expect(sync.if).toContain("github.base_ref == 'main'");
- const scope = step(sync, 'Detect the release-sync branch contract').run;
- expect(scope).toContain('chore/sync-v*-to-main');
+ it('validates every main merge-back against trusted policy and the immutable tag', () => {
+ const mergeBack = ci.jobs['release-merge-back'];
+ expect(mergeBack.if).toContain("github.base_ref == 'main'");
+ const scope = step(
+ mergeBack,
+ 'Detect the release-merge-back branch contract',
+ ).run;
+ expect(scope).toContain('chore/merge-v*-to-main');
expect(scope).not.toContain('stable package-version change on main');
const lintScope = step(
lint.jobs.lint,
- 'Detect the release-sync branch contract',
+ 'Detect the release merge-back branch contract',
).run;
- expect(lintScope).toContain('chore/sync-v*-to-main');
+ expect(lintScope).toContain('chore/merge-v*-to-main');
expect(lintScope).toContain("grep -Eq '^[0-9]+\\.[0-9]+\\.[0-9]+$'");
- // FR46: the tag-relative version guard lives in required lint, not the
- // optional release-sync context.
const declared = step(
lint.jobs.lint,
"Keep main's declared version above latest stable",
);
- expect(declared.if).toBe("github.event_name == 'pull_request'");
+ expect(declared.if).toBe(
+ "github.event_name == 'pull_request' && steps.release-merge-back-scope.outputs.required != 'true'",
+ );
expect(declared.run).toContain(
'git show origin/main:scripts/release/active-release.mjs',
);
expect(declared.run).toContain("'refs/tags/v*:refs/tags/v*'");
- expect(declared.run).toContain('ALLOW_BOOTSTRAP_EQUAL=false');
- expect(declared.run).toContain('ALLOW_BOOTSTRAP_EQUAL=true');
expect(declared.run).toContain(
- '--allow-bootstrap-equal "$ALLOW_BOOTSTRAP_EQUAL"',
+ "'+refs/heads/release/v*:refs/remotes/origin/release/v*'",
);
+ expect(declared.run).not.toContain('allow-bootstrap-equal');
expect(declared.run).toContain('validate-main-version');
expect(declared.run).toContain('--base origin/main');
- expect(JSON.stringify(sync)).not.toContain('validate-main-version');
+ expect(JSON.stringify(mergeBack)).not.toContain('validate-main-version');
expect(step(lint.jobs.lint, 'Check Changeset coverage').if).toBe(
- "github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required != 'true'",
+ "github.event_name == 'pull_request' && steps.release-merge-back-scope.outputs.required != 'true'",
);
const requiredLintValidation = step(
lint.jobs.lint,
- 'Validate release sync in required lint',
+ 'Validate release merge-back in required lint',
);
expect(requiredLintValidation.if).toBe(
- "github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required == 'true'",
+ "github.event_name == 'pull_request' && steps.release-merge-back-scope.outputs.required == 'true'",
);
for (const command of [
'git show origin/main:scripts/release/active-release.mjs',
'git show origin/main:scripts/lib/workspace-globs.mjs',
- 'validate-sync',
+ 'validate-merge-back',
'--base origin/main',
'--release-ref "v$VERSION"',
'--active-branches "$ACTIVE_BRANCHES"',
@@ -154,18 +170,18 @@ describe('stable and canary publication authority', () => {
expect(requiredLintValidation.run).toContain(command);
}
const validation = step(
- sync,
- 'Validate published bytes and consumed-only Changeset sync',
+ mergeBack,
+ 'Validate published bytes and consumed-only Changeset merge-back',
).run;
- expect(validation).toContain('validate-sync');
+ expect(validation).toContain('validate-merge-back');
expect(validation).toContain('--base origin/main');
expect(validation).toContain('--release-ref "v$VERSION"');
expect(validation).toContain('--active-branches "$ACTIVE_BRANCHES"');
expect(
- step(sync, 'Fetch release authority and trusted validator').run,
+ step(mergeBack, 'Fetch release authority and trusted validator').run,
).toContain('git show origin/main:scripts/release/active-release.mjs');
const parity = step(
- sync,
+ mergeBack,
'Verify immutable tag package bytes match npm',
).run;
expect(parity).toContain('git worktree add --detach');
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index bdcc564e56..282f49ff1c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -267,28 +267,28 @@ jobs:
path: release-bump-receipt.json
retention-days: 30
- release-sync:
- name: release-sync
+ release-merge-back:
+ name: release-merge-back
if: ${{ github.event_name == 'pull_request' && github.base_ref == 'main' }}
# Match the stable publisher so byte parity covers the same packed manifest.
runs-on: 4-core-ubuntu
permissions:
contents: read
steps:
- - name: Checkout sync candidate
+ - name: Checkout merge-back candidate
uses: actions/checkout@v7
with:
fetch-depth: 0
- - name: Detect the release-sync branch contract
- id: release-sync-scope
+ - name: Detect the release-merge-back branch contract
+ id: release-merge-back-scope
env:
- SYNC_BRANCH: ${{ github.head_ref }}
+ MERGE_BRANCH: ${{ github.head_ref }}
run: |
set -eu
- case "$SYNC_BRANCH" in
- chore/sync-v*-to-main)
- VERSION=${SYNC_BRANCH#chore/sync-v}
+ case "$MERGE_BRANCH" in
+ chore/merge-v*-to-main)
+ VERSION=${MERGE_BRANCH#chore/merge-v}
VERSION=${VERSION%-to-main}
printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'
echo 'required=true' >> "$GITHUB_OUTPUT"
@@ -299,7 +299,7 @@ jobs:
esac
- name: Fetch release authority and trusted validator
- if: steps.release-sync-scope.outputs.required == 'true'
+ if: steps.release-merge-back-scope.outputs.required == 'true'
run: |
set -eu
git fetch origin main 'refs/tags/v*:refs/tags/v*' '+refs/heads/release/v*:refs/remotes/origin/release/v*'
@@ -310,36 +310,36 @@ jobs:
git show origin/main:scripts/lib/workspace-globs.mjs \
> "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs"
- - name: Validate published bytes and consumed-only Changeset sync
- if: steps.release-sync-scope.outputs.required == 'true'
+ - name: Validate published bytes and consumed-only Changeset merge-back
+ if: steps.release-merge-back-scope.outputs.required == 'true'
env:
- SYNC_BRANCH: ${{ github.head_ref }}
+ MERGE_BRANCH: ${{ github.head_ref }}
run: |
set -eu
- VERSION=${SYNC_BRANCH#chore/sync-v}
+ VERSION=${MERGE_BRANCH#chore/merge-v}
VERSION=${VERSION%-to-main}
printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'
VALIDATOR="$RUNNER_TEMP/release-policy/scripts/release/active-release.mjs"
ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE")
- node "$VALIDATOR" validate-sync \
+ node "$VALIDATOR" validate-merge-back \
--root "$GITHUB_WORKSPACE" \
--base origin/main \
--release-ref "v$VERSION" \
--active-branches "$ACTIVE_BRANCHES"
- name: Setup Node and pnpm for published-byte verification
- if: steps.release-sync-scope.outputs.required == 'true'
+ if: steps.release-merge-back-scope.outputs.required == 'true'
uses: ./.github/actions/setup
with:
install: 'false'
- name: Verify immutable tag package bytes match npm
- if: steps.release-sync-scope.outputs.required == 'true'
+ if: steps.release-merge-back-scope.outputs.required == 'true'
env:
- SYNC_BRANCH: ${{ github.head_ref }}
+ MERGE_BRANCH: ${{ github.head_ref }}
run: |
set -eu
- VERSION=${SYNC_BRANCH#chore/sync-v}
+ VERSION=${MERGE_BRANCH#chore/merge-v}
VERSION=${VERSION%-to-main}
TAG_ROOT="$RUNNER_TEMP/release-tag"
git worktree add --detach "$TAG_ROOT" "v$VERSION"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a750252403..279290fd21 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -48,48 +48,19 @@ jobs:
>> "$GITHUB_OUTPUT"
fi
- # Main declares the next planned version (spec:AST-017 FR46). An owner may
- # raise or lower it before cut, but it must remain strictly above the newest
- # stable tag and keep the fixed group together. This runs in required lint,
- # not the optional release-sync context, so every main pull request is gated.
- - name: Keep main's declared version above latest stable
+ # Merge-back is the one trusted path allowed to leave main equal to the
+ # newest stable tag (spec:AST-017 FR50). Detect it before the ordinary
+ # version guard so required lint can route to the stronger validator.
+ - name: Detect the release merge-back branch contract
if: github.event_name == 'pull_request'
- run: |
- set -eu
- git fetch origin main 'refs/tags/v*:refs/tags/v*'
- TRUSTED_POLICY="$RUNNER_TEMP/main-version-policy"
- mkdir -p "$TRUSTED_POLICY/scripts/release" "$TRUSTED_POLICY/scripts/lib"
- git show origin/main:scripts/release/active-release.mjs \
- > "$TRUSTED_POLICY/scripts/release/active-release.mjs"
- git show origin/main:scripts/lib/workspace-globs.mjs \
- > "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs"
- VALIDATOR="$TRUSTED_POLICY/scripts/release/active-release.mjs"
- ALLOW_BOOTSTRAP_EQUAL=false
- if ! grep -q 'validate-main-version' "$VALIDATOR"; then
- # Main's trusted policy predates this command; the candidate's copy
- # applies only while this command is landing. Current main still
- # equals the newest tag until the separate owner bump lands next.
- VALIDATOR="$GITHUB_WORKSPACE/scripts/release/active-release.mjs"
- ALLOW_BOOTSTRAP_EQUAL=true
- fi
- node "$VALIDATOR" validate-main-version \
- --root "$GITHUB_WORKSPACE" \
- --base origin/main \
- --allow-bootstrap-equal "$ALLOW_BOOTSTRAP_EQUAL"
-
- # Release-sync PRs copy already-published generated outputs and consume the
- # frozen Changesets. They cannot add a new Changeset, so the required lint
- # context runs the trusted release-sync validator instead.
- - name: Detect the release-sync branch contract
- if: github.event_name == 'pull_request'
- id: release-sync-scope
+ id: release-merge-back-scope
env:
- SYNC_BRANCH: ${{ github.head_ref }}
+ MERGE_BRANCH: ${{ github.head_ref }}
run: |
required=false
- case "$SYNC_BRANCH" in
- chore/sync-v*-to-main)
- VERSION=${SYNC_BRANCH#chore/sync-v}
+ case "$MERGE_BRANCH" in
+ chore/merge-v*-to-main)
+ VERSION=${MERGE_BRANCH#chore/merge-v}
VERSION=${VERSION%-to-main}
if printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
required=true
@@ -98,13 +69,31 @@ jobs:
esac
echo "required=$required" >> "$GITHUB_OUTPUT"
- - name: Validate release sync in required lint
- if: github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required == 'true'
+ # Every ordinary main PR must keep the declaration above stable. The
+ # separate FR51 next-plan PR exits merge-back equality; no bootstrap or
+ # generic equality exception exists.
+ - name: Keep main's declared version above latest stable
+ if: github.event_name == 'pull_request' && steps.release-merge-back-scope.outputs.required != 'true'
+ run: |
+ set -eu
+ git fetch origin main 'refs/tags/v*:refs/tags/v*' '+refs/heads/release/v*:refs/remotes/origin/release/v*'
+ TRUSTED_POLICY="$RUNNER_TEMP/main-version-policy"
+ mkdir -p "$TRUSTED_POLICY/scripts/release" "$TRUSTED_POLICY/scripts/lib"
+ git show origin/main:scripts/release/active-release.mjs \
+ > "$TRUSTED_POLICY/scripts/release/active-release.mjs"
+ git show origin/main:scripts/lib/workspace-globs.mjs \
+ > "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs"
+ node "$TRUSTED_POLICY/scripts/release/active-release.mjs" validate-main-version \
+ --root "$GITHUB_WORKSPACE" \
+ --base origin/main
+
+ - name: Validate release merge-back in required lint
+ if: github.event_name == 'pull_request' && steps.release-merge-back-scope.outputs.required == 'true'
env:
- SYNC_BRANCH: ${{ github.head_ref }}
+ MERGE_BRANCH: ${{ github.head_ref }}
run: |
set -eu
- VERSION=${SYNC_BRANCH#chore/sync-v}
+ VERSION=${MERGE_BRANCH#chore/merge-v}
VERSION=${VERSION%-to-main}
git fetch origin main 'refs/tags/v*:refs/tags/v*' '+refs/heads/release/v*:refs/remotes/origin/release/v*'
TRUSTED_POLICY="$RUNNER_TEMP/release-policy"
@@ -115,7 +104,7 @@ jobs:
> "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs"
VALIDATOR="$TRUSTED_POLICY/scripts/release/active-release.mjs"
ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE")
- node "$VALIDATOR" validate-sync \
+ node "$VALIDATOR" validate-merge-back \
--root "$GITHUB_WORKSPACE" \
--base origin/main \
--release-ref "v$VERSION" \
@@ -125,7 +114,7 @@ jobs:
# released CLI JSON id cannot disappear unclassified. The release coverage
# audit runs the same classifier over the cut range, so the two agree.
- name: Check Changeset coverage
- if: github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required != 'true'
+ if: github.event_name == 'pull_request' && steps.release-merge-back-scope.outputs.required != 'true'
env:
MERGE_SHA: ${{ github.sha }}
run: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9d0e96a0af..ed1a87ad6a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -24,9 +24,10 @@
# release branch and head. Stable publication from main is rejected.
# Version-gated and idempotent: any version already on the registry is
# skipped, so re-running (or a `dry-run` first) is safe.
-# - canary: push to main only. Main declares the next planned version, so
-# this publishes <declared>-canary.<short-sha> to the `canary` dist-tag on
-# every push to main:
+# - canary: push to main only. Main normally declares the next planned version,
+# so this publishes <declared>-canary.<short-sha> to the `canary` dist-tag.
+# The trusted release merge-back briefly leaves main equal to the stable tag;
+# that push publishes no canary and waits for the separate next-plan PR:
# npm install @astryxdesign/core@canary
#
# Why both jobs live here instead of in deploy.yml:
@@ -201,19 +202,31 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
+ with:
+ fetch-depth: 0
+
+ - name: Decide whether main may publish a canary
+ id: canary-scope
+ run: |
+ set -eu
+ git fetch origin 'refs/tags/v*:refs/tags/v*'
+ node scripts/release/active-release.mjs canary-eligibility
# registry-url makes setup-node write the auth config `npm publish` reads.
# The Node line in .nvmrc must stay >= 24 so npm >= 11.5.1 ships with it,
# which OIDC trusted publishing requires.
- name: Setup Node and pnpm
+ if: steps.canary-scope.outputs.publish == 'true'
uses: ./.github/actions/setup
with:
registry-url: 'https://registry.npmjs.org'
- name: Build all packages
+ if: steps.canary-scope.outputs.publish == 'true'
run: pnpm build
- name: Publish canary versions
+ if: steps.canary-scope.outputs.publish == 'true'
# Pure OIDC trusted publishing — no NPM_TOKEN.
run: |
set -eu
@@ -278,6 +291,7 @@ jobs:
echo "Canary published: npm install @astryxdesign/core@${CANARY_VERSION}"
- name: Prune old canary versions
+ if: steps.canary-scope.outputs.publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
diff --git a/scripts/release/active-release.mjs b/scripts/release/active-release.mjs
index 547b3d91bd..1e1e3915a0 100644
--- a/scripts/release/active-release.mjs
+++ b/scripts/release/active-release.mjs
@@ -309,7 +309,7 @@ function releaseOutputMapAtRef(root, plan, releaseRef) {
return new Map(
releaseOutputPathsAtRef(root, plan, releaseRef)
.filter(isReleaseOutputPath)
- .filter(file => !isPackageManifestPath(file) && file !== 'pnpm-lock.yaml')
+ .filter(file => !isPackageManifestPath(file))
.map(file => [file, fileDigestAtRef(root, releaseRef, file)]),
);
}
@@ -469,41 +469,61 @@ const VERSION_DEPENDENCY_FIELDS = [
'peerDependencies',
];
const EXACT_SPEC_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
-
function patchSuccessor(version) {
if (!VERSION_RE.test(version ?? '')) return null;
const [major, minor, patch] = version.split('.').map(Number);
return `${major}.${minor}.${patch + 1}`;
}
+function minorSuccessor(version) {
+ if (!VERSION_RE.test(version ?? '')) return null;
+ const [major, minor] = version.split('.').map(Number);
+ return `${major}.${minor + 1}.0`;
+}
+
/**
- * FR50 — the version main declares after syncing a release: the higher of
- * main's version and the released version's patch successor. Main declares
- * the next patch by default and keeps an owner's higher bump.
- *
- * @param {string} mainVersion main's fixed-group version at the sync base
- * @param {string} releaseVersion the published version
- * @returns {string|null}
+ * FR51 — choose the next declaration after merge-back. Patch is the operational
+ * default. An owner-named value may select only the patch or minor successor;
+ * pending Changesets never choose or skip the plan.
*/
-function syncedMainVersion(mainVersion, releaseVersion) {
- const next = patchSuccessor(releaseVersion);
- const order = compareVersions(mainVersion, next);
- if (next === null || order === null) return null;
- return order >= 0 ? mainVersion : next;
+function nextPlannedVersion(releaseVersion, ownerVersion = null) {
+ const patch = patchSuccessor(releaseVersion);
+ const minor = minorSuccessor(releaseVersion);
+ if (patch === null || minor === null) return null;
+ if (ownerVersion === null) return patch;
+ return ownerVersion === patch || ownerVersion === minor ? ownerVersion : null;
}
/**
- * A main manifest after sync: fixed-group members carry `version`, and every
- * exact internal pin on a fixed-group package points at it, the way
- * sync-internal-deps keeps them. Nothing else changes.
+ * Apply only the generated manifest delta from the published branch to current
+ * main. This preserves post-cut main fields while carrying an allowed release
+ * version or exact-internal-pin change byte-for-byte.
*/
-function syncedManifest(base, {version, fixedNames}) {
+function mergedReleaseManifest(base, cut, release, {mainVersion, fixedNames}) {
+ if (!base || !cut || !release) return null;
const expected = structuredClone(base);
- if (fixedNames.has(base.name)) expected.version = version;
+ if (cut.version !== release.version) expected.version = release.version;
for (const field of VERSION_DEPENDENCY_FIELDS) {
- for (const [name, spec] of Object.entries(expected[field] ?? {})) {
- if (fixedNames.has(name) && EXACT_SPEC_RE.test(spec))
- expected[field][name] = version;
+ const cutValues = cut[field] ?? {};
+ const releaseValues = release[field] ?? {};
+ for (const name of new Set([
+ ...Object.keys(cutValues),
+ ...Object.keys(releaseValues),
+ ])) {
+ if (canonicalJson(cutValues[name]) === canonicalJson(releaseValues[name]))
+ continue;
+ expected[field] ??= {};
+ if (releaseValues[name] === undefined) delete expected[field][name];
+ else expected[field][name] = releaseValues[name];
+ }
+ }
+ if (mainVersion) {
+ if (fixedNames.has(expected.name)) expected.version = mainVersion;
+ for (const field of VERSION_DEPENDENCY_FIELDS) {
+ for (const [name, spec] of Object.entries(expected[field] ?? {})) {
+ if (fixedNames.has(name) && EXACT_SPEC_RE.test(spec))
+ expected[field][name] = mainVersion;
+ }
}
}
return expected;
@@ -515,7 +535,7 @@ function syncedManifest(base, {version, fixedNames}) {
*/
function releaseManifestChangeError({file, cut, release}) {
if (!cut || !release)
- return `release sync cannot read manifest history: ${file}`;
+ return `release merge-back cannot read manifest history: ${file}`;
const releaseFromCut = structuredClone(cut);
releaseFromCut.version = release.version;
for (const field of VERSION_DEPENDENCY_FIELDS) {
@@ -539,7 +559,7 @@ function releaseManifestChangeError({file, cut, release}) {
: `published manifest contains a non-version release change: ${file}`;
}
-function validateReleaseSync({
+function validateReleaseMergeBack({
entries,
plan,
baseChangesets,
@@ -555,7 +575,15 @@ function validateReleaseSync({
headManifests = new Map(),
}) {
const errors = [];
- const planned = new Set(plan.changesets.map(entry => entry.path));
+ const planned = new Map(
+ plan.changesets.map(entry => [entry.path, entry.sha256]),
+ );
+ const releaseManifestPaths = new Set(releaseManifests.keys());
+ const releaseOutputPaths = new Set(releaseOutputs.keys());
+ const releaseRenamePaths = new Set(
+ [...releaseRenames].flatMap(rename => rename.split('\t')),
+ );
+
for (const entry of entries) {
const [status, ...files] = entry.split('\t');
const isRename = status?.startsWith('R');
@@ -565,12 +593,12 @@ function validateReleaseSync({
files.length !== expectedPaths ||
files.some(file => !file)
) {
- errors.push(`invalid sync diff entry: ${entry}`);
+ errors.push(`invalid merge-back diff entry: ${entry}`);
continue;
}
if (isRename && !releaseRenames.has(files.join('\t'))) {
errors.push(
- `release sync rename does not match published branch: ${files.join(' -> ')}`,
+ `release merge-back rename does not match published branch: ${files.join(' -> ')}`,
);
continue;
}
@@ -578,121 +606,169 @@ function validateReleaseSync({
if (file.startsWith('.changeset/')) {
if (status !== 'D' || !planned.has(file))
errors.push(
- `release sync may only delete frozen Changesets: ${file}`,
+ `release merge-back may only delete frozen Changesets: ${file}`,
);
} else if (isPackageManifestPath(file)) {
- if (!baseManifests.has(file))
+ if (!releaseManifestPaths.has(file))
errors.push(
- `release sync changed an unknown package manifest: ${file}`,
+ `release merge-back changed a manifest not changed on the published branch: ${file}`,
);
- } else if (
- !isReleaseOutputPath(file) &&
- !/^\.github\/pages\/assets\/(?:manifest\.json|reset\.css|astryx\.css|theme\.css)$/.test(
- file,
- )
- ) {
- errors.push(`release sync contains a non-bookkeeping path: ${file}`);
+ } else if (isReleaseOutputPath(file)) {
+ if (!releaseOutputPaths.has(file) && !releaseRenamePaths.has(file))
+ errors.push(
+ `release merge-back changed an output not changed on the published branch: ${file}`,
+ );
+ } else {
+ errors.push(`release merge-back contains a non-release path: ${file}`);
}
}
}
- for (const file of planned) {
- if (baseChangesets.has(file) && headChangesets.has(file))
- errors.push(`release sync did not delete frozen Changeset: ${file}`);
+
+ for (const [file, digest] of planned) {
+ if (baseChangesets.get(file) !== digest)
+ errors.push(
+ `release merge-back cannot verify frozen Changeset on current main: ${file}`,
+ );
+ if (headChangesets.has(file))
+ errors.push(
+ `release merge-back did not delete frozen Changeset: ${file}`,
+ );
}
for (const [file, digest] of baseChangesets) {
if (planned.has(file)) continue;
if (headChangesets.get(file) !== digest)
- errors.push(`release sync changed post-cut Changeset: ${file}`);
+ errors.push(`release merge-back changed post-cut Changeset: ${file}`);
}
for (const file of headChangesets.keys()) {
if (!baseChangesets.has(file))
errors.push(
- `release sync added a Changeset instead of preserving main: ${file}`,
+ `release merge-back added a Changeset instead of preserving main: ${file}`,
);
}
for (const [file, digest] of releaseOutputs) {
if (headOutputs.get(file) !== digest)
- errors.push(`release sync output differs from published branch: ${file}`);
- }
- for (const [file, release] of releaseManifests) {
- const error = releaseManifestChangeError({
- file,
- cut: cutManifests.get(file),
- release,
- });
- if (error) errors.push(error);
+ errors.push(
+ `release merge-back output differs from published branch: ${file}`,
+ );
}
- // FR50: every main manifest moves to one synced version, never backward.
- const mainVersions = new Set(
+ const baseVersions = new Set(
[...baseManifests.values()]
.filter(manifest => manifest && fixedNames.has(manifest.name))
.map(manifest => manifest.version),
);
- if (mainVersions.size !== 1) {
- errors.push(
- `release sync needs one fixed-group version on main; found ${[...mainVersions].join(', ') || 'none'}`,
- );
- return errors;
- }
- const [mainVersion] = mainVersions;
- const version = syncedMainVersion(mainVersion, releaseVersion);
- if (version === null) {
+ const mainVersion = baseVersions.size === 1 ? [...baseVersions][0] : null;
+ if (
+ mainVersion === null ||
+ compareVersions(mainVersion, releaseVersion) === null ||
+ compareVersions(mainVersion, releaseVersion) < 0
+ )
errors.push(
- `release sync cannot order main ${mainVersion} after release ${releaseVersion}`,
+ `release merge-back requires current main at or above published v${releaseVersion}; found ${[...baseVersions].sort().join(', ') || 'none'}`,
);
- return errors;
- }
- for (const [file, base] of baseManifests) {
- if (!base) continue;
- const head = headManifests.get(file);
- if (!head) {
- errors.push(`release sync removed a package manifest: ${file}`);
+
+ for (const [file, release] of releaseManifests) {
+ const cut = cutManifests.get(file);
+ const error = releaseManifestChangeError({file, cut, release});
+ if (error) {
+ errors.push(error);
continue;
}
- const expected = syncedManifest(base, {version, fixedNames});
- if (canonicalJson(head) === canonicalJson(expected)) continue;
- if (
- fixedNames.has(base.name) &&
- compareVersions(head.version, base.version) < 0
- )
+ const expected = mergedReleaseManifest(
+ baseManifests.get(file),
+ cut,
+ release,
+ {mainVersion, fixedNames},
+ );
+ const head = headManifests.get(file);
+ if (!expected || !head) {
+ errors.push(`release merge-back cannot read manifest history: ${file}`);
+ } else if (canonicalJson(head) !== canonicalJson(expected)) {
errors.push(
- `release sync moves main backward: ${file} ${base.version} -> ${head.version}`,
+ `release merge-back manifest differs from the published branch delta: ${file}`,
);
- else if (head.version !== expected.version)
+ }
+ }
+ for (const [file, base] of baseManifests) {
+ if (releaseManifestPaths.has(file)) continue;
+ const head = headManifests.get(file);
+ if (!head)
+ errors.push(`release merge-back removed a package manifest: ${file}`);
+ else if (canonicalJson(head) !== canonicalJson(base))
errors.push(
- `release sync manifest has the wrong version: ${file} is ${head.version}, expected ${expected.version}`,
+ `release merge-back changed a current-main manifest outside the published branch: ${file}`,
);
- else
- errors.push(`release sync changed non-version manifest fields: ${file}`);
+ }
+
+ const headVersions = new Set(
+ [...headManifests.values()]
+ .filter(manifest => manifest && fixedNames.has(manifest.name))
+ .map(manifest => manifest.version),
+ );
+ if (
+ mainVersion === null ||
+ headVersions.size !== 1 ||
+ [...headVersions][0] !== mainVersion
+ )
+ errors.push(
+ `release merge-back must preserve main's declaration ${mainVersion ?? 'unknown'}; found ${[...headVersions].sort().join(', ') || 'none'}`,
+ );
+ if (mainVersion) {
+ for (const manifest of headManifests.values()) {
+ if (!manifest) continue;
+ for (const field of VERSION_DEPENDENCY_FIELDS) {
+ for (const [name, spec] of Object.entries(manifest[field] ?? {})) {
+ if (
+ fixedNames.has(name) &&
+ EXACT_SPEC_RE.test(spec) &&
+ spec !== mainVersion
+ )
+ errors.push(
+ `release merge-back changed ${manifest.name} ${field}.${name} to ${spec}; expected preserved main declaration ${mainVersion}`,
+ );
+ }
+ }
+ }
}
return errors;
}
/**
- * FR46 — main's fixed-group version on a pull request into main.
+ * FR46/FR51 — main's fixed-group version on a pull request into main.
*
* Main carries a malleable plan until cut. It may move up or down, but always
- * remains one plain version strictly above the newest stable release.
+ * remains one plain version strictly above the newest stable release. When the
+ * base still equals that release after merge-back, the first plan may only be
+ * its patch successor (default) or its owner-named minor successor.
*
* @param {object} input
* @param {string[]} input.fixed trusted fixed-group package names
* @param {string} input.releasedVersion newest stable vX.Y.Z tag, without v
+ * @param {string|null} [input.activeCutVersion] single active untagged/ongoing cut
+ * @param {Map<string, object|null>} input.baseManifests name -> manifest at base
* @param {Map<string, object|null>} input.headManifests name -> manifest at head
- * @param {boolean} [input.allowBootstrapEqual] one-time landing bridge when trusted main predates this validator
* @returns {string[]}
*/
function validateMainVersions({
fixed,
releasedVersion,
+ activeCutVersion = null,
+ baseManifests = new Map(),
headManifests,
- allowBootstrapEqual = false,
}) {
const errors = [];
if (!VERSION_RE.test(releasedVersion ?? ''))
errors.push('main version check needs the newest stable vX.Y.Z tag');
const headVersions = new Set();
+ const baseVersions = new Set();
for (const name of fixed) {
+ const base = baseManifests.get(name);
+ if (
+ base &&
+ isStableReleasePackage(base) &&
+ VERSION_RE.test(base.version ?? '')
+ )
+ baseVersions.add(base.version);
const head = headManifests.get(name);
if (!head || !isStableReleasePackage(head)) continue;
if (!VERSION_RE.test(head.version ?? '')) {
@@ -711,13 +787,82 @@ function validateMainVersions({
const order = VERSION_RE.test(releasedVersion ?? '')
? compareVersions(declaredVersion, releasedVersion)
: null;
- if (order < 0 || (order === 0 && !allowBootstrapEqual))
+ if (order === null || order <= 0)
errors.push(
`main declares ${declaredVersion}; it must stay strictly above newest stable v${releasedVersion}`,
);
+ if (
+ activeCutVersion !== null &&
+ compareVersions(declaredVersion, activeCutVersion) < 0
+ )
+ errors.push(
+ `main declares ${declaredVersion}; it must not fall below active cut v${activeCutVersion}`,
+ );
+ if (
+ order > 0 &&
+ baseVersions.size === 1 &&
+ [...baseVersions][0] === releasedVersion &&
+ nextPlannedVersion(releasedVersion, declaredVersion) === null
+ )
+ errors.push(
+ `main's first plan after v${releasedVersion} must be patch successor ${patchSuccessor(releasedVersion)} by default or owner-named minor ${minorSuccessor(releasedVersion)}; found ${declaredVersion}`,
+ );
+ const fixedNames = new Set(fixed);
+ for (const manifest of headManifests.values()) {
+ if (!manifest) continue;
+ for (const field of VERSION_DEPENDENCY_FIELDS) {
+ for (const [name, spec] of Object.entries(manifest[field] ?? {})) {
+ if (
+ fixedNames.has(name) &&
+ EXACT_SPEC_RE.test(spec) &&
+ spec !== declaredVersion
+ )
+ errors.push(
+ `${manifest.name} ${field}.${name} pins ${spec}; main declares ${declaredVersion}`,
+ );
+ }
+ }
+ }
return errors;
}
+function canaryEligibility({fixed, releasedVersion, manifests}) {
+ const versions = new Set(
+ [...manifests.values()]
+ .filter(
+ manifest =>
+ fixed.has(manifest.name) && isStableReleasePackage(manifest),
+ )
+ .map(manifest => manifest.version),
+ );
+ if (versions.size !== 1 || !VERSION_RE.test([...versions][0] ?? ''))
+ return {
+ errors: [
+ `canary needs one plain fixed-group version; found ${[...versions].sort().join(', ') || 'none'}`,
+ ],
+ publish: false,
+ declaredVersion: null,
+ releasedVersion,
+ };
+ const [declaredVersion] = versions;
+ const order = compareVersions(declaredVersion, releasedVersion);
+ if (order === null || order < 0)
+ return {
+ errors: [
+ `canary declaration ${declaredVersion} is below newest stable v${releasedVersion}`,
+ ],
+ publish: false,
+ declaredVersion,
+ releasedVersion,
+ };
+ return {
+ errors: [],
+ publish: order > 0,
+ declaredVersion,
+ releasedVersion,
+ };
+}
+
function packageManifestsByName(read, root) {
const manifests = new Map();
for (const dir of expandWorkspaceDirs(root)) {
@@ -923,26 +1068,79 @@ async function main() {
);
return;
}
+ if (command === 'next-plan-version') {
+ const releaseVersion = required(values, 'released-version');
+ const ownerVersion = values['owner-version'] ?? null;
+ const version = nextPlannedVersion(releaseVersion, ownerVersion);
+ if (version === null)
+ throw new Error(
+ `next plan after v${releaseVersion} must be patch successor ${patchSuccessor(releaseVersion)} or owner-named minor ${minorSuccessor(releaseVersion)}`,
+ );
+ console.log(version);
+ return;
+ }
+ if (command === 'canary-eligibility') {
+ const config = readJson(path.join(root, '.changeset/config.json'));
+ const fixed = new Set((config.fixed ?? []).flat());
+ const manifests = packageManifestsByName(file => {
+ const absolute = path.join(root, file);
+ return fs.existsSync(absolute) ? readJson(absolute) : null;
+ }, root);
+ const releasedVersion = latestStableVersion(root);
+ const receipt = canaryEligibility({fixed, releasedVersion, manifests});
+ if (receipt.errors.length) throw new Error(receipt.errors.join('\n'));
+ if (process.env.GITHUB_OUTPUT)
+ fs.appendFileSync(
+ process.env.GITHUB_OUTPUT,
+ `publish=${receipt.publish}\ndeclared-version=${receipt.declaredVersion}\nreleased-version=${releasedVersion}\n`,
+ );
+ console.log(
+ JSON.stringify({
+ declaredVersion: receipt.declaredVersion,
+ releasedVersion,
+ publish: receipt.publish,
+ }),
+ );
+ return;
+ }
if (command === 'validate-main-version') {
const base = required(values, 'base');
const config = jsonAtRef(root, base, '.changeset/config.json');
if (!config)
throw new Error(`cannot read trusted fixed group from ${base}`);
const releasedVersion = latestStableVersion(root);
- const errors = validateMainVersions({
- fixed: (config.fixed ?? []).flat(),
- releasedVersion,
- allowBootstrapEqual: values['allow-bootstrap-equal'] === 'true',
- headManifests: packageManifestsByName(file => {
- const absolute = path.join(root, file);
- return fs.existsSync(absolute) ? readJson(absolute) : null;
- }, root),
- });
+ const activeBranches = listActiveBranches(root);
+ const activeCutVersion =
+ activeBranches.length === 1
+ ? markerAtRef(root, `origin/${activeBranches[0]}`).version
+ : null;
+ const errors = [];
+ if (activeBranches.length > 1)
+ errors.push(
+ `main version check requires at most one active cut; found ${activeBranches.join(', ')}`,
+ );
+ errors.push(
+ ...validateMainVersions({
+ fixed: (config.fixed ?? []).flat(),
+ releasedVersion,
+ activeCutVersion,
+ baseManifests: packageManifestsByName(
+ file => jsonAtRef(root, base, file),
+ root,
+ ),
+ headManifests: packageManifestsByName(file => {
+ const absolute = path.join(root, file);
+ return fs.existsSync(absolute) ? readJson(absolute) : null;
+ }, root),
+ }),
+ );
if (errors.length) throw new Error(errors.join('\n'));
- console.log(JSON.stringify({base, releasedVersion, valid: true}));
+ console.log(
+ JSON.stringify({base, releasedVersion, activeCutVersion, valid: true}),
+ );
return;
}
- if (command === 'validate-sync') {
+ if (command === 'validate-merge-back') {
const base = required(values, 'base');
const releaseRef = required(values, 'release-ref');
const marker = markerAtRef(root, releaseRef);
@@ -951,7 +1149,7 @@ async function main() {
);
const errors = validateIdentity(marker, plan);
if (releaseRef !== `v${marker.version}`)
- errors.push('release sync must use the immutable version tag');
+ errors.push('release merge-back must use the immutable version tag');
const releaseHead = git(root, ['rev-parse', releaseRef]);
const branchHead = git(root, ['rev-parse', `origin/${marker.branch}`]);
if (releaseHead !== branchHead)
@@ -961,7 +1159,9 @@ async function main() {
.filter(Boolean)
.sort();
if (activeBranches.length !== 1 || activeBranches[0] !== marker.branch)
- errors.push('release sync requires exactly the marked active branch');
+ errors.push(
+ 'release merge-back requires exactly the marked active branch',
+ );
const raw = git(root, [
'diff',
'--name-status',
@@ -1002,8 +1202,8 @@ async function main() {
releaseRef,
releaseManifestFiles,
);
- // FR50 covers every package manifest on main, not only those the release
- // bump touched: sync advances main's declared version everywhere.
+ // FR50 validates every current-main manifest so the release branch delta
+ // cannot overwrite post-cut main fields or decide the next version.
const mainManifestFiles = git(root, [
'ls-tree',
'-r',
@@ -1017,7 +1217,7 @@ async function main() {
const baseManifests = manifestMapAtRef(root, base, mainManifestFiles);
const baseConfig = jsonAtRef(root, base, '.changeset/config.json');
errors.push(
- ...validateReleaseSync({
+ ...validateReleaseMergeBack({
entries: raw ? raw.split('\n') : [],
plan,
baseChangesets: changesetMapAtRef(root, base),
@@ -1050,7 +1250,7 @@ async function main() {
}
if (command !== 'validate')
throw new Error(
- 'command must be create, refresh, list-active, inspect-ref, validate-diff, validate-main-version, validate-sync, or validate',
+ 'command must be create, refresh, list-active, inspect-ref, validate-diff, next-plan-version, canary-eligibility, validate-main-version, validate-merge-back, or validate',
);
const marker = readJson(path.join(root, RELEASE_DIR, MARKER_FILE));
@@ -1103,11 +1303,12 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
export {
buildMarker,
buildPlan,
+ canaryEligibility,
canonicalJson,
compareVersions,
computePlanDigest,
declaredVersionAtRef,
- syncedMainVersion,
+ nextPlannedVersion,
isStableReleasePackage,
latestStableVersion,
listActiveBranches,
@@ -1116,7 +1317,7 @@ export {
validateRefMarker,
validateReleaseDiff,
validateReleaseState,
- validateReleaseSync,
+ validateReleaseMergeBack,
versionTagExists,
writeAuthority,
};
diff --git a/scripts/release/active-release.test.mjs b/scripts/release/active-release.test.mjs
index b99040ec40..41e4aaacda 100644
--- a/scripts/release/active-release.test.mjs
+++ b/scripts/release/active-release.test.mjs
@@ -16,13 +16,14 @@ import {afterEach, describe, expect, it} from 'vitest';
import {
buildMarker,
buildPlan,
+ canaryEligibility,
declaredVersionAtRef,
latestStableVersion,
- syncedMainVersion,
+ nextPlannedVersion,
validateMainVersions,
validateReleaseDiff,
+ validateReleaseMergeBack,
validateReleaseState,
- validateReleaseSync,
writeAuthority,
} from './active-release.mjs';
@@ -425,7 +426,7 @@ describe('active release branch authority', () => {
});
});
-describe('post-release bookkeeping sync (FR50)', () => {
+describe('published release merge-back (FR50)', () => {
const digest = value => value.repeat(64).slice(0, 64);
const corePath = 'packages/core/package.json';
const themePath = 'packages/themes/neutral/package.json';
@@ -458,21 +459,12 @@ describe('post-release bookkeeping sync (FR50)', () => {
[labPath, lab(labPin)],
]);
const plan = {
- changesets: [
- {path: '.changeset/frozen.md', sha256: digest('a')},
- {path: '.changeset/already-consumed.md', sha256: digest('b')},
- ],
+ changesets: [{path: '.changeset/frozen.md', sha256: digest('a')}],
};
- function sync({release = '0.7.0', base, head, ...overrides}) {
- return validateReleaseSync({
- entries: [
- 'D\t.changeset/frozen.md',
- `M\t${corePath}`,
- `M\t${themePath}`,
- `M\t${labPath}`,
- 'M\tpackages/core/CHANGELOG.md',
- ],
+ function mergeBack({release = '0.7.0', base, head, ...overrides}) {
+ return validateReleaseMergeBack({
+ entries: ['D\t.changeset/frozen.md', 'M\tpackages/core/CHANGELOG.md'],
plan,
baseChangesets: new Map([
['.changeset/frozen.md', digest('a')],
@@ -483,77 +475,80 @@ describe('post-release bookkeeping sync (FR50)', () => {
headOutputs: new Map([['packages/core/CHANGELOG.md', digest('e')]]),
releaseVersion: release,
fixedNames,
+ cutManifests: new Map(),
+ releaseManifests: new Map(),
baseManifests: base,
headManifests: head,
...overrides,
});
}
- it('advances main from the released version to its patch successor', () => {
- expect(sync({base: mainAt('0.7.0'), head: mainAt('0.7.1')})).toEqual([]);
- });
-
- it('rejects a sync that leaves main declaring the published version', () => {
- expect(sync({base: mainAt('0.7.0'), head: mainAt('0.7.0')})).toContain(
- `release sync manifest has the wrong version: ${corePath} is 0.7.0, expected 0.7.1`,
+ it('returns exact published outputs while leaving main at the released version', () => {
+ expect(mergeBack({base: mainAt('0.7.0'), head: mainAt('0.7.0')})).toEqual(
+ [],
);
});
- it("preserves an owner's higher bump and refuses to roll it back", () => {
- // Main was bumped to plan 0.8.0 while 0.7.0 was releasing.
- expect(sync({base: mainAt('0.8.0'), head: mainAt('0.8.0')})).toEqual([]);
- expect(sync({base: mainAt('0.8.0'), head: mainAt('0.7.1')})).toEqual(
+ it('rejects folding the next plan into merge-back', () => {
+ expect(
+ mergeBack({base: mainAt('0.7.0'), head: mainAt('0.7.1'), entries: []}),
+ ).toEqual(
expect.arrayContaining([
- `release sync moves main backward: ${corePath} 0.8.0 -> 0.7.1`,
- `release sync moves main backward: ${themePath} 0.8.0 -> 0.7.1`,
+ `release merge-back changed a current-main manifest outside the published branch: ${corePath}`,
+ "release merge-back must preserve main's declaration 0.7.0; found 0.7.1",
]),
);
- expect(sync({base: mainAt('0.8.0'), head: mainAt('0.7.0')})).toContain(
- `release sync moves main backward: ${corePath} 0.8.0 -> 0.7.0`,
- );
- });
-
- it('keeps an owner bump that is exactly the patch successor', () => {
- expect(sync({base: mainAt('0.7.1'), head: mainAt('0.7.1')})).toEqual([]);
});
- it('raises a main that is behind the release past it, never to it', () => {
+ it('preserves a newer main plan that landed before merge-back', () => {
expect(
- sync({release: '0.6.7', base: mainAt('0.6.6'), head: mainAt('0.6.8')}),
+ mergeBack({base: mainAt('0.7.1'), head: mainAt('0.7.1'), entries: []}),
).toEqual([]);
+ });
+
+ it('rejects resetting a newer main plan to the released version', () => {
expect(
- sync({release: '0.6.7', base: mainAt('0.6.6'), head: mainAt('0.6.7')}),
- ).toContain(
- `release sync manifest has the wrong version: ${corePath} is 0.6.7, expected 0.6.8`,
+ mergeBack({base: mainAt('0.7.1'), head: mainAt('0.7.0'), entries: []}),
+ ).toEqual(
+ expect.arrayContaining([
+ `release merge-back changed a current-main manifest outside the published branch: ${corePath}`,
+ "release merge-back must preserve main's declaration 0.7.1; found 0.7.0",
+ ]),
);
});
- it('repins exact internal pins everywhere and leaves private versions alone', () => {
- const head = mainAt('0.7.1');
- expect(head.get(labPath).version).toBe('0.1.9');
- expect(sync({base: mainAt('0.7.0'), head})).toEqual([]);
+ it('rejects a main declaration below the published release', () => {
expect(
- sync({base: mainAt('0.7.0'), head: mainAt('0.7.1', '0.7.0')}),
- ).toContain(`release sync changed non-version manifest fields: ${labPath}`);
+ mergeBack({base: mainAt('0.6.9'), head: mainAt('0.6.9'), entries: []}),
+ ).toContain(
+ 'release merge-back requires current main at or above published v0.7.0; found 0.6.9',
+ );
});
- it('is idempotent once main is synced', () => {
+ it('preserves a newer main declaration while applying a published manifest delta', () => {
+ const base = mainAt('0.7.1');
+ base.set(themePath, {...theme('0.7.1'), scripts: {test: 'post-cut'}});
+ const head = structuredClone(base);
expect(
- sync({
- entries: [],
- baseChangesets: new Map([['.changeset/post-cut.md', digest('c')]]),
- base: mainAt('0.7.1'),
- head: mainAt('0.7.1'),
+ mergeBack({
+ base,
+ head,
+ entries: [
+ 'D\t.changeset/frozen.md',
+ `M\t${themePath}`,
+ 'M\tpackages/core/CHANGELOG.md',
+ ],
+ cutManifests: new Map([[themePath, theme('0.6.9')]]),
+ releaseManifests: new Map([[themePath, theme('0.7.0')]]),
}),
).toEqual([]);
});
it('accepts only published release-output renames', () => {
const from = 'packages/cli/assets/codemods/transforms/next/transform.mjs';
- const to = 'packages/cli/assets/codemods/transforms/v0.6.6/transform.mjs';
+ const to = 'packages/cli/assets/codemods/transforms/v0.7.0/transform.mjs';
const entries = [
'D\t.changeset/frozen.md',
- `M\t${corePath}`,
'M\tpackages/core/CHANGELOG.md',
`R100\t${from}\t${to}`,
];
@@ -564,46 +559,54 @@ describe('post-release bookkeeping sync (FR50)', () => {
const headOutputs = new Map(releaseOutputs);
expect(
- sync({
+ mergeBack({
entries,
releaseOutputs,
headOutputs,
releaseRenames: new Set([`${from}\t${to}`]),
base: mainAt('0.7.0'),
- head: mainAt('0.7.1'),
+ head: mainAt('0.7.0'),
}),
).toEqual([]);
expect(
- sync({
+ mergeBack({
entries,
releaseOutputs,
headOutputs,
base: mainAt('0.7.0'),
- head: mainAt('0.7.1'),
+ head: mainAt('0.7.0'),
}),
).toContain(
- `release sync rename does not match published branch: ${from} -> ${to}`,
+ `release merge-back rename does not match published branch: ${from} -> ${to}`,
);
});
- it('rejects any other manifest change, including wholesale tag copies', () => {
- const head = mainAt('0.7.1');
- head.set(corePath, {...core('0.7.1'), scripts: {build: 'changed'}});
- expect(sync({base: mainAt('0.7.0'), head})).toContain(
- `release sync changed non-version manifest fields: ${corePath}`,
- );
- const copied = mainAt('0.7.1');
- copied.set(corePath, {...core('0.7.1'), files: ['dist']});
- expect(sync({base: mainAt('0.7.0'), head: copied})).toContain(
- `release sync changed non-version manifest fields: ${corePath}`,
+ it('rejects unlisted manifests, lifecycle files, and non-release paths', () => {
+ expect(
+ mergeBack({
+ base: mainAt('0.7.0'),
+ head: mainAt('0.7.0'),
+ entries: [
+ `M\t${corePath}`,
+ 'M\t.release/active.json',
+ 'M\tpackages/core/src/Button/Button.tsx',
+ ],
+ }),
+ ).toEqual(
+ expect.arrayContaining([
+ `release merge-back changed a manifest not changed on the published branch: ${corePath}`,
+ 'release merge-back contains a non-release path: .release/active.json',
+ 'release merge-back contains a non-release path: packages/core/src/Button/Button.tsx',
+ ]),
);
});
- it('rejects a release bump that changed more than versions and pins', () => {
+ it('rejects a published manifest with non-version release changes', () => {
expect(
- sync({
+ mergeBack({
base: mainAt('0.7.0'),
- head: mainAt('0.7.1'),
+ head: mainAt('0.7.0'),
+ entries: [`M\t${corePath}`],
cutManifests: new Map([[corePath, core('0.7.0')]]),
releaseManifests: new Map([
[corePath, {...core('0.7.0'), sideEffects: false}],
@@ -614,31 +617,32 @@ describe('post-release bookkeeping sync (FR50)', () => {
);
});
- it('rejects changes to post-cut Changesets and non-bookkeeping paths', () => {
+ it('rejects changed post-cut Changesets and missing frozen bytes', () => {
expect(
- sync({
+ mergeBack({
base: mainAt('0.7.0'),
- head: mainAt('0.7.1'),
- entries: [
- 'M\t.changeset/post-cut.md',
- 'M\tpackages/core/src/Button/Button.tsx',
- ],
+ head: mainAt('0.7.0'),
+ entries: ['M\t.changeset/post-cut.md'],
+ baseChangesets: new Map([
+ ['.changeset/frozen.md', digest('z')],
+ ['.changeset/post-cut.md', digest('c')],
+ ]),
headChangesets: new Map([['.changeset/post-cut.md', digest('f')]]),
}),
).toEqual(
expect.arrayContaining([
- 'release sync may only delete frozen Changesets: .changeset/post-cut.md',
- 'release sync contains a non-bookkeeping path: packages/core/src/Button/Button.tsx',
- 'release sync changed post-cut Changeset: .changeset/post-cut.md',
+ 'release merge-back may only delete frozen Changesets: .changeset/post-cut.md',
+ 'release merge-back cannot verify frozen Changeset on current main: .changeset/frozen.md',
+ 'release merge-back changed post-cut Changeset: .changeset/post-cut.md',
]),
);
});
it('rejects missing frozen deletions and exact-output drift', () => {
expect(
- sync({
+ mergeBack({
base: mainAt('0.7.0'),
- head: mainAt('0.7.1'),
+ head: mainAt('0.7.0'),
headChangesets: new Map([
['.changeset/frozen.md', digest('a')],
['.changeset/post-cut.md', digest('c')],
@@ -647,17 +651,61 @@ describe('post-release bookkeeping sync (FR50)', () => {
}),
).toEqual(
expect.arrayContaining([
- 'release sync did not delete frozen Changeset: .changeset/frozen.md',
- 'release sync output differs from published branch: packages/core/CHANGELOG.md',
+ 'release merge-back did not delete frozen Changeset: .changeset/frozen.md',
+ 'release merge-back output differs from published branch: packages/core/CHANGELOG.md',
]),
);
});
- it('computes the synced version as max(main, released patch successor)', () => {
- expect(syncedMainVersion('0.7.0', '0.7.0')).toBe('0.7.1');
- expect(syncedMainVersion('0.8.0', '0.7.0')).toBe('0.8.0');
- expect(syncedMainVersion('0.6.6', '0.6.7')).toBe('0.6.8');
- expect(syncedMainVersion('0.7.0-canary.1', '0.7.0')).toBeNull();
+ it('defaults the separate next plan to patch and admits only an explicit minor', () => {
+ expect(nextPlannedVersion('0.7.0')).toBe('0.7.1');
+ expect(nextPlannedVersion('0.7.0', '0.7.1')).toBe('0.7.1');
+ expect(nextPlannedVersion('0.7.0', '0.8.0')).toBe('0.8.0');
+ expect(nextPlannedVersion('0.7.0', '0.7.2')).toBeNull();
+ expect(nextPlannedVersion('0.7.0-canary.1')).toBeNull();
+ });
+});
+
+describe('canary eligibility during release merge-back (FR46)', () => {
+ const fixed = new Set(['@astryxdesign/core', '@astryxdesign/cli']);
+ const at = (core, cli = core) =>
+ new Map([
+ ['@astryxdesign/core', {name: '@astryxdesign/core', version: core}],
+ ['@astryxdesign/cli', {name: '@astryxdesign/cli', version: cli}],
+ ]);
+
+ it('publishes above stable and suppresses the transient equal state', () => {
+ expect(
+ canaryEligibility({
+ fixed,
+ releasedVersion: '0.6.8',
+ manifests: at('0.6.9'),
+ }),
+ ).toMatchObject({errors: [], publish: true, declaredVersion: '0.6.9'});
+ expect(
+ canaryEligibility({
+ fixed,
+ releasedVersion: '0.6.8',
+ manifests: at('0.6.8'),
+ }),
+ ).toMatchObject({errors: [], publish: false, declaredVersion: '0.6.8'});
+ });
+
+ it('refuses a lower or split declaration instead of silently skipping', () => {
+ expect(
+ canaryEligibility({
+ fixed,
+ releasedVersion: '0.6.8',
+ manifests: at('0.6.7'),
+ }).errors,
+ ).toContain('canary declaration 0.6.7 is below newest stable v0.6.8');
+ expect(
+ canaryEligibility({
+ fixed,
+ releasedVersion: '0.6.8',
+ manifests: at('0.6.8', '0.6.9'),
+ }).errors[0],
+ ).toMatch(/canary needs one plain fixed-group version/);
});
});
@@ -683,12 +731,12 @@ describe('main pull requests keep the declared version above newest stable (FR46
base,
head,
releasedVersion = '0.6.7',
- allowBootstrapEqual = false,
+ activeCutVersion = null,
) =>
validateMainVersions({
fixed,
releasedVersion,
- allowBootstrapEqual,
+ activeCutVersion,
baseManifests: base,
headManifests: head,
});
@@ -698,10 +746,35 @@ describe('main pull requests keep the declared version above newest stable (FR46
expect(check(at('0.6.8'), at('0.7.0'))).toEqual([]);
});
- it('allows only the one-time equal-version bootstrap while the validator lands', () => {
- expect(check(at('0.6.7'), at('0.6.7'), '0.6.7', true)).toEqual([]);
- expect(check(at('0.6.7'), at('0.6.6'), '0.6.7', true)).toContain(
- 'main declares 0.6.6; it must stay strictly above newest stable v0.6.7',
+ it('allows equality with an untagged active cut but refuses lowering below it', () => {
+ expect(check(at('0.6.8'), at('0.6.8'), '0.6.7', '0.6.8')).toEqual([]);
+ expect(check(at('0.6.8'), at('0.6.9'), '0.6.7', '0.6.8')).toEqual([]);
+ expect(check(at('0.6.8'), at('0.6.7'), '0.6.6', '0.6.8')).toContain(
+ 'main declares 0.6.7; it must not fall below active cut v0.6.8',
+ );
+ expect(check(at('0.6.8'), at('0.6.8'), '0.6.8', '0.6.8')).toContain(
+ 'main declares 0.6.8; it must stay strictly above newest stable v0.6.8',
+ );
+ });
+
+ it('admits only patch or minor successor as the first plan after merge-back', () => {
+ expect(check(at('0.6.7'), at('0.6.8'))).toEqual([]);
+ expect(check(at('0.6.7'), at('0.7.0'))).toEqual([]);
+ expect(check(at('0.6.7'), at('0.6.9'))).toContain(
+ "main's first plan after v0.6.7 must be patch successor 0.6.8 by default or owner-named minor 0.7.0; found 0.6.9",
+ );
+ });
+
+ it('requires every exact internal pin to follow the separate next plan', () => {
+ const head = at('0.6.8');
+ head.set('@astryxdesign/lab', {
+ name: '@astryxdesign/lab',
+ version: '0.1.9',
+ private: true,
+ peerDependencies: {'@astryxdesign/core': '0.6.7'},
+ });
+ expect(check(at('0.6.7'), head)).toContain(
+ '@astryxdesign/lab peerDependencies.@astryxdesign/core pins 0.6.7; main declares 0.6.8',
);
});