fix: fail incompatible lockfile in frozen CI mode#10978
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 whenfrozenLockfileistrue. - Add Jest coverage for both the frozen and non-frozen CI branches in
readLockfiles(). - Add a changeset documenting the behavior change for
@pnpm/get-contextandpnpm.
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
approved these changes
Mar 17, 2026
zkochan
added a commit
that referenced
this pull request
Mar 24, 2026
Cherry-picked from main (5d130c3).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make incompatible lockfiles fail in CI when is enabled
Motivation
Closes #10908
Testing