Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/cleanup yarn lock #41847

Merged
merged 9 commits into from
May 12, 2020
Merged

Fix/cleanup yarn lock #41847

merged 9 commits into from
May 12, 2020

Conversation

scinos
Copy link
Contributor

@scinos scinos commented May 6, 2020

Changes proposed in this Pull Request

From https://app.circleci.com/pipelines/github/Automattic/wp-calypso/58032/workflows/819cbf5a-ec40-4989-a89a-c57186712b9d/jobs/715945/steps
image

Testing instructions

  1. Checkout the branch, delete yarn.lock and run yarn. Run this script in the console and verify it shows the error:
DIRTY_FILES=$(git status --porcelain 2>/dev/null)
if [[ ! -z "$DIRTY_FILES" ]]; then
  echo "Repository contains uncommitted changes: "
  echo "$DIRTY_FILES"
  echo "You may need to checkout the branch, run 'yarn' and commit those files."
fi
  1. Revert local changes to yarn.lock and run the script again, you shouldn't see any error.

@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@scinos scinos requested a review from sirreal May 6, 2020 06:45
@scinos scinos self-assigned this May 6, 2020
@scinos scinos added Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels May 6, 2020
@scinos scinos marked this pull request as ready for review May 6, 2020 06:46
@scinos scinos requested review from a team as code owners May 6, 2020 06:46
@simison
Copy link
Member

simison commented May 6, 2020

I'm still confused (only skimmed linked issues); is there no way to prevent updates in package.json that are missing from lockfile or other way around? cc @kraftbj @jeherve since I contributed Automattic/jetpack#14640

@scinos
Copy link
Contributor Author

scinos commented May 6, 2020

is there no way to prevent updates in package.json that are missing from lockfile or other way around?

As far as I know, there is no way to do that using yarn flags. There are a few examples on how to do it "externally" (check that yarn.lock has not changed) in yarnpkg/yarn#5840

I did something similar in the CI config, now at least at test will fail if yarn.lock needs to be updated for any reason, for example because it no longer matches package.json

@scinos scinos force-pushed the fix/cleanup-yarn-lock branch 2 times, most recently from 4d53313 to 9d55001 Compare May 11, 2020 06:54
@sirreal
Copy link
Member

sirreal commented May 11, 2020

Should we be removing --frozen-lockfile everywhere? It does seem like desirable behavior (if confusing):

If you need reproducible dependencies, which is usually the case with the continuous integration systems, you should pass --frozen-lockfile flag.

yarn install --frozen-lockfile
Don’t generate a yarn.lock lockfile and fail if an update is needed.

Do we have any theories on how we get into a state where the lockfile is out of date but not committed? I have a hard time imagining yarn.lock is modified locally but isn't committed.

@scinos
Copy link
Contributor Author

scinos commented May 11, 2020

IMO, the behaviour of --frozen-lockfile is broken, as it doesn't do what the doc says (build does not fail if an update of yarn.lock is needed). If we leave it around it can cause confusion and suggest the check for a dirty lockfile in CI is not needed.

My theories of why yarn.lock is not committed are:

  1. People may have it in their local .gitignore
  2. If you do cd apps/full-site-editing && npm add ..., yarn.lock is not updated at all. Although in this case you'll end up with a package-lock.json.
  3. Maybe people are adding deps to package.json manually?

@scinos
Copy link
Contributor Author

scinos commented May 11, 2020

Extracted the commit to fix yarn.lock to #42041

@simison
Copy link
Member

simison commented May 11, 2020

Incidentally, I just ended up with a change in lockfile by running yarn dev --sync in apps/full-site-editing:

image

I'd expect not to have these pop up while working.

@scinos scinos force-pushed the fix/cleanup-yarn-lock branch from 1b936b2 to 6fb03ad Compare May 11, 2020 12:40
@scinos
Copy link
Contributor Author

scinos commented May 11, 2020

@simison

Incidentally, I just ended up with a change in lockfile

In this branch? I can't reproduce it in commit 1b936b2a81 (before the rebase) or 6fb03ad5b7 (after the rebase)

@simison
Copy link
Member

simison commented May 11, 2020

In this branch?

Sorry, I didn't specify. At #41966

Actually! I might've ran yarn --sync first accidentally, instead of yarn dev --sync.

@scinos
Copy link
Contributor Author

scinos commented May 11, 2020

Sorry, I didn't specify. At #41966

I get the same diff in yarn.lock.

Looks like that branch is not updated with master. It is using a yarn.lock that is "dirty" as well :(

if --frozen-lockfile is the only discussion point I'll be more than happy to undo those changes and just commit the new CI step to avoid the bleeding of uncommitted yarn.lock files.

Copy link
Contributor

@griffbrad griffbrad left a comment

Choose a reason for hiding this comment

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

Yeah. Let's just drop the --frozen-lockfile change from this PR so we can get the CI check in place.

@scinos scinos merged commit 6b7ef40 into master May 12, 2020
@scinos scinos deleted the fix/cleanup-yarn-lock branch May 12, 2020 07:02
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants