cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.68k stars 3.16k forks source link

Prevent merge of unsynchronized `yarn.lock` files #30052

Open MikeMcC399 opened 3 weeks ago

MikeMcC399 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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

MikeMcC399 commented 3 weeks ago

@jennifer-shehane

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

MikeMcC399 commented 2 weeks ago