Skip to content

fix: fail incompatible lockfile in frozen CI mode#10978

Merged
zkochan merged 2 commits intopnpm:mainfrom
zubeyralmaho:fix/ci-incompatible-lockfile-10908
Mar 17, 2026
Merged

fix: fail incompatible lockfile in frozen CI mode#10978
zkochan merged 2 commits intopnpm:mainfrom
zubeyralmaho:fix/ci-incompatible-lockfile-10908

Conversation

@zubeyralmaho
Copy link
Copy Markdown
Contributor

@zubeyralmaho zubeyralmaho commented Mar 15, 2026

Summary

make incompatible lockfiles fail in CI when is enabled

  • keep existing CI fallback behavior for non-frozen installs
  • add tests in get-context covering both branches

Motivation

Closes #10908

Testing

  • pnpm --filter @pnpm/get-context run lint
  • note: local jest execution in this workspace currently has unrelated module/runtime issues; coverage added and CI will validate the test suite

@zubeyralmaho zubeyralmaho requested a review from zkochan as a code owner March 15, 2026 21:32
Copilot AI review requested due to automatic review settings March 15, 2026 21:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts @pnpm/get-context lockfile-reading behavior so that CI runs in frozen-lockfile mode fail fast on incompatible pnpm-lock.yaml, aligning CI behavior with the expectations of reproducible installs and addressing #10908.

Changes:

  • Make readLockfiles() stop ignoring incompatible wanted lockfiles in CI when frozenLockfile is true.
  • Add Jest coverage for both the frozen and non-frozen CI branches in readLockfiles().
  • Add a changeset documenting the behavior change for @pnpm/get-context and pnpm.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg-manager/get-context/src/readLockfiles.ts Tightens CI “ignore incompatible lockfile” logic to respect frozen-lockfile mode.
pkg-manager/get-context/test/index.ts Adds regression tests for incompatible lockfile handling in CI (frozen vs non-frozen).
.changeset/ci-frozen-incompatible-lockfile.md Declares a patch release and describes the behavioral change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +67 to +102
await fs.writeFile(path.join(lockfileDir, 'pnpm-lock.yaml'), 'lockfileVersion: 1.0\nimporters:\n .:\n specifiers: {}\n')

await expect(readLockfiles({
autoInstallPeers: true,
excludeLinksFromLockfile: false,
peersSuffixMaxLength: 1000,
ci: true,
force: false,
frozenLockfile: true,
projects: [{ id: '.' as ProjectId, rootDir: lockfileDir as ProjectRootDir }],
lockfileDir,
registry: 'https://registry.npmjs.org/',
useLockfile: true,
internalPnpmDir: path.join(lockfileDir, 'node_modules', '.pnpm'),
})).rejects.toMatchObject({ code: 'ERR_PNPM_LOCKFILE_BREAKING_CHANGE' })
})

test('readLockfiles() ignores incompatible lockfile in CI when frozenLockfile is false', async () => {
const lockfileDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pnpm-get-context-'))
await fs.writeFile(path.join(lockfileDir, 'pnpm-lock.yaml'), 'lockfileVersion: 1.0\nimporters:\n .:\n specifiers: {}\n')

const context = await readLockfiles({
autoInstallPeers: true,
excludeLinksFromLockfile: false,
peersSuffixMaxLength: 1000,
ci: true,
force: false,
frozenLockfile: false,
projects: [{ id: '.' as ProjectId, rootDir: lockfileDir as ProjectRootDir }],
lockfileDir,
registry: 'https://registry.npmjs.org/',
useLockfile: true,
internalPnpmDir: path.join(lockfileDir, 'node_modules', '.pnpm'),
})

expect(context.existsWantedLockfile).toBe(false)
Comment on lines +2 to +3
'@pnpm/get-context': patch
pnpm: patch
Comment on lines +67 to +102
await fs.writeFile(path.join(lockfileDir, 'pnpm-lock.yaml'), 'lockfileVersion: 1.0\nimporters:\n .:\n specifiers: {}\n')

await expect(readLockfiles({
autoInstallPeers: true,
excludeLinksFromLockfile: false,
peersSuffixMaxLength: 1000,
ci: true,
force: false,
frozenLockfile: true,
projects: [{ id: '.' as ProjectId, rootDir: lockfileDir as ProjectRootDir }],
lockfileDir,
registry: 'https://registry.npmjs.org/',
useLockfile: true,
internalPnpmDir: path.join(lockfileDir, 'node_modules', '.pnpm'),
})).rejects.toMatchObject({ code: 'ERR_PNPM_LOCKFILE_BREAKING_CHANGE' })
})

test('readLockfiles() ignores incompatible lockfile in CI when frozenLockfile is false', async () => {
const lockfileDir = await fs.mkdtemp(path.join(os.tmpdir(), 'pnpm-get-context-'))
await fs.writeFile(path.join(lockfileDir, 'pnpm-lock.yaml'), 'lockfileVersion: 1.0\nimporters:\n .:\n specifiers: {}\n')

const context = await readLockfiles({
autoInstallPeers: true,
excludeLinksFromLockfile: false,
peersSuffixMaxLength: 1000,
ci: true,
force: false,
frozenLockfile: false,
projects: [{ id: '.' as ProjectId, rootDir: lockfileDir as ProjectRootDir }],
lockfileDir,
registry: 'https://registry.npmjs.org/',
useLockfile: true,
internalPnpmDir: path.join(lockfileDir, 'node_modules', '.pnpm'),
})

expect(context.existsWantedLockfile).toBe(false)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@zkochan zkochan merged commit 5d130c3 into pnpm:main Mar 17, 2026
8 checks passed
zkochan added a commit that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Ignoring broken lockfile at ... pnpm-lock.yaml not compatible with current pnpm" warning should be an error when run in CI

3 participants