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: idempotency issues when rangeStrategy=update-lockfile is used with other rangeStrategy in the same file #11328

Merged
merged 15 commits into from Sep 7, 2021

Conversation

onigoetz
Copy link
Contributor

Changes:

This change provides a fix for #10050

Since options using postUpdateOptions cause the behaviour of PR updates to be non-deterministic, reuseExistingBranch is set to false when such options are discovered.

This should have no noticeable impact on the number of pushes because the commit won't be made if the content is identical to the previous commit.

Context:

Closes #10050

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

The PR from the production renovate is this one : onigoetz/renovate-loop-repro#1 as you can see there are several hundreds force pushes

The PR created by this updated code is : onigoetz/renovate-loop-repro#2
I have run the script three times locally, the first time it created the branch.
the second and third time it output this

DEBUG: 2 file(s) to commit (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
DEBUG: Committing files to branch renovate-test/all-minor-patch (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
DEBUG: git commit (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
       "result": {
         "author": null,
         "branch": "renovate-test/all-minor-patch",
         "commit": "2ae4f4f",
         "root": false,
         "summary": {"changes": 2, "insertions": 28, "deletions": 28}
       }
DEBUG: No file changes detected. Skipping commit (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
       "branchName": "renovate-test/all-minor-patch",
       "fileNames": ["package.json", "yarn.lock"]

Which seem to indicate that everything works as expected now

lib/workers/branch/reuse.spec.ts Outdated Show resolved Hide resolved
lib/workers/branch/reuse.spec.ts Show resolved Hide resolved
@viceice viceice requested a review from rarkins August 19, 2021 06:03
onigoetz and others added 2 commits August 19, 2021 08:22
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
@onigoetz
Copy link
Contributor Author

Hi @rarkins @viceice
Is there anything I can do to help get this merged ?
Thanks in advance

viceice
viceice previously approved these changes Aug 24, 2021
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

Use the re-request review button when you've done all mentioned changes, so we see the PR on our review list

@onigoetz
Copy link
Contributor Author

oh okay, sure will do that next time 👍

@onigoetz
Copy link
Contributor Author

I added a second check when two rangeStrategy are used on a single packageFile, when one is update-lockfile.

Here is an example output with this change :

DEBUG: Branch does not need rebasing (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
DEBUG: Detected multiple rangeStrategies along with update-lockfile (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
DEBUG: Using reuseExistingBranch: false (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)

...
DEBUG: Committing files to branch renovate-test/all-minor-patch (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
DEBUG: git commit (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
       "result": {
         "author": null,
         "branch": "renovate-test/all-minor-patch",
         "commit": "30d770d",
         "root": false,
         "summary": {"changes": 2, "insertions": 28, "deletions": 28}
       }
DEBUG: No file changes detected. Skipping commit (repository=onigoetz/renovate-loop-repro, branch=renovate-test/all-minor-patch)
       "branchName": "renovate-test/all-minor-patch",
       "fileNames": ["package.json", "yarn.lock"]

Still on the same test repository : onigoetz/renovate-loop-repro#2 (which now contains a force-push, but that's an actual dependency update)

lib/workers/branch/reuse.ts Outdated Show resolved Hide resolved
lib/workers/branch/reuse.ts Show resolved Hide resolved
lib/workers/branch/reuse.ts Outdated Show resolved Hide resolved
@onigoetz onigoetz requested a review from viceice August 27, 2021 19:07
viceice
viceice previously approved these changes Aug 28, 2021
@viceice viceice marked this pull request as draft August 30, 2021 12:58
@onigoetz onigoetz changed the title fix: idempotency issues when postUpdateOptions are present fix: idempotency issues when rangeStrategy=update-lockfile is used with other rangeStrategy in the same file Aug 31, 2021
@onigoetz onigoetz marked this pull request as ready for review August 31, 2021 14:53
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

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

It's kinda ugly but we may need to live with it. What do you think @viceice ?

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

Don't know a better solution for now. 🤔

@rarkins rarkins enabled auto-merge (squash) September 6, 2021 19:04
@rarkins rarkins merged commit 2a60a9c into renovatebot:main Sep 7, 2021
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 26.21.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yarnDedupeFewer runs even if no change was made to package.json
4 participants