Skip to content

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

TypeScript

fix(ci): route validated release syncs around Changeset coverage (#7258)

Cindy Zhang5275d894a003
diff --git a/.github/scripts/release-publish-workflow.test.mjs b/.github/scripts/release-publish-workflow.test.mjs
index 9626f95ad5..89c4f951c8 100644
--- a/.github/scripts/release-publish-workflow.test.mjs
+++ b/.github/scripts/release-publish-workflow.test.mjs
@@ -12,6 +12,9 @@ const workflow = yaml.parse(
const ci = yaml.parse(
fs.readFileSync(path.join(ROOT, '.github/workflows/ci.yml'), 'utf8'),
);
+const lint = yaml.parse(
+ fs.readFileSync(path.join(ROOT, '.github/workflows/lint.yml'), 'utf8'),
+);
const stable = workflow.jobs.publish;
const canary = workflow.jobs.canary;
const step = (job, name) =>
@@ -101,6 +104,34 @@ describe('stable and canary publication authority', () => {
).run;
expect(scope).toContain('chore/sync-v*-to-main');
expect(scope).toContain('stable package-version change on main');
+
+ const lintScope = step(
+ lint.jobs.lint,
+ 'Detect the release-sync branch contract',
+ ).run;
+ expect(lintScope).toContain('chore/sync-v*-to-main');
+ expect(lintScope).toContain("grep -Eq '^[0-9]+\\.[0-9]+\\.[0-9]+$'");
+ expect(step(lint.jobs.lint, 'Check Changeset coverage').if).toBe(
+ "github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required != 'true'",
+ );
+ const requiredLintValidation = step(
+ lint.jobs.lint,
+ 'Validate release sync in required lint',
+ );
+ expect(requiredLintValidation.if).toBe(
+ "github.event_name == 'pull_request' && steps.release-sync-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',
+ '--base origin/main',
+ '--release-ref "v$VERSION"',
+ '--active-branches "$ACTIVE_BRANCHES"',
+ ]) {
+ expect(requiredLintValidation.run).toContain(command);
+ }
+
const validation = step(
sync,
'Validate published bytes and consumed-only Changeset sync',
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 37cef30a75..911d6d0bca 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -48,11 +48,55 @@ jobs:
>> "$GITHUB_OUTPUT"
fi
+ # 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
+ env:
+ SYNC_BRANCH: ${{ github.head_ref }}
+ run: |
+ required=false
+ case "$SYNC_BRANCH" in
+ chore/sync-v*-to-main)
+ VERSION=${SYNC_BRANCH#chore/sync-v}
+ VERSION=${VERSION%-to-main}
+ if printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
+ required=true
+ fi
+ ;;
+ 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'
+ env:
+ SYNC_BRANCH: ${{ github.head_ref }}
+ run: |
+ set -eu
+ VERSION=${SYNC_BRANCH#chore/sync-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"
+ 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"
+ ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE")
+ node "$VALIDATOR" validate-sync \
+ --root "$GITHUB_WORKSPACE" \
+ --base origin/main \
+ --release-ref "v$VERSION" \
+ --active-branches "$ACTIVE_BRANCHES"
+
# A change that ships to consumers names its package in a Changeset, and a
# 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'
+ if: github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required != 'true'
env:
MERGE_SHA: ${{ github.sha }}
run: |