Skip to content

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

TypeScript

fix(ci): check:changesets fails closed when no plain minor is declared (#7361)

Cindy Zhang5b6c74784f2b
diff --git a/scripts/check-changesets.mjs b/scripts/check-changesets.mjs
index caa4206409..2a3aa681bc 100755
--- a/scripts/check-changesets.mjs
+++ b/scripts/check-changesets.mjs
@@ -97,6 +97,23 @@ function validateChangeset(file, contents, ctx) {
`${file}: [breaking] cannot merge while main declares patch ${declaredVersion}. ` +
'Plan the minor first, or keep the change compatible through deprecation.',
);
+ // Fail closed: a breaking entry is admitted only once the fixed group
+ // declares one plain x.y.0. Split versions or a prerelease declare no tier.
+ // Only a repository check carries `declaredTier`; a caller validating one
+ // entry without a declaration is not making an admission decision.
+ if (
+ pre1 &&
+ parsed.category === 'breaking' &&
+ 'declaredTier' in ctx &&
+ declaredTier == null
+ )
+ problems.push(
+ `${file}: [breaking] cannot merge until the fixed group declares one plain minor version` +
+ (declaredVersion
+ ? ` (found ${declaredVersion})`
+ : ' (the fixed packages disagree)') +
+ '. Plan the minor first, or keep the change compatible through deprecation.',
+ );
for (const [name, type] of Object.entries(fm.releases)) {
if (!allNames.has(name)) {
diff --git a/scripts/check-changesets.test.mjs b/scripts/check-changesets.test.mjs
index 4e236dbe11..6d72cb9811 100644
--- a/scripts/check-changesets.test.mjs
+++ b/scripts/check-changesets.test.mjs
@@ -204,6 +204,59 @@ describe('checkRepository — main pull requests enforce the declared tier', ()
expect(result.problems).toEqual([]);
});
+ it('refuses [breaking] when the fixed group declares a prerelease, not a plain minor', () => {
+ const root = mainCheckout('0.7.0-canary.3', {
+ 'remove-thing': cs(
+ `'@astryxdesign/core': minor`,
+ '[breaking] Remove the old thing\n@person',
+ ),
+ });
+ const result = checkRepository(root);
+ expect(result.declaredTier).toBeNull();
+ expect(result.problems).toContain(
+ 'remove-thing.md: [breaking] cannot merge until the fixed group declares one plain minor version (found 0.7.0-canary.3). ' +
+ 'Plan the minor first, or keep the change compatible through deprecation.',
+ );
+ });
+
+ it('refuses [breaking] when the fixed packages disagree on the declared version', () => {
+ const root = mainCheckout('0.7.0', {
+ 'remove-thing': cs(
+ `'@astryxdesign/core': minor`,
+ '[breaking] Remove the old thing\n@person',
+ ),
+ });
+ fs.mkdirSync(path.join(root, 'packages/cli'), {recursive: true});
+ fs.writeFileSync(
+ path.join(root, 'packages/cli/package.json'),
+ JSON.stringify({name: '@astryxdesign/cli', version: '0.6.9'}),
+ );
+ fs.writeFileSync(
+ path.join(root, '.changeset/config.json'),
+ JSON.stringify({
+ fixed: [['@astryxdesign/core', '@astryxdesign/cli']],
+ ignore: [],
+ }),
+ );
+ const result = checkRepository(root);
+ expect(result.declaredVersion).toBeNull();
+ expect(result.declaredTier).toBeNull();
+ expect(result.problems).toContain(
+ 'remove-thing.md: [breaking] cannot merge until the fixed group declares one plain minor version (the fixed packages disagree). ' +
+ 'Plan the minor first, or keep the change compatible through deprecation.',
+ );
+ });
+
+ it('still admits a non-breaking Changeset when no tier is declared', () => {
+ const root = mainCheckout('0.7.0-canary.3', {
+ 'fix-thing': cs(
+ `'@astryxdesign/core': patch`,
+ '[fix] Fix the thing\n@person',
+ ),
+ });
+ expect(checkRepository(root).problems).toEqual([]);
+ });
+
it('still refuses malformed Changesets on main', () => {
const root = mainCheckout('0.6.7', {
'no-category': cs(`'@astryxdesign/core': patch`, 'Something\n@person'),