Skip to content

Commit 5275d89

Browse files
authored
fix(ci): route validated release syncs around Changeset coverage (#7258)
* fix(ci): route release syncs around Changeset coverage * fix(ci): validate release syncs in required lint
1 parent 4447ae7 commit 5275d89

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

‎.github/scripts/release-publish-workflow.test.mjs‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const workflow = yaml.parse(
1212
const ci = yaml.parse(
1313
fs.readFileSync(path.join(ROOT, '.github/workflows/ci.yml'), 'utf8'),
1414
);
15+
const lint = yaml.parse(
16+
fs.readFileSync(path.join(ROOT, '.github/workflows/lint.yml'), 'utf8'),
17+
);
1518
const stable = workflow.jobs.publish;
1619
const canary = workflow.jobs.canary;
1720
const step = (job, name) =>
@@ -101,6 +104,34 @@ describe('stable and canary publication authority', () => {
101104
).run;
102105
expect(scope).toContain('chore/sync-v*-to-main');
103106
expect(scope).toContain('stable package-version change on main');
107+
108+
const lintScope = step(
109+
lint.jobs.lint,
110+
'Detect the release-sync branch contract',
111+
).run;
112+
expect(lintScope).toContain('chore/sync-v*-to-main');
113+
expect(lintScope).toContain("grep -Eq '^[0-9]+\\.[0-9]+\\.[0-9]+$'");
114+
expect(step(lint.jobs.lint, 'Check Changeset coverage').if).toBe(
115+
"github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required != 'true'",
116+
);
117+
const requiredLintValidation = step(
118+
lint.jobs.lint,
119+
'Validate release sync in required lint',
120+
);
121+
expect(requiredLintValidation.if).toBe(
122+
"github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required == 'true'",
123+
);
124+
for (const command of [
125+
'git show origin/main:scripts/release/active-release.mjs',
126+
'git show origin/main:scripts/lib/workspace-globs.mjs',
127+
'validate-sync',
128+
'--base origin/main',
129+
'--release-ref "v$VERSION"',
130+
'--active-branches "$ACTIVE_BRANCHES"',
131+
]) {
132+
expect(requiredLintValidation.run).toContain(command);
133+
}
134+
104135
const validation = step(
105136
sync,
106137
'Validate published bytes and consumed-only Changeset sync',

‎.github/workflows/lint.yml‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,55 @@ jobs:
4848
>> "$GITHUB_OUTPUT"
4949
fi
5050
51+
# Release-sync PRs copy already-published generated outputs and consume the
52+
# frozen Changesets. They cannot add a new Changeset, so the required lint
53+
# context runs the trusted release-sync validator instead.
54+
- name: Detect the release-sync branch contract
55+
if: github.event_name == 'pull_request'
56+
id: release-sync-scope
57+
env:
58+
SYNC_BRANCH: ${{ github.head_ref }}
59+
run: |
60+
required=false
61+
case "$SYNC_BRANCH" in
62+
chore/sync-v*-to-main)
63+
VERSION=${SYNC_BRANCH#chore/sync-v}
64+
VERSION=${VERSION%-to-main}
65+
if printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
66+
required=true
67+
fi
68+
;;
69+
esac
70+
echo "required=$required" >> "$GITHUB_OUTPUT"
71+
72+
- name: Validate release sync in required lint
73+
if: github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required == 'true'
74+
env:
75+
SYNC_BRANCH: ${{ github.head_ref }}
76+
run: |
77+
set -eu
78+
VERSION=${SYNC_BRANCH#chore/sync-v}
79+
VERSION=${VERSION%-to-main}
80+
git fetch origin main 'refs/tags/v*:refs/tags/v*' '+refs/heads/release/v*:refs/remotes/origin/release/v*'
81+
TRUSTED_POLICY="$RUNNER_TEMP/release-policy"
82+
mkdir -p "$TRUSTED_POLICY/scripts/release" "$TRUSTED_POLICY/scripts/lib"
83+
git show origin/main:scripts/release/active-release.mjs \
84+
> "$TRUSTED_POLICY/scripts/release/active-release.mjs"
85+
git show origin/main:scripts/lib/workspace-globs.mjs \
86+
> "$TRUSTED_POLICY/scripts/lib/workspace-globs.mjs"
87+
VALIDATOR="$TRUSTED_POLICY/scripts/release/active-release.mjs"
88+
ACTIVE_BRANCHES=$(node "$VALIDATOR" list-active --root "$GITHUB_WORKSPACE")
89+
node "$VALIDATOR" validate-sync \
90+
--root "$GITHUB_WORKSPACE" \
91+
--base origin/main \
92+
--release-ref "v$VERSION" \
93+
--active-branches "$ACTIVE_BRANCHES"
94+
5195
# A change that ships to consumers names its package in a Changeset, and a
5296
# released CLI JSON id cannot disappear unclassified. The release coverage
5397
# audit runs the same classifier over the cut range, so the two agree.
5498
- name: Check Changeset coverage
55-
if: github.event_name == 'pull_request'
99+
if: github.event_name == 'pull_request' && steps.release-sync-scope.outputs.required != 'true'
56100
env:
57101
MERGE_SHA: ${{ github.sha }}
58102
run: |

0 commit comments

Comments
 (0)