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

Allow Renovate to migrate its own configuration #17190

Closed
SebastianGoeb opened this issue Aug 15, 2022 · 4 comments
Closed

Allow Renovate to migrate its own configuration #17190

SebastianGoeb opened this issue Aug 15, 2022 · 4 comments
Labels
core:config Related to config capabilities and presets status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality)

Comments

@SebastianGoeb
Copy link

What would you like Renovate to be able to do?

It would be cool if Renovate could post config-migration PRs for its own config.json/js in the same way that it can for renovate.json of managed repositories.

If you have any ideas on how this should be implemented, please tell us here.

We use self-hosted Renovate running in a GitLab-CI Repo/Pipeline. Currently "Config needs migrating ..." logs aren't very useful because they end up in Renovate's own pipeline logs, which we don't usually check (it's supposed to be automated, right).

I was really hoping the configMigration feature could turn these log messages about config.js needing migrating into a PR that would update config.js. Unfortunately, this seems to only be available for the repository.json files of the managed repositories.

From what I can gather, Renovate currently uses its config migration code in two separate places:

  1. from workers/global/config/parse/file.ts
      const { isMigrated, migratedConfig } = migrateConfig(config);
      if (isMigrated) {
        logger.warn(
          { originalConfig: config, migratedConfig },
          'Config needs migrating'
        );
        config = migratedConfig;
      }
    
    which operates on config.js and results in the log message "Config needs migrating" or [nothing].
  2. workers/repository/config-migration/branch/migrated-data.ts
    // get migrated config
    const { isMigrated, migratedConfig } = migrateConfig(configFileParsed);
    if (!isMigrated) {
      return null;
    }
    
    which operates on renovate.json and results in a migration PR or the debug message "checkConfigMigrationBranch() Config does not need migration".

Maybe these usages could be unified somehow to allow both to produce config-migration PRs?

I suppose, I could also extract the shared settings into another, separate repository, also managed by renovate. This renovate.json could then be used by all repositories, including renovate itself. But that seems quite complicated (if including renovate.json into config.js is even permitted, not sure...). In any case, being able to migrate config.js too seems like a useful feature to me.

Is this a feature you are interested in implementing yourself?

No

@SebastianGoeb SebastianGoeb added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality) labels Aug 15, 2022
@HonkingGoose HonkingGoose added the core:config Related to config capabilities and presets label Aug 15, 2022
@viceice
Copy link
Member

viceice commented Aug 15, 2022

that's a lot more complicated that you think

@SebastianGoeb
Copy link
Author

that's a lot more complicated that you think

Is it? Renovate already produces Config needs migrating: oldConfig: {}, migratedConfig: {}, so essentially a diff. I haven't dug deep enough into the source, but I imagine the problem stems mostly from:

  1. this probably (?) being the final, composite configuration that comes out of module.exports = ..., with includes, functions, etc. all resolved
  2. config.js being a .js file, which could range from a simple json wrapper with some env replacements (that's what we do) to a complex, dynamic configuration possibly pulling parameters from remote apis (very clearly un-updatable).

Maybe, instead of having to reverse-engineering the .js to update it, a compromise could be to post a Draft-PR with the json and/or diff as a comment/thread/suggestion. The actual work of updating the config.js could be left to the reviewer, making this PR more of a notification that something needs to be done, rather than outright doing it, i.e. half-automated.

To be honest, I would already be very happy with simple notification-style PR, where I still have to do the work. The current problem is mainly that necessary changes go completely unnoticed, not that it's too much work to make the changes.

My original plan was to parse the JSON from the log and post that as a PR. Which is essentially the same thing, just as a hacky workaround instead of a native feature.

@HonkingGoose
Copy link
Collaborator

This issue may be a duplicate of this earlier one? Or maybe there are key differences between the issues, and we should keep both... 🙈

@rarkins
Copy link
Collaborator

rarkins commented Dec 12, 2022

Duplicate of #1502

Fixed by #15122

@rarkins rarkins closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core:config Related to config capabilities and presets status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality)
Projects
None yet
Development

No branches or pull requests

4 participants