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

Prevent merge of unsynchronized yarn.lock files #30052

Open
MikeMcC399 opened this issue Aug 18, 2024 · 8 comments
Open

Prevent merge of unsynchronized yarn.lock files #30052

MikeMcC399 opened this issue Aug 18, 2024 · 8 comments
Labels
type: chore Work is required w/ no deliverable to end user

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Aug 18, 2024

What would you like?

The develop branch should be protected against merging commits with unsynchronized yarn.lock files.

Running yarn on any commit in the develop branch, or destined for this branch, should not produce any differences in yarn.lock.

Why is this needed?

If commits with unsynchronized yarn.lock files are merged into the develop branch then follow-on PRs are forced into cleaning up the mismatch of their predecessor(s) leading to a confusing change history.

Other

Examples of PRs merged with unsynchronized yarn.lock files:

Renovate

See

Examples caused by Renovate:

Manual error

Caused by manual change to a dependency in a package.json file without running yarn:

@MikeMcC399 MikeMcC399 changed the title Prevent merge of unsynchronized yarn.lock files Prevent merge of unsynchronized yarn.lock files Aug 18, 2024
@MikeMcC399
Copy link
Contributor Author

GitHub Actions has a similar issue and https://github.com/cypress-io/github-action/blob/master/.github/workflows/check-dist.yml is used to check for unresolved changes.

That would be something like the following, added into the CI workflow at some point after yarn install has run:

if [ "$(git diff --ignore-space-at-eol | wc -l)" -gt "0" ]; then
    echo yarn.lock mismatch
    git diff
    exit 1
fi

@jennifer-shehane jennifer-shehane added the type: chore Work is required w/ no deliverable to end user label Aug 19, 2024
@jennifer-shehane
Copy link
Member

Yah, seems reasonable to have something in place since this keeps happening.

@MikeMcC399

This comment was marked as outdated.

@MikeMcC399
Copy link
Contributor Author

@MikeMcC399
Copy link
Contributor Author

  • Possibly branch protection rules for develop need revisiting.

  • PR chore(deps): migrate to @tanstack/react-query #30154 was clean in its own forked branch before merge, but has caused yarn.lock to become out of sync after merge. Was this because it wasn't up to date with develop at the time of merge? If the GitHub UI is used update a branch from develop does that cause a yarn de-duplication run?

@raygdev
Copy link
Contributor

raygdev commented Sep 14, 2024

  • Possibly branch protection rules for develop need revisiting.
  • PR chore(deps): migrate to @tanstack/react-query #30154 was clean in its own forked branch before merge, but has caused yarn.lock to become out of sync after merge. Was this because it wasn't up to date with develop at the time of merge? If the GitHub UI is used update a branch from develop does that cause a yarn de-duplication run?

@MikeMcC399

I did actually consider this when I started making changes. I ended up stashing the changes. I then ran git clean -xfd to remove the node modules. Pulled against the develop branch from cypress to ensure the latest changes, and manually added @tanstack/react-query to the package.json of that directory since the workaround for yarn add didn't work for me. I then ran yarn to install, made changes (not from my stash), and committed them. My initial commit wasn't a semantic release, so I also ran git --amend to change the commit message to suit the requirements of the semantic release. Do you think that may have caused the issue?

Was there something I could have done differently? I would like to make sure that for any future changes I make that this won't be a burden on anyone.

@MikeMcC399
Copy link
Contributor Author

@raygdev

Was there something I could have done differently? I would like to make sure that for any future changes I make that this won't be a burden on anyone.

The final state of your branch looks completely correct to me, so please don't worry that you did something wrong!

This issue is about improving the process to catch any mismatch issues caused by whatever reason. If there is a mismatch there should be a warning, however there wasn't a warning. I only noticed the problem when I was preparing a new PR and ran yarn which produced yarn.lock changes that had nothing to do with the changes in my new branch.

@raygdev
Copy link
Contributor

raygdev commented Sep 14, 2024

@MikeMcC399
Good to know! I just wanted to make sure that a command I ran wouldn't have caused this issue or that there was something in the process i could have done to prevent it. Will keep an eye on this! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore Work is required w/ no deliverable to end user
Projects
None yet
Development

No branches or pull requests

3 participants