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: allow templating of the extends field #27955

Merged
merged 21 commits into from
May 14, 2024

Conversation

lstoeferle
Copy link
Contributor

@lstoeferle lstoeferle commented Mar 15, 2024

Changes

Hi everyone,
this PR adds the extends field to the allowed field for handlebars templating to add some QOL for self-hosted config presets within the same directory like the self-host-config.

Self-Hosted configuration

module.exports = {
  customEnvVariables: {
    GITLAB_REF: process.env.CI_COMMIT_REF_NAME,
  },
}

Repository configuration

{
  extends: ["local>foo/bar#{{ env.GITLAB_REF }}"]
}

Context

#27952

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 select 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

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.

wrong, doesn't work that way

lib/util/template/index.ts Outdated Show resolved Hide resolved
@lstoeferle
Copy link
Contributor Author

There's one issue with the replacements:messageFormat-{{package}}-to-@messageformat/{{package}} preset, since it contains {{package}}. I've added a presetTemplateIgnoredFields config, which skips the template compilation in case any of the values are present in the template string.

@rarkins
Copy link
Collaborator

rarkins commented Mar 18, 2024

I don't think that templating based on package is a valid concept. extends fields are evaluated during repository intialization, which is before any packages are detected. I think we need to go back to the discussion to understand better what you're trying to do

@rarkins rarkins closed this Mar 18, 2024
@lstoeferle
Copy link
Contributor Author

I don't think that templating based on package is a valid concept. extends fields are evaluated during repository intialization, which is before any packages are detected. I think we need to go back to the discussion to understand better what you're trying to do

It's not my intention to do templating base on package 😉 The problem is, that there is an existing preset which is called replacements:messageFormat-{{package}}-to-@messageformat/{{package}}, which includes the handlebars {{package}}. So in the end there will be replacements:messageFormat--to-@messageformat/, since it will be filled with an empty string by default.

I've added a more detailed scenario here: #27952 (comment)

@rarkins rarkins reopened this Mar 20, 2024
@rarkins
Copy link
Collaborator

rarkins commented Mar 20, 2024

Let's rename that messageFormat-{{package} one - plus add a migration - and ideally add a test that such names don't include handlebars syntax in future

@rarkins rarkins marked this pull request as draft March 20, 2024 11:34
@lstoeferle
Copy link
Contributor Author

Let's rename that messageFormat-{{package} one - plus add a migration - and ideally add a test that such names don't include handlebars syntax in future

Applied the changes. For the test I'm not quite sure how/where to implement that.

lib/config/presets/index.ts Show resolved Hide resolved
lib/config/presets/internal/index.spec.ts Outdated Show resolved Hide resolved
@lstoeferle lstoeferle requested a review from viceice April 11, 2024 09:44
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
@lstoeferle lstoeferle marked this pull request as ready for review April 11, 2024 12:00
@rarkins rarkins requested a review from viceice April 11, 2024 12:10
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.

there should be a note that only a small subset of options can be used in template

docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
lstoeferle and others added 3 commits April 18, 2024 14:21
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
@lstoeferle lstoeferle requested review from viceice and rarkins May 6, 2024 11:58
rarkins
rarkins previously approved these changes May 13, 2024
Copy link
Collaborator

@HonkingGoose HonkingGoose left a comment

Choose a reason for hiding this comment

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

I'll let a maintainer check the Renovate code and the configuration examples.

docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
docs/usage/config-presets.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@HonkingGoose HonkingGoose left a comment

Choose a reason for hiding this comment

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

Sorry for crossing wires on the PR reviews with the lead maintainer. 😉

I'll let the maintainer review again. 🙃

@rarkins rarkins enabled auto-merge May 13, 2024 11:36
@lstoeferle
Copy link
Contributor Author

@rarkins may I ask you for a final approval? 😇

@HonkingGoose HonkingGoose requested a review from rarkins May 14, 2024 12:14
@rarkins rarkins added this pull request to the merge queue May 14, 2024
Merged via the queue into renovatebot:main with commit 91e8a86 May 14, 2024
37 checks passed
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 37.363.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

zharinov pushed a commit to zharinov/renovate that referenced this pull request May 15, 2024
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants