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(config): Support presets in subdirectories #8724

Merged
merged 40 commits into from
Mar 20, 2021
Merged

feat(config): Support presets in subdirectories #8724

merged 40 commits into from
Mar 20, 2021

Conversation

ArmaanT
Copy link
Contributor

@ArmaanT ArmaanT commented Feb 16, 2021

Changes:

This PR adds the ability to extend a config preset that exists within an arbitrary path inside another repo. The new syntax is: github>user/repo//path/to/file which will load path/to/file.json within the user/repo repository.

This new syntax is supported on github, gitlab, gitea, and local (when on one of those platforms)

Context:

Closes #8674

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 unit tests, or
  • No new tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Here's the real repository I tested with. Here's a PR that was generated using an external preset config: ArmaanT/testbed#8.

@rarkins rarkins requested a review from viceice February 18, 2021 10:56
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.

@rarkins I'm not sure if this is what we want. Currently we use the preset :name as filename and we don't support sub-presets on those hosted presets. So why we don't simply use the all after the : as path. Which needs to have an extension then, to support json5 or later maybe yaml

@rarkins
Copy link
Collaborator

rarkins commented Feb 18, 2021

Currently we use the preset :name as filename and we don't support sub-presets on those hosted presets.

github>foo/bar:fruit/banana today already has a meaning: the file fruit.json and subobject banana. So I don't think we can use it.

I think we can keep our convention of "no file extension implies .json" both for these and others.

@viceice
Copy link
Member

viceice commented Feb 18, 2021

so parse as follow?

  • github>abc/foo//path/xyz:abc -> https://github.com/abc/foo and path/xyz/abc.json
  • github>abc/foo//path/xyz -> https://github.com/abc/foo and path/xyz/default.json (path/xyz/renovate.json fallback)

@ArmaanT
Copy link
Contributor Author

ArmaanT commented Feb 18, 2021

I think forcing a separation between the path and filename with : feels a bit unintuitive. Maybe we could use a trailing slash to signify we want to use default.json?
github>abc/foo//path/xyz -> path/xyz.json
github>abc/foo//path/xyz/ -> path/xyz/default.json (path/xyz/renovate.json)

@rarkins
Copy link
Collaborator

rarkins commented Feb 18, 2021

We need to maintain backwards compatibility at all costs here

@rarkins
Copy link
Collaborator

rarkins commented Feb 18, 2021

Once we are out of the root I think that having a filename specified as mandatory is an OK restriction

@viceice
Copy link
Member

viceice commented Feb 18, 2021

so again, we need to decide, what happens when github>abc/foo//path/xyz:abc is used. or even github>abc/foo//path/xyz:abc/def

is abc/def only a sub-preset path?

@viceice
Copy link
Member

viceice commented Feb 18, 2021

I think best is to split this github>abc/foo//path/xyz:abc/def as follows:

  • repo: https://github.com/abc/foo
  • presetName: path/xyz
  • sub-preset: abc/def

@ArmaanT
Copy link
Contributor Author

ArmaanT commented Feb 18, 2021

Right now the // syntax doesn't have any support for using : or subpresets. I have a slight preference to leaving it as-is (so that subdirectories are mutually exclusive with subpresets) because it offers new functionality without breaking the existing : subpreset parsing when not using a subdirectory.

I think the above idea could cause some confusion because it would overload the meaning of :abc/def where if there is no subdirectory, it loads abc.json with def subpreset, but if you're using the subdirectory syntax it would mean the abc/def subpreset within xyz.json

@rarkins
Copy link
Collaborator

rarkins commented Feb 18, 2021

I think best is to split this github>abc/foo//path/xyz:abc/def as follows:

  • repo: https://github.com/abc/foo
  • presetName: path/xyz
  • sub-preset: abc/def

If it makes a difference for us, we could argue that when using paths, you don't need sub-presets.

We also have documented github>abc/foo/:xyz as follows:

  • repo: https://github.com/abc/foo
  • presetName: xyz
  • sub-preset: none

And I've got a feeling that github>abc/foo/:xyz/def works as follows:

  • repo: https://github.com/abc/foo
  • presetName: xyz
  • sub-preset:def

In fact I think it's this above one that has caused us to consider the // divider?

@rarkins
Copy link
Collaborator

rarkins commented Feb 18, 2021

Do we think that "no sub-presets if subdirectories are in use" is a reasonable limitation?

@viceice
Copy link
Member

viceice commented Feb 18, 2021

I'm ok with no sub-preset support. But we should throw an config error if someone tries to do that.

lib/config/presets/index.ts Outdated Show resolved Hide resolved
@rarkins
Copy link
Collaborator

rarkins commented Feb 18, 2021

Yes, if they combine // with : then we should fail to parse it and throw

@ArmaanT
Copy link
Contributor Author

ArmaanT commented Mar 5, 2021

I think we should add a note below the table that combining path and subpreset is not supported.

That makes sense to me, but I'm not sure how that should be worded since subpresets aren't mentioned in the docs right now

@ArmaanT ArmaanT requested a review from viceice March 9, 2021 03:50
@viceice
Copy link
Member

viceice commented Mar 9, 2021

I think we should add a note below the table that combining path and subpreset is not supported.

That makes sense to me, but I'm not sure how that should be worded since subpresets aren't mentioned in the docs right now

@HonkingGoose Do you have a suggestion ? 🙃

lib/config/presets/index.ts Outdated Show resolved Hide resolved
viceice
viceice previously approved these changes Mar 9, 2021
@HonkingGoose
Copy link
Collaborator

@viceice and @ArmaanT

I think a note explaining what parts of the string are "repo", "path" and "subpreset" is OK for now, until we figure out more.
I'm not sure that subpresets need to be mentioned anywhere else? It seems to me that you only need to know those terms in this part of the document anyways? Or are there other places where we should mention these terms?

I don't have a suggestion now, as I don't really understand what terms belong to which parts of the strings. 😄

@ArmaanT ArmaanT marked this pull request as ready for review March 14, 2021 21:28
@ArmaanT ArmaanT requested a review from JamieMagee as a code owner March 14, 2021 21:28
@CLAassistant
Copy link

CLAassistant commented Mar 14, 2021

CLA assistant check
All committers have signed the CLA.

@ArmaanT
Copy link
Contributor Author

ArmaanT commented Mar 14, 2021

@HonkingGoose @viceice
I just added a note to the table specifying that the path syntax and subpreset syntax aren't compatible. I still don't feel too confident about it, so I'd like to hear what you both have to say

@viceice
Copy link
Member

viceice commented Mar 15, 2021

@ArmaanT Looks like a bad rebase? I think you need to rebase and force push to clean this pr.

@ArmaanT
Copy link
Contributor Author

ArmaanT commented Mar 15, 2021

Sorry about that @viceice, should be fixed now.

@viceice viceice requested a review from rarkins March 15, 2021 09:39
@rarkins rarkins changed the title feat: Support presets in subdirectories feat(config): Support presets in subdirectories Mar 20, 2021
@rarkins rarkins enabled auto-merge (squash) March 20, 2021 21:36
@rarkins rarkins merged commit e5c92e4 into renovatebot:master Mar 20, 2021
@ArmaanT ArmaanT deleted the feat/8674-preset-subdirectories branch March 20, 2021 23:03
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 24.91.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 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.

Support loading presets from subdirectories
8 participants