ci: Force fresh sync patch validation (no-changelog) (#38929)

This commit is contained in:
Declan Carroll 2026-09-17 09:47:55 +00:00 committed by GitHub
parent 43fa826342
commit ecc822d588
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 12 deletions

View File

@ -151,9 +151,9 @@ export function resolveMechanicalPath({ git, pnpm, path, masterSha, log = consol
log(`Regenerating ${path} with pnpm...`);
pnpm(['install', '--lockfile-only', '--no-frozen-lockfile']);
try {
// A lockfile-only install does not apply patches. Validate the regenerated lockfile
// with a full install so pnpm applies patches before accepting the resolution.
pnpm(['install', '--frozen-lockfile']);
// A lockfile-only install does not apply patches. Force a full install so pnpm
// does not accept cached dependencies without applying the regenerated patches.
pnpm(['install', '--frozen-lockfile', '--force']);
} catch (error) {
git(['checkout', '--conflict=merge', '--', path]);
throw error;
@ -313,7 +313,8 @@ export function reconcileWithMergeTreeAtTip({
*/
export function reconcileLockfileAtTip({ git, pnpm, masterSha, log = console.log }) {
pnpm(['install', '--lockfile-only', '--no-frozen-lockfile']);
pnpm(['install', '--frozen-lockfile']);
// Force pnpm to reimport cached dependencies and apply the regenerated patches.
pnpm(['install', '--frozen-lockfile', '--force']);
if (attempt(git, ['diff', '--quiet', '--', LOCKFILE]).ok) return;
if (git(['rev-parse', 'HEAD']) === masterSha) {
throw new Error('Lockfile reconciliation would amend a master commit; refusing.');

View File

@ -185,10 +185,10 @@ test('resolveMechanicalPath regenerates and applies patches before staging the l
const git = makeStub();
const pnpm = makeStub();
resolveMechanicalPath({ git, pnpm, path: LOCKFILE, masterSha: MASTER, log: () => {} });
// `--no-frozen-lockfile` is load-bearing: pnpm defaults to frozen when CI=true.
// Regeneration must override CI's frozen default. Validation must bypass cached imports.
assert.deepEqual(pnpm.calls, [
['install', '--lockfile-only', '--no-frozen-lockfile'],
['install', '--frozen-lockfile'],
['install', '--frozen-lockfile', '--force'],
]);
assert.ok(git.calls.some((a) => a[0] === 'add' && a.includes(LOCKFILE)));
});
@ -421,7 +421,7 @@ test('reconcileLockfileAtTip folds an inconsistent lockfile into the tip commit,
reconcileLockfileAtTip({ git: inconsistent, pnpm, masterSha: MASTER, log: () => {} });
assert.deepEqual(pnpm.calls, [
['install', '--lockfile-only', '--no-frozen-lockfile'],
['install', '--frozen-lockfile'],
['install', '--frozen-lockfile', '--force'],
]);
assert.ok(inconsistent.calls.some((a) => a[0] === 'commit' && a.includes('--amend')));
@ -684,11 +684,11 @@ test('sync auto-resolves a lockfile-only conflict during the replay — no PR, n
await sync({ git, gh, pnpm, env, log: () => {} });
// The stall regen and the tip reconciliation each run regeneration and validation.
// The stall regen and tip reconciliation each run regeneration and forced validation.
assert.deepEqual(pnpm.calls[0], ['install', '--lockfile-only', '--no-frozen-lockfile']);
assert.deepEqual(pnpm.calls[1], ['install', '--frozen-lockfile']);
assert.deepEqual(pnpm.calls[1], ['install', '--frozen-lockfile', '--force']);
assert.deepEqual(pnpm.calls[2], ['install', '--lockfile-only', '--no-frozen-lockfile']);
assert.deepEqual(pnpm.calls[3], ['install', '--frozen-lockfile']);
assert.deepEqual(pnpm.calls[3], ['install', '--frozen-lockfile', '--force']);
assert.equal(pnpm.calls.length, 4);
assert.ok(git.calls.some((a) => a[0] === 'add' && a.includes(LOCKFILE)));
assert.ok(git.calls.some((a) => a[0] === 'rebase' && a[1] === '--continue'));
@ -838,7 +838,7 @@ test('buildConflictBranch pre-resolves mechanical files so only code conflicts r
assert.equal(lockfileDeferred, false);
assert.deepEqual(pnpm.calls, [
['install', '--lockfile-only', '--no-frozen-lockfile'],
['install', '--frozen-lockfile'],
['install', '--frozen-lockfile', '--force'],
]);
assert.ok(
git.calls.some((a) => a[0] === 'checkout' && a[1] === MASTER && a.includes(POPULARITY)),
@ -886,7 +886,7 @@ test('buildConflictBranch restores and defers a lockfile when the patched instal
assert.equal(lockfileDeferred, true);
assert.deepEqual(pnpm.calls, [
['install', '--lockfile-only', '--no-frozen-lockfile'],
['install', '--frozen-lockfile'],
['install', '--frozen-lockfile', '--force'],
]);
assert.ok(
git.calls.some(