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

feat(core/onboarding): support manual rebase/retry #17633

Merged
merged 47 commits into from Jan 11, 2023

Conversation

Gabriel-Ladzaretti
Copy link
Collaborator

@Gabriel-Ladzaretti Gabriel-Ladzaretti commented Sep 5, 2022

Changes

  • Additional feature flag to enable onboarding rebase checkbox
  • Added static onboarding state holder for manual retry request

Based on the feature flag value -

  • Onboarding PRs body will now contain embedded config hash + rebase checkbox

Supported platforms -

  • GitHub
  • GitLab
  • Gitea

Unsupported platforms will be unaffected by this change.

Changed logic -
Extraction -> lookup -> PR creation/update flow will now be preformed only when one of the following condition is met:

  • No onboarding PR exists
  • Missing rebase checkbox
  • Manual retry requested
  • Branch is behind base
  • Onboarding config was modified by the user (config hash changed)
  • Missing PR embedded config hash

If non of the above is met, repo cache is left unchanged as well (setBranchCache is skipped as part of worker/index, cache.scan is written as part of the extraction, therefore is skipped as well).

Note that the rebase terminology in the context of onboarding is a bit misleading, as the actual action preformed by checking the checkbox is Updating the onboarding PR.

Design consideration -

  • Embedding config hash as opposed to repo cache it:
    • We currently sample the onboarding PR
    • Onboarding is the only case where the renovate config is present in a non base branch, caching it would pollute the repo cache
    • bodyStruct infrastructure is already widely used
  • Storing current config hash
    • Used to detect config modification by the user. As the user changes the config, the branch won't get rebased (cause of isBranchModified) so isBranchModified cant be used to detect config changes as it will always be true once other than renovate[bot] have committed to the branch

Context

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 (GitHub + Bitbucket)

@Gabriel-Ladzaretti

This comment was marked as outdated.

@Gabriel-Ladzaretti
Copy link
Collaborator Author

Should we be worried about exceeding 60k characters here?

Copy link
Collaborator

@PhilipAbed PhilipAbed left a comment

Choose a reason for hiding this comment

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

MassageMarkdown for other platform that dont support html comments and checkboxes
azure/Bitbucket/bitbucket-server
and soon AWS

lib/modules/platform/azure/index.ts Outdated Show resolved Hide resolved
lib/modules/platform/pr-body.spec.ts Outdated Show resolved Hide resolved
lib/workers/repository/onboarding/common.ts Show resolved Hide resolved
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.

Do you think any of this can be broken up into smaller pieces? There's a lot of code being touched here

lib/workers/repository/onboarding/branch/index.ts Outdated Show resolved Hide resolved
lib/modules/platform/azure/index.ts Outdated Show resolved Hide resolved
lib/modules/platform/pr-body.ts Outdated Show resolved Hide resolved
lib/modules/platform/pr-body.ts Outdated Show resolved Hide resolved
lib/workers/repository/index.ts Outdated Show resolved Hide resolved
lib/workers/repository/onboarding/branch/index.ts Outdated Show resolved Hide resolved
lib/workers/repository/onboarding/common.ts Outdated Show resolved Hide resolved
lib/workers/repository/onboarding/common.ts Outdated Show resolved Hide resolved
lib/modules/platform/bitbucket/index.ts Outdated Show resolved Hide resolved
lib/modules/platform/pr-body.ts Outdated Show resolved Hide resolved
lib/workers/repository/onboarding/pr/index.ts Outdated Show resolved Hide resolved
lib/modules/platform/pr-body.ts Outdated Show resolved Hide resolved
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
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.

need extensive real repo testing

viceice
viceice previously approved these changes Nov 14, 2022
@Gabriel-Ladzaretti
Copy link
Collaborator Author

Ill run some e2e tests on GitHub and Bitbucket again, hopefully in the coming days

@rarkins rarkins marked this pull request as draft November 29, 2022 08:53
viceice
viceice previously approved these changes Dec 8, 2022
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.

code lgtm 🤷‍♂️

# Conflicts:
#	lib/workers/repository/index.ts
@Gabriel-Ladzaretti
Copy link
Collaborator Author

e2e testing:

Github

Running with the onboardingRebaseCheckbox: false ->extraction/lookup is preformed on every run, repo cache updated on every run.

Turning onboardingRebaseCheckbox: true, with an existing onboarding -> checkbox is added, lookup performed, repo cache updated.

Running again without modifications to the branch -> no lookup, repo cache remains the same.

DEBUG: Repository timing splits (milliseconds) (repository=ladzaretti/onboarding)
       "splits": {"init": 9965, "onboarding": 133, "update": 1},

Commit to branch -> changes detected -> extraction + lookup performed -> cache updated

DEBUG: Onboarding config has been modified by the user (repository=ladzaretti/onboarding)
...
DEBUG: Repository timing splits (milliseconds) (repository=ladzaretti/onboarding)
       "splits": {"init": 9422, "extract": 572, "lookup": 400, "onboarding": 2481, "update": 0},
       "total": 104374

Running again -> no extraction or lookup

DEBUG: Repository timing splits (milliseconds) (repository=ladzaretti/onboarding)
       "splits": {"init": 9377, "onboarding": 115, "update": 1},
       "total": 33022

Manually updating the PR body by deleting the checkbox prompt -> PR is getting fixed

DEBUG: No rebase checkbox was found in the onboarding PR (repository=ladzaretti/onboarding)
DEBUG: Repository timing splits (milliseconds) (repository=ladzaretti/onboarding)
       "splits": {"init": 9182, "extract": 600, "lookup": 389, "onboarding": 2084, "update": 1},
       "total": 23035

Turning it off by onboardingRebaseCheckbox: false => PR restored to its regular form.

Bitbucket

enabling the feature has no effect.

DEBUG: Repository timing splits (milliseconds) (repository=gabriel-ladzaretti/onboarding)
       "splits": {"init": 14282, "extract": 764, "lookup": 496, "onboarding": 187, "update": 1},
       "total": 16094
{"name":"renovate","hostname":"Gabriel-Dell5420","pid":18052,"level":10,"logContext":"FAH6g4QH_X-6ucWQ4Jcrh","repository":"gabriel-ladzaretti/onboarding","msg":"Platform 'bitbucket' does not support extended markdown","time":"2023-01-08T21:48:58.411Z","v":0}

@rarkins rarkins enabled auto-merge (squash) January 11, 2023 13:00
@rarkins rarkins merged commit de289bb into renovatebot:main Jan 11, 2023
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 34.99.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants