diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index bcc167f8d0ae6e..824a1b8183a9c8 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -129,6 +129,9 @@ const options: RenovateOptions[] = [ stage: 'repository', type: 'boolean', default: false, + experimental: true, + experimentalDescription: + 'Config migration PRs are still being improved, in particular to reduce the amount of reordering and whitespace changes.', }, { name: 'productLinks', diff --git a/lib/workers/repository/config-migration/pr/__snapshots__/index.spec.ts.snap b/lib/workers/repository/config-migration/pr/__snapshots__/index.spec.ts.snap index dcbcd3daed29ac..aba3532b87f749 100644 --- a/lib/workers/repository/config-migration/pr/__snapshots__/index.spec.ts.snap +++ b/lib/workers/repository/config-migration/pr/__snapshots__/index.spec.ts.snap @@ -1,18 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() creates PR for JSON5 config file 1`] = ` -"Config migration needed, merge this PR to update your Renovate configuration file. +"The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed. + + You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. #### [PLEASE NOTE](https://docs.renovatebot.com/configuration-options#configmigration): JSON5 config file migrated! All comments & trailing commas were removed. ---- -#### Migration completed successfully, No errors or warnings found. ---- +❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions). -❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section. -If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions). --- @@ -23,18 +21,16 @@ This PR has been generated by [Renovate Bot](https://github.com/renovatebot/reno exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() creates PR with empty footer and header 1`] = ` " -Config migration needed, merge this PR to update your Renovate configuration file. +The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed. + + You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. ---- -#### Migration completed successfully, No errors or warnings found. ---- +❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions). -❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section. -If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions). --- @@ -45,18 +41,16 @@ If you need any further assistance then you can also [request help here](https:/ exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() creates PR with footer and header using templating 1`] = ` "This is a header for platform:github -Config migration needed, merge this PR to update your Renovate configuration file. +The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed. + + You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. ---- -#### Migration completed successfully, No errors or warnings found. ---- +❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions). -❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section. -If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions). --- @@ -69,18 +63,16 @@ exports[`workers/repository/config-migration/pr/index ensureConfigMigrationPr() This should not be the first line of the PR -Config migration needed, merge this PR to update your Renovate configuration file. +The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed. + + You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. ---- -#### Migration completed successfully, No errors or warnings found. ---- +❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://github.com/renovatebot/renovate/discussions). -❓ Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section. -If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions). --- diff --git a/lib/workers/repository/config-migration/pr/errors-warnings.spec.ts b/lib/workers/repository/config-migration/pr/errors-warnings.spec.ts deleted file mode 100644 index 3069e6461eb618..00000000000000 --- a/lib/workers/repository/config-migration/pr/errors-warnings.spec.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { RenovateConfig, getConfig } from '../../../../../test/util'; -import { getErrors, getWarnings } from './errors-warnings'; - -describe('workers/repository/config-migration/pr/errors-warnings', () => { - let config: RenovateConfig; - - beforeEach(() => { - jest.resetAllMocks(); - config = getConfig(); - }); - - describe('getWarnings()', () => { - it('returns warning text', () => { - config.warnings = [ - { - topic: 'WARNING', - message: 'Something went wrong', - }, - ]; - const res = getWarnings(config); - expect(res).toMatchInlineSnapshot(` - " - # Warnings (1) - - Please correct - or verify that you can safely ignore - these warnings before you merge this PR. - - - \`WARNING\`: Something went wrong - - --- - " - `); - }); - }); - - describe('getErrors()', () => { - it('returns error text', () => { - config.errors = [ - { - topic: 'Error', - message: 'An error occurred', - }, - ]; - const res = getErrors(config); - expect(res).toMatchInlineSnapshot(` - " - # Errors (1) - - Renovate has found errors that you should fix (in this branch) before finishing this PR. - - - \`Error\`: An error occurred - - --- - " - `); - }); - }); -}); diff --git a/lib/workers/repository/config-migration/pr/errors-warnings.ts b/lib/workers/repository/config-migration/pr/errors-warnings.ts deleted file mode 100644 index 6506ec784de290..00000000000000 --- a/lib/workers/repository/config-migration/pr/errors-warnings.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { RenovateConfig } from '../../../../config/types'; - -export function getWarnings(config: RenovateConfig): string { - if (!config.warnings?.length) { - return ''; - } - let warningText = `\n# Warnings (${config?.warnings.length})\n\n`; - warningText += `Please correct - or verify that you can safely ignore - these warnings before you merge this PR.\n\n`; - config.warnings.forEach((w) => { - warningText += `- \`${w.topic}\`: ${w.message}\n`; - }); - warningText += '\n---\n'; - return warningText; -} - -export function getErrors(config: RenovateConfig): string { - let errorText = ''; - if (!config.errors?.length) { - return ''; - } - errorText = `\n# Errors (${config.errors.length})\n\n`; - errorText += `Renovate has found errors that you should fix (in this branch) before finishing this PR.\n\n`; - config.errors.forEach((e) => { - errorText += `- \`${e.topic}\`: ${e.message}\n`; - }); - errorText += '\n---\n'; - return errorText; -} diff --git a/lib/workers/repository/config-migration/pr/index.spec.ts b/lib/workers/repository/config-migration/pr/index.spec.ts index fd7c8691c18470..44395278a51f46 100644 --- a/lib/workers/repository/config-migration/pr/index.spec.ts +++ b/lib/workers/repository/config-migration/pr/index.spec.ts @@ -37,8 +37,6 @@ describe('workers/repository/config-migration/pr/index', () => { ...getConfig(), configMigration: true, defaultBranch: 'main', - errors: [], - warnings: [], description: [], }; }); diff --git a/lib/workers/repository/config-migration/pr/index.ts b/lib/workers/repository/config-migration/pr/index.ts index 7ab87877c16d7b..a4f2d8714d3c6a 100644 --- a/lib/workers/repository/config-migration/pr/index.ts +++ b/lib/workers/repository/config-migration/pr/index.ts @@ -14,7 +14,6 @@ import { prepareLabels } from '../../update/pr/labels'; import { addParticipants } from '../../update/pr/participants'; import type { MigratedData } from '../branch/migrated-data'; import { getMigrationBranchName } from '../common'; -import { getErrors, getWarnings } from './errors-warnings'; export async function ensureConfigMigrationPr( config: RenovateConfig, @@ -26,7 +25,7 @@ export async function ensureConfigMigrationPr( 'configuration-options/#configmigration' ); const branchName = getMigrationBranchName(config); - const prTitle = config.onboardingPrTitle ?? 'Config Migration'; + const prTitle = 'Migrate Renovate config'; const existingPr = await platform.getBranchPr(branchName); const closedPr = await platform.findPr({ branchName, @@ -35,8 +34,10 @@ export async function ensureConfigMigrationPr( }); const filename = migratedConfigData.filename; logger.debug('Filling in config migration PR template'); - let prTemplate = `Config migration needed, merge this PR to update your Renovate configuration file.\n\n`; - prTemplate += emojify( + let prBody = `The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed. + + You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. \n\n`; + prBody += emojify( ` ${ @@ -45,33 +46,12 @@ ${ `JSON5 config file migrated! All comments & trailing commas were removed.` : '' } ---- -{{#if hasWarningsErrors}} -{{{warnings}}} -{{{errors}}} -{{else}} -#### Migration completed successfully, No errors or warnings found. -{{/if}} ---- - -:question: Got questions? Check out Renovate's [Docs](${ - config.productLinks?.documentation - }), particularly the Getting Started section. -If you need any further assistance then you can also [request help here](${ +:question: Got questions? Does something look wrong to you? Please don't hesitate to [request help here](${ config.productLinks?.help - }). -` + }).\n\n` ); - const warnings = getWarnings(config); - const errors = getErrors(config); - const hasWarningsErrors = warnings || errors; - let prBody = prTemplate; - prBody = template.compile(prBody, { - warnings, - errors, - hasWarningsErrors, - }); + if (is.string(config.prHeader)) { prBody = `${template.compile(config.prHeader, config)}\n\n${prBody}`; } @@ -103,9 +83,7 @@ If you need any further assistance then you can also [request help here](${ } return; } - if ( - [config.onboardingPrTitle, 'Config Migration'].includes(closedPr?.title) - ) { + if (closedPr) { logger.debug('Found closed migration PR, exiting...'); return; }