chore: Do not allow changes to package json during CI yarn install#12125
Merged
chore: Do not allow changes to package json during CI yarn install#12125
Conversation
Running `yarn install` will format the package.json for all packages in the workspace. This will cause `cache_content_hash` to fail on CI due to changed files, which causes the build to terminate abruptly (see [here](https://github.com/AztecProtocol/aztec-packages/actions/runs/13422411604/job/37497960586?pr=12096#step:7:109) for an example). This PR adds all package.json files to yarn's `immutablePatterns`, so if it detects that the install process changed them it, it will fail with `The checksum for **/package.json has been modified by this install, which is explicitly forbidden.` and a nice exit code, which should be visible on the CI run. This only applies to CI runs.
ludamad
approved these changes
Feb 19, 2025
ludamad
reviewed
Feb 19, 2025
| # If in CI mode, retry as bcrypto can sometimes fail mysteriously. | ||
| # We set immutable since we don't expect the yarn.lock to change. Note that we have also added all package.json | ||
| # files to yarn immutablePatterns, so if they are also changed, this step will fail. | ||
| denoise "retry yarn install --immutable" |
Collaborator
There was a problem hiding this comment.
this is redundant as yarn install reacts to CI being set
Contributor
Author
There was a problem hiding this comment.
agree it's redundant, but I'd rather be explicit
spalladino
added a commit
that referenced
this pull request
Mar 6, 2025
We introduced two issues in #12125 when adding the immutable patterns to yarn install: - If `immutablePatterns` is set, yarn sets the `immutable` flag even outside CI (contradicting its documentation). This is fixed by explicitly setting `--no-immutable` on the non-CI branch of install. - The glob `**/package.json` inadvertently matched package.json files within `node_modules`, so installing them created the new files, which means they were flagged as changed. This is fixed by having a less eager glob. Fixes #12538
spalladino
added a commit
that referenced
this pull request
Mar 6, 2025
We introduced two issues in #12125 when adding the immutable patterns to yarn install: - If `immutablePatterns` is set, yarn sets the `immutable` flag even outside CI (contradicting its documentation). This is fixed by explicitly setting `--no-immutable` on the non-CI branch of install. - The glob `**/package.json` inadvertently matched package.json files within `node_modules`, so installing them created the new files, which means they were flagged as changed. This is fixed by having a less eager glob. Fixes #12538
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.
Running
yarn installwill format the package.json for all packages in the workspace. This will causecache_content_hashto fail on CI due to changed files, which (before #12124) caused the build to terminate abruptly (see here for an example).This PR adds all package.json files to yarn's
immutablePatterns, so if it detects that the install process changed them it, it will fail withThe checksum for **/package.json has been modified by this install, which is explicitly forbidden.and a nice exit code, which should be visible on the CI run. This only applies to CI runs.