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: separateMultipleMinor #24538

Merged
merged 35 commits into from Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
953341b
update docs
phyzical Sep 20, 2023
c15c836
support multiple minor pull requests
phyzical Sep 20, 2023
b152f12
support group
phyzical Sep 20, 2023
323a247
update the branch name via replace on .x instead
phyzical Sep 20, 2023
f672f8f
Update lib/config/options/index.ts
rarkins Sep 27, 2023
1a47f8f
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Sep 27, 2023
ed3d00c
Update lib/workers/repository/updates/branch-name.ts
rarkins Sep 27, 2023
bf4c026
Update docs/usage/configuration-options.md
rarkins Sep 28, 2023
cc4c600
Apply suggestions from code review
rarkins Sep 28, 2023
66a3fb6
Update lib/workers/repository/updates/branch-name.spec.ts
phyzical Oct 5, 2023
b2c0217
Update lib/workers/repository/updates/branch-name.spec.ts
phyzical Oct 5, 2023
43c12d2
Update lib/workers/repository/updates/branch-name.spec.ts
phyzical Oct 5, 2023
09a4a36
Merge branch 'main' into feature/seperateMultipleMinor
phyzical Oct 5, 2023
b9e79d5
lint
phyzical Oct 5, 2023
f5c78da
Update lib/config/presets/internal/default.ts
phyzical Oct 6, 2023
83af299
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Oct 23, 2023
45aba59
Update docs/usage/configuration-options.md
phyzical Oct 27, 2023
0aadc2c
Update docs/usage/configuration-options.md
phyzical Oct 27, 2023
b5b40f0
Update lib/config/options/index.ts
phyzical Oct 27, 2023
ac0ce96
Update lib/workers/repository/updates/branch-name.ts
phyzical Oct 27, 2023
a0463f7
Update docs/usage/configuration-options.md
phyzical Oct 27, 2023
6d7912b
Merge branch 'main' into feature/seperateMultipleMinor
phyzical Oct 27, 2023
af29f33
fix test
phyzical Oct 27, 2023
44bb571
Apply suggestions from code review
rarkins Nov 10, 2023
1d9b8af
Merge branch 'main' into feature/seperateMultipleMinor
phyzical Feb 6, 2024
e941623
eslint
phyzical Feb 6, 2024
8569589
md lint
phyzical Feb 6, 2024
1b3ec85
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Feb 19, 2024
9ff90aa
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Feb 19, 2024
e11953a
fix test
rarkins Feb 19, 2024
b9f17dd
Apply suggestions from code review
rarkins Mar 4, 2024
27e9e9f
Update lib/workers/repository/updates/branch-name.ts
viceice Mar 16, 2024
ac1cd26
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Mar 18, 2024
cd315d8
String
rarkins Mar 18, 2024
032bbbe
Merge branch 'main' into feature/seperateMultipleMinor
rarkins Mar 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -3773,6 +3773,15 @@ Configure this to `true` if you wish to get one PR for every separate major vers
e.g. if you are on webpack@v1 currently then default behavior is a PR for upgrading to webpack@v3 and not for webpack@v2.
If this setting is true then you would get one PR for webpack@v2 and one for webpack@v3.

## separateMultipleMinor

Enable this for dependencies when it is important to split updates into separate PRs per minor release stream (e.g. `python`).

For example, if you are on `python@v3.9.0` currently, then by default Renovate creates a PR to upgrade you to the latest version such as `python@v3.12.x`.
By default, Renovate skips versions in between, like `python@v3.10.x`.

But if you set `separateMultipleMinor=true` then you get separate PRs for each minor stream, like `python@3.9.x`, `python@v3.10.x` and `python@v3.11.x`, etc.

## skipInstalls

By default, Renovate will use the most efficient approach to updating package files and lock files, which in most cases skips the need to perform a full module install by the bot.
Expand Down
9 changes: 9 additions & 0 deletions lib/config/options/index.ts
Expand Up @@ -1620,6 +1620,15 @@ const options: RenovateOptions[] = [
type: 'boolean',
default: false,
},
{
name: 'separateMultipleMinor',
description:
'If set to `true`, Renovate creates separate PRs for each `minor` stream.',
stage: 'package',
type: 'boolean',
default: false,
rarkins marked this conversation as resolved.
Show resolved Hide resolved
experimental: true,
},
{
name: 'separateMinorPatch',
description:
Expand Down
5 changes: 5 additions & 0 deletions lib/config/presets/internal/default.ts
Expand Up @@ -574,6 +574,11 @@ export const presets: Record<string, Preset> = {
separateMajorMinor: true,
separateMultipleMajor: true,
},
separateMultipleMinorReleases: {
description:
'Separate each `minor` version of dependencies into individual branches/PRs.',
separateMultipleMinor: true,
},
separatePatchReleases: {
description:
'Separate `patch` and `minor` releases of dependencies into separate PRs.',
Expand Down
1 change: 1 addition & 0 deletions lib/config/validation.ts
Expand Up @@ -464,6 +464,7 @@ export async function validateConfig(
'separateMajorMinor',
'separateMinorPatch',
'separateMultipleMajor',
'separateMultipleMinor',
'versioning',
];
if (is.nonEmptyArray(resolvedRule.matchUpdateTypes)) {
Expand Down
11 changes: 7 additions & 4 deletions lib/workers/repository/process/lookup/bucket.ts
Expand Up @@ -3,6 +3,7 @@ import type { VersioningApi } from '../../../../modules/versioning/types';
export interface BucketConfig {
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
separateMultipleMinor?: boolean;
separateMinorPatch?: boolean;
}

Expand All @@ -12,8 +13,12 @@ export function getBucket(
newVersion: string,
versioning: VersioningApi,
): string | null {
const { separateMajorMinor, separateMultipleMajor, separateMinorPatch } =
config;
const {
separateMajorMinor,
separateMultipleMajor,
separateMultipleMinor,
separateMinorPatch,
} = config;
if (!separateMajorMinor) {
return 'latest';
}
Expand Down Expand Up @@ -46,11 +51,9 @@ export function getBucket(

// Check the minor update type first
if (fromMinor !== toMinor) {
/* future option
if (separateMultipleMinor) {
return `v${toMajor}.${toMinor}`;
}
*/

if (separateMinorPatch) {
return 'minor';
Expand Down
15 changes: 15 additions & 0 deletions lib/workers/repository/process/lookup/index.spec.ts
Expand Up @@ -2785,6 +2785,21 @@ describe('workers/repository/process/lookup/index', () => {
]);
});

it('should upgrade to 16 minors', async () => {
config.currentValue = '1.0.0';
config.separateMultipleMinor = true;
config.packageName = 'webpack';
config.datasource = NpmDatasource.id;
httpMock
.scope('https://registry.npmjs.org')
.get('/webpack')
.reply(200, webpackJson);
const { updates } = await Result.wrap(
lookup.lookupUpdates(config),
).unwrapOrThrow();
expect(updates).toHaveLength(16);
});

it('does not jump major unstable', async () => {
config.currentValue = '^4.4.0-canary.3';
config.rangeStrategy = 'replace';
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/lookup/types.ts
Expand Up @@ -41,6 +41,7 @@ export interface LookupUpdateConfig
isVulnerabilityAlert?: boolean;
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
separateMultipleMinor?: boolean;
datasource: string;
packageName: string;
minimumConfidence?: MergeConfidence | undefined;
Expand Down
1 change: 1 addition & 0 deletions lib/workers/repository/process/lookup/update-type.ts
Expand Up @@ -4,6 +4,7 @@ import type * as allVersioning from '../../../../modules/versioning';
export interface UpdateTypeConfig {
separateMajorMinor?: boolean;
separateMultipleMajor?: boolean;
separateMultipleMinor?: boolean;
separateMinorPatch?: boolean;
}

Expand Down
37 changes: 37 additions & 0 deletions lib/workers/repository/updates/branch-name.spec.ts
Expand Up @@ -59,6 +59,43 @@ describe('workers/repository/updates/branch-name', () => {
expect(upgrade.branchName).toBe('major-2-some-group-slug-grouptopic');
});

it('separates minor with groups', () => {
const upgrade: RenovateConfig = {
groupName: 'some group name',
groupSlug: 'some group slug',
updateType: 'minor',
separateMultipleMinor: true,
newMinor: 1,
newMajor: 2,
group: {
branchName: '{{groupSlug}}-{{branchTopic}}',
branchTopic: 'grouptopic',
},
};
generateBranchName(upgrade);
expect(upgrade.branchName).toBe('minor-2.1-some-group-slug-grouptopic');
});

it('separates minor when separateMultipleMinor=true', () => {
const upgrade: RenovateConfig = {
branchName:
'{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}',
branchPrefix: 'renovate/',
additionalBranchPrefix: '',
depNameSanitized: 'lodash',
newMajor: 4,
separateMinorPatch: true,
isPatch: true,
newMinor: 17,
branchTopic:
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if separateMinorPatch}}{{#if isPatch}}.{{{newMinor}}}{{/if}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}',
depName: 'dep',
group: {},
};
generateBranchName(upgrade);
expect(upgrade.branchName).toBe('renovate/lodash-4.17.x');
});

it('uses single major with groups', () => {
const upgrade: RenovateConfig = {
groupName: 'some group name',
Expand Down
10 changes: 8 additions & 2 deletions lib/workers/repository/updates/branch-name.ts
Expand Up @@ -47,6 +47,8 @@ function cleanBranchName(

export function generateBranchName(update: RenovateConfig): void {
// Check whether to use a group name
const newMajor = String(update.newMajor);
const newMinor = String(update.newMinor);
rarkins marked this conversation as resolved.
Show resolved Hide resolved
if (update.groupName) {
update.groupName = template.compile(update.groupName, update);
logger.trace('Using group branchName template');
Expand All @@ -64,12 +66,14 @@ export function generateBranchName(update: RenovateConfig): void {
});
if (update.updateType === 'major' && update.separateMajorMinor) {
if (update.separateMultipleMajor) {
const newMajor = String(update.newMajor);
update.groupSlug = `major-${newMajor}-${update.groupSlug}`;
} else {
update.groupSlug = `major-${update.groupSlug}`;
}
}
if (update.updateType === 'minor' && update.separateMultipleMinor) {
update.groupSlug = `minor-${newMajor}.${newMinor}-${update.groupSlug}`;
}
if (update.updateType === 'patch' && update.separateMinorPatch) {
update.groupSlug = `patch-${update.groupSlug}`;
}
Expand Down Expand Up @@ -116,7 +120,9 @@ export function generateBranchName(update: RenovateConfig): void {
update.branchName = template.compile(update.branchName, update);
update.branchName = template.compile(update.branchName, update);
}

if (update.updateType === 'minor' && update.separateMultipleMinor) {
update.branchName = update.branchName.replace('.x', `.${newMinor}.x`);
}
update.branchName = cleanBranchName(
update.branchName,
update.branchNameStrict,
Expand Down