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)!: parse JSON5/YAML self-hosted admin config #12644

Merged
merged 20 commits into from Dec 9, 2021

Conversation

nejch
Copy link
Contributor

@nejch nejch commented Nov 14, 2021

Changes:

Parses .json5 and .yaml/.yml config files for self-hosted bots if they are defined using RENOVATE_CONFIG_FILE.

Context:

Closes #7882.
It is also IMO the tiniest, least invasive next change (after #12196) towards #7031.

I deliberately say "parse" rather than "support" since I assume you want to cover all config files (project + preset) before officially supporting this.

However, if you'd like to already include this in docs, I could update renovatebot/renovatebot.github.io#65 to be configurable and only generate json+yaml blocks based on a file filter, e.g. docs/self-hosted-*.md or something. Just let me know.

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

@nejch nejch marked this pull request as ready for review November 14, 2021 10:47
lib/workers/global/config/parse/file.ts Show resolved Hide resolved
lib/workers/global/config/parse/file.ts Outdated Show resolved Hide resolved
lib/workers/global/config/parse/file.ts Outdated Show resolved Hide resolved
@nejch nejch marked this pull request as draft November 17, 2021 21:47
@nejch nejch marked this pull request as ready for review November 18, 2021 00:36
BREAKING CHANGE: Renovate will now fail if RENOVATE_CONFIG_FILE does
have a file extension provided.
@nejch nejch requested a review from rarkins November 27, 2021 14:49
@HonkingGoose HonkingGoose added the breaking Breaking change, requires major version bump label Nov 30, 2021
@rarkins rarkins requested a review from viceice December 9, 2021 10:41
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.

just some small test stuff

lib/workers/global/config/parse/file.spec.ts Outdated Show resolved Hide resolved
lib/workers/global/config/parse/file.spec.ts Outdated Show resolved Hide resolved
lib/workers/global/config/parse/file.spec.ts Outdated Show resolved Hide resolved
lib/workers/global/config/parse/file.spec.ts Outdated Show resolved Hide resolved
lib/workers/global/config/parse/file.ts Show resolved Hide resolved
viceice
viceice previously approved these changes Dec 9, 2021
@rarkins rarkins changed the title feat: parse JSON5/YAML self-hosted admin config feat!: parse JSON5/YAML self-hosted admin config Dec 9, 2021
@rarkins rarkins changed the title feat!: parse JSON5/YAML self-hosted admin config feat(config)!: parse JSON5/YAML self-hosted admin config Dec 9, 2021
@rarkins rarkins merged commit 9aa97af into renovatebot:main Dec 9, 2021
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 30.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nejch nejch deleted the feat/config-self-hosted-yaml-json5 branch December 9, 2021 13:12
@nejch
Copy link
Contributor Author

nejch commented Dec 9, 2021

Thanks for taking this over the finish line! There was a bit of ping pong there at the end for me, sorry :)

pmorch added a commit to pmorch/renovate that referenced this pull request Dec 12, 2021
module.exports can now be a function and it can be/return a Promise,
allowing the results of asynchronous operations to be used in the
configuration.

The discussion leading up to this PR in renovatebot#13035 assumed that
module.exports had to be a plain object.

But this commit:

  commit 9aa97af
  Author: Nejc Habjan <hab.nejc@gmail.com>
  Date:   Thu Dec 9 13:45:48 2021 +0100

      feat(config)!: parse JSON5/YAML self-hosted admin config (renovatebot#12644)

      Adds support for alternative admin config file formats.

      BREAKING CHANGE: Renovate will now fail if RENOVATE_CONFIG_FILE is specified without a file extension

Had as an undocumented side effect, that it also handled transparenty
if module.exports was assigned a Promise. With that commit, the
promise will be await-ed so the resolved value is returned from
getConfig(). That was not the case before that commit.

So in this commit, configs that export functions are handled, and
test cases for both promises and functions have been added.
pmorch added a commit to pmorch/renovate that referenced this pull request Dec 13, 2021
…atebot#12644)

The code was introduced in 9aa97af and here is the documentation to
go with it
viceice added a commit that referenced this pull request Dec 13, 2021
* feat(config): allow exporting async config (#13035)

module.exports can now be a function and it can be/return a Promise,
allowing the results of asynchronous operations to be used in the
configuration.

The discussion leading up to this PR in #13035 assumed that
module.exports had to be a plain object.

But this commit:

  commit 9aa97af
  Author: Nejc Habjan <hab.nejc@gmail.com>
  Date:   Thu Dec 9 13:45:48 2021 +0100

      feat(config)!: parse JSON5/YAML self-hosted admin config (#12644)

      Adds support for alternative admin config file formats.

      BREAKING CHANGE: Renovate will now fail if RENOVATE_CONFIG_FILE is specified without a file extension

Had as an undocumented side effect, that it also handled transparenty
if module.exports was assigned a Promise. With that commit, the
promise will be await-ed so the resolved value is returned from
getConfig(). That was not the case before that commit.

So in this commit, configs that export functions are handled, and
test cases for both promises and functions have been added.

* Update lib/workers/global/config/parse/__fixtures__/fileAsyncFunction.js

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>

* Update lib/workers/global/config/parse/__fixtures__/fileFunctionPromise.js

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>

* feat(config): Fixed linter problems (#13035)

* feat(config)!: Add doc for JSON5/YAML self-hosted admin config (#12644)

The code was introduced in 9aa97af and here is the documentation to
go with it

* feat(config): Document config.js exports (#13035)

* feat(config): Rename file*.js to config*.js because they really are config (#13035)

* Update docs/usage/getting-started/running.md

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>

* Update docs/usage/getting-started/running.md

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking Breaking change, requires major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support JSON5 for bot admin config files
5 participants