-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add support for yaml config files #7031
Comments
This comment has been minimized.
This comment has been minimized.
No, let's stick with JSON. We have a lot of config examples in our documentation and it would be painful to maintain both. In addition we have the JSON schema now which can be used for validation in IDEs. YAML is far from perfect too, and while the blog post may argue that JSON's strictness is a weakness, I think that YAML's lack of strictness can be equally problematic. |
Reopening this for reconsideration. We could support YAML config even if all our examples are JSON. People choosing to use YAML would need to accept that. Ideally one day all JSON code snippets in our markdown docs could be processed to generate the equivalent in YAML and then display both in docs (switchable). We also need to consider the impact of YAML on presets. We currently check for |
As I just discussed with @rarkins, I'd be willing to manually go through the docs to update them with YAML examples. People that would like to migrate from JSON to YAML can use yq to convert their file easily with |
What I was hoping for visually in our docs is something like this mockup (ignore the languages/example): Ideally JSON would be our single source of truth - therefore not many docs need changing - but we can transform them on the way to HTML so that tabbed examples can be shown, similar to the above. |
Where did you get that example from? I've been trying to find just that so I can try and find how to create it online. |
I found it in a meta Stack Overflow post discussing adding the feature to SO. But better news - it seems like such tabs are supported by Docusaurus, which we were planning to switch to. Exactly what we need: https://v2.docusaurus.io/docs/markdown-features/#multi-language-support-code-blocks |
That indeed looks like the perfect fit, what a coincidence. |
So, approximate steps:
This way users can keep writing simple markdown with JSON blocks as is today, but the docs published to docs.renovatebot.com have multi-language examples. One more thing: need to think about the admin config ( |
@rarkins I would love to see support for yaml! You don't even need to wait to migrate to docusaurus, as mkdocs supports this natively, so this shouldn't be a blocker to continue with the feature. See renovatebot/renovatebot.github.io#65 for a quick implementation of a post-processor with mkdocs (it's a few lines of code really), and below a short demo: renovate-yaml-2021-06-27_13.51.04.mp4The caveat is that examples need to be valid json (so currently a few are skipped), I think this would be the case with any post-processor anyway. |
Wow, cool! I'd like all our examples to be fully valid JSON anyway, so would be happy to add further linting to try to ensure it. I'm currently on vacation so struggling to keep up with the usual volume of issues and PRs. @viceice what do you think? |
Sounds good. but before we add the docs we need to allow the yaml config files. Ideas:
|
Re: filtering repo files, @viceice I'll just give you what I know for GitLab. Sadly on gitlab the most useful endpoint (search repo blobs) is a premium feature: https://docs.gitlab.com/ee/api/search.html#scope-blobs Second best, before actually looping over all possible filepaths, might be the repo tree endpoint: But again, if there are a lot of files in the repo that are returned before a renovate config file is found, the pagination might trigger more requests than just looping over ~10 files. This is better if you leave out So there would need to be a balance, maybe benchmark based on the average repo tree size. Just some thoughts on options :) |
I think if we cache the found config file name then it should be ok to have a small impact on the first run because it will be 0 impact indefinitely after that |
What about preset filenames? |
Good point. For backwards compatibility, no extension means .json. For .yaml or .json5 the extension must be included |
Is this something that's basically already done at least for per-repo config? renovate/lib/workers/repository/init/merge.ts Lines 27 to 38 in 9184207
|
Can we cache the resolved preset file names? that way we can suppress extension for preset too. 🤔 |
Depends whether you consider the current lack of file extensions a feature or a bug :) Less a user needs to type the better. But then we should try to avoid ambiguity and confusion too. BTW such caching could already be added today for the default.json/renovate.json check. Question is for how long? Eg 24 hours? Never, as long as the cached file name resolves? |
My idea waas to cache those in the repo json cache file, where we already have the repo config filename. I think we can cache the filenames as long as they resolve. We should also prefer json over yaml, if a user has both available. Should be documented of cause. |
So if there are 100 repos referencing a particular preset then we'd "try/fail" that preset once per downstream repo but then cache it in each downstream repo after that? Slightly inefficient but on the upside it resolves any concerns about caching private results |
Are there any updates on plans to support |
JSON schemas work just as well with YAML as they do with JSON since the two languages are essentially different representations of the same underlying structure. VSCode users get autocomplete, documentation, etc. from schemas that have been added to JSONSchema for example.
|
This topic came up again recently, so I will add a recent opinion: I don't want to support this unless a regular contributor to Renovate wants to add it and support it in the longer term. While one-off PRs are usually appreciated, in this case it would be like gifting a puppy - we'd be left behind to clean up after it and look after it all its life. |
What would you like Renovate to be able to do?
JSON isn't considered the best choice for configuration files anymore. This blog post on lucidchart explains some of the reasons for it. Most services (e.g., GitHub actions) use YAML as the new standard. In my opinion, YAML support for configuration files would make a helpful addition to Renovate. The configuration would be more comprehensible and also easier to edit, especially when using GitHub's online edit feature.
Did you already have any implementation ideas?
Since yaml is a superset of json, the config file could be parsed using the yaml library, and then, equally processed as the json-derived config object.
Is this a feature you'd be interested in implementing yourself?
Depends on your feedback and the level of interest in this feature.
The text was updated successfully, but these errors were encountered: