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(package-rules)!: match packageName for matchPackageNames #22703

Merged
merged 25 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1169d19
feat!: allow post upgrade templating by default (#21326)
rarkins Apr 5, 2023
a9f5219
feat(automerge)!: default to platformAutomerge=true (#21327)
rarkins Apr 5, 2023
c1b63f6
feat(platform/gitlab)!: prefer `commit_email` (#21122
viceice Apr 26, 2023
ca7357f
fix(post-upgrade-tasks)!: enable dot option for file filters (#21282)
bgutschke Apr 26, 2023
bbc72d9
feat(npm)!: disable rollbackPrs for npm by default (#21970)
rarkins May 5, 2023
3f432a4
fix(presets)!: remove compatibility:additionalBranchPrefix (#22015)
rarkins May 7, 2023
6e95ba7
feat(package-rules)!: remove fuzzy matchPaths matching (#22394)
rarkins May 24, 2023
107e2bc
feat!: merge matchPaths and matchFiles into matchFileNames (#22406)
rarkins May 25, 2023
8bc9a6a
feat(package-rules)!: match packageName for matchPackageNames
rarkins Jun 12, 2023
fcb67af
feat!: allow post upgrade templating by default (#21326)
rarkins Apr 5, 2023
22ad73c
feat(automerge)!: default to platformAutomerge=true (#21327)
rarkins Apr 5, 2023
9df6457
feat(platform/gitlab)!: prefer `commit_email` (#21122
viceice Apr 26, 2023
c7f0604
fix(post-upgrade-tasks)!: enable dot option for file filters (#21282)
bgutschke Apr 26, 2023
be162f9
feat(npm)!: disable rollbackPrs for npm by default (#21970)
rarkins May 5, 2023
775eb99
fix(presets)!: remove compatibility:additionalBranchPrefix (#22015)
rarkins May 7, 2023
ff724cf
feat(package-rules)!: remove fuzzy matchPaths matching (#22394)
rarkins May 24, 2023
77cf950
feat!: merge matchPaths and matchFiles into matchFileNames (#22406)
rarkins May 25, 2023
136eece
feat!: remove `skipInstalls` config option (#22648)
RahulGautamSingh Jun 12, 2023
1eb2533
feat!: replace `dockerImagePrefix` with `dockerSidecarImage` (#22708)
RahulGautamSingh Jun 17, 2023
93a7751
feat!: Revert "feat!: remove `skipInstalls` config option (#22648)"
rarkins Jun 18, 2023
6515df8
feat(release-notes)!: support configurable fetching stage (#22781)
RahulGautamSingh Jun 18, 2023
553d2bc
Merge branch 'v36' into feat/20926-match-package-names
rarkins Jun 18, 2023
1eb534e
Merge branch 'v36' into feat/20926-match-package-names
rarkins Jun 18, 2023
e094aec
simplify
rarkins Jun 24, 2023
10850d1
Merge branch 'v36' into feat/20926-match-package-names
rarkins Jun 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 44 additions & 54 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1863,28 +1863,28 @@ Example:

The above rule will group together the `neutrino` package and any package matching `@neutrino/*`.

Path rules are convenient to use if you wish to apply configuration rules to certain package files using patterns.
File name matches are convenient to use if you wish to apply configuration rules to certain package or lock files using patterns.
For example, if you have an `examples` directory and you want all updates to those examples to use the `chore` prefix instead of `fix`, then you could add this configuration:

```json
{
"packageRules": [
{
"matchPaths": ["examples/**"],
"matchFileNames": ["examples/**"],
"extends": [":semanticCommitTypeAll(chore)"]
}
]
}
```

If you wish to limit Renovate to apply configuration rules to certain files in the root repository directory, you have to use `matchPaths` with a `minimatch` pattern or use [`matchFiles`](#matchfiles) with an exact match.
If you wish to limit Renovate to apply configuration rules to certain files in the root repository directory, you have to use `matchFileNames` with a `minimatch` pattern (which can include an exact file name match).
For example you have multiple `package.json` and want to use `dependencyDashboardApproval` only on the root `package.json`:

```json
{
"packageRules": [
{
"matchFiles": ["package.json"],
"matchFileNames": ["package.json"],
"dependencyDashboardApproval": true
}
]
Expand Down Expand Up @@ -2179,23 +2179,50 @@ Use the syntax `!/ /` like this:
}
```

### matchFiles
### matchFileNames

Renovate will compare `matchFiles` for an exact match against the dependency's package file or lock file.
Renovate will compare `matchFileNames` glob matching against the dependency's package file or lock file.

For example the following would match `package.json` but not `package/frontend/package.json`:
The following example matches `package.json` but _not_ `package/frontend/package.json`:

```json
{
"packageRules": [
{
"matchFiles": ["package.json"]
"matchFileNames": ["package.json"],
"labels": ["npm"]
}
]
}
```

Use [`matchPaths`](#matchpaths) instead if you need more flexible matching.
The following example matches any `package.json`, including files like `backend/package.json`:

```json
{
"packageRules": [
{
"description": "Group dependencies from package.json files",
"matchFileNames": ["**/package.json"],
"groupName": "All package.json changes"
}
]
}
```

The following example matches any file in directories starting with `app/`:

```json
{
"packageRules": [
{
"description": "Group all dependencies from the app directory",
"matchFileNames": ["app/**"],
"groupName": "App dependencies"
}
]
}
```

### matchDepNames

Expand Down Expand Up @@ -2255,43 +2282,6 @@ See also `excludePackagePrefixes`.

Like the earlier `matchPackagePatterns` example, the above will configure `rangeStrategy` to `replace` for any package starting with `angular`.

### matchPaths

Renovate finds the file(s) listed in `matchPaths` with a `minimatch` glob pattern.

For example the following matches any `package.json`, including files like `backend/package.json`:

```json
{
"packageRules": [
{
"description": "Group dependencies from package.json files",
"matchPaths": ["**/package.json"],
"groupName": "All package.json changes"
}
]
}
```

The following matches any file in directories starting with `app/`:

```json
{
"packageRules": [
{
"description": "Group all dependencies from the app directory",
"matchPaths": ["app/**"],
"groupName": "App dependencies"
}
]
}
```

<!-- prettier-ignore -->
!!! warning
Partial matches for `matchPaths` are deprecated.
Please use a `minimatch` glob pattern or switch to [`matchFiles`](#matchfiles) if you need exact matching.

### matchSourceUrlPrefixes

Here's an example of where you use this to group together all packages from the `renovatebot` GitHub org:
Expand Down Expand Up @@ -2513,28 +2503,28 @@ If enabled Renovate will pin Docker images or GitHub Actions by means of their S
## platformAutomerge

<!-- prettier-ignore -->
!!! warning
Before you enable `platformAutomerge` you should enable your Git hosting platform's capabilities to enforce test passing before PR merge.
!!! note
rarkins marked this conversation as resolved.
Show resolved Hide resolved
If you use the default `platformAutomerge=true` then you should enable your Git hosting platform's capabilities to enforce test passing before PR merge.
If you don't do this, the platform might merge Renovate PRs even if the repository's tests haven't started, are in still in progress, or possibly even when they have failed.
On GitHub this is called "Require status checks before merging", which you can find in the "Branch protection rules" section of the settings for your repository.
[GitHub docs, about protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches)
[GitHub docs, require status checks before merging](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches#require-status-checks-before-merging)
If you're using another platform, search their documentation for a similar feature.

If you have enabled `automerge` and set `automergeType=pr` in the Renovate config, then you can also set `platformAutomerge` to `true` to speed up merging via the platform's native automerge functionality.
If you have enabled `automerge` and set `automergeType=pr` in the Renovate config, then leaving `platformAutomerge` as `true` speeds up merging via the platform's native automerge functionality.

Renovate tries platform-native automerge only when it initially creates the PR.
Any PR that is being updated will be automerged with the Renovate-based automerge.

`platformAutomerge` will configure PRs to be merged after all (if any) branch policies have been met.
This option is available for Azure, GitHub and GitLab.
This option is available for Azure, Gitea, GitHub and GitLab.
rarkins marked this conversation as resolved.
Show resolved Hide resolved
It falls back to Renovate-based automerge if the platform-native automerge is not available.

You can also fine-tune the behavior by setting `packageRules` if you want to use it selectively (e.g. per-package).

Note that the outcome of `rebaseWhen=auto` can differ when `platformAutomerge=true`.
Normally when you set `rebaseWhen=auto` Renovate rebases any branch that's behind the base branch automatically, and some people rely on that.
This behavior is no longer guaranteed when you enable `platformAutomerge` because the platform might automerge a branch which is not up-to-date.
This behavior is no longer guaranteed when `platformAutomerge` is `true` because the platform might automerge a branch which is not up-to-date.
For example, GitHub might automerge a Renovate branch even if it's behind the base branch at the time.

Please check platform specific docs for version requirements.
Expand Down Expand Up @@ -2605,6 +2595,7 @@ You can use variable templating in your commands if [`allowPostUpgradeCommandTem
### fileFilters

A list of glob-style matchers that determine which files will be included in the final commit made by Renovate.
Dotfiles are included.

### executionMode

Expand Down Expand Up @@ -3267,9 +3258,8 @@ There are times when a dependency version in use by a project gets removed from
For some registries, existing releases or even whole packages can be removed or "yanked" at any time, while for some registries only very new or unused releases can be removed.
Renovate's "rollback" feature exists to propose a downgrade to the next-highest release if the current release is no longer found in the registry.

Renovate does not create these rollback PRs by default, with one exception: npm packages get a rollback PR if needed.

You can configure the `rollbackPrs` property globally, per-language, or per-package to override the default behavior.
Renovate does not create these rollback PRs by default, so this functionality needs to be opted-into.
We recommend you do this selectively with `packageRules` and not globally.

## ruby

Expand Down
12 changes: 5 additions & 7 deletions docs/usage/key-concepts/automerge.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ Say you want to automerge `patch` and `minor` updates for packages in the `group

### Faster merges with platform-native automerge

You can speed up merges by letting Renovate use your platform's native automerge.
The config option is called `platformAutomerge`.
If `automerge=true` and `automergeType=pr` then you can set `platformAutomerge=true`.
By default, Renovate uses platform-native automerge to speed up automerging.
If you don't want Renovate to use the platform-native automerge, then set `platformAutomerge` to `false`.

For example:

Expand All @@ -112,7 +111,7 @@ For example:
"enabled": true,
"automerge": true,
"automergeType": "pr",
"platformAutomerge": true
"platformAutomerge": false
}
}
```
Expand Down Expand Up @@ -155,11 +154,10 @@ On `github.com`, go to your repository's "homepage", click on Settings, scroll d
Then go to your repository's branch protection rules for your base branch (usually `main`) and enable the "Require merge queue" setting.
Confirm you've set the correct "required checks" for your base branch.

Finally, allow Renovate to automerge by setting `automerge=true` and `platformAutomerge=true` in your Renovate config file, for example:
Finally, allow Renovate to automerge by setting `automerge=true` in your Renovate config file, for example:

```json
{
"platformAutomerge": true,
"packageRules": [
{
"description": "Automerge non-major updates",
Expand All @@ -180,7 +178,7 @@ On `github.com`, go to your repository's "homepage", click on Settings, scroll d
Go to your repository's branch protection rules for your base branch (usually `main`) and enable the "Require merge queue" setting.
Confirm you've set the correct "required checks" for your base branch.

Finally, allow Renovate to automerge by setting `automerge=true` and `platformAutomerge=true` in your Renovate config file (see earlier example).
Finally, allow Renovate to automerge by setting `automerge=true` in your Renovate config file (see earlier example).

## Automerging and scheduling

Expand Down
8 changes: 3 additions & 5 deletions docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ Please also see [Self-Hosted Experimental Options](./self-hosted-experimental.md

## allowPostUpgradeCommandTemplating

Set to `true` to allow templating of dependency level post-upgrade commands.

Let's look at an example of configuring packages with existing Angular migrations.

Add two properties to `config.js`: `allowPostUpgradeCommandTemplating` and `allowedPostUpgradeCommands`:

```javascript
module.exports = {
allowPostUpgradeCommandTemplating: true,
allowedPostUpgradeCommands: ['^npm ci --ignore-scripts$', '^npx ng update'],
};
```
Expand Down Expand Up @@ -60,6 +55,9 @@ npm ci --ignore-scripts
npx ng update @angular/core --from=10.0.0 --to=11.0.0 --migrate-only --allow-dirty --force
```

If you wish to disable templating because of any security or performance concern, you may set `allowPostUpgradeCommandTemplating` to `false`.
But before you disable templating completely, try the `allowedPostUpgradeCommands` config option to limit what commands are allowed to run.

## allowScripts

## allowedPostUpgradeCommands
Expand Down
9 changes: 0 additions & 9 deletions docs/usage/self-hosted-experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ Source: [AWS S3 documentation - Interface BucketEndpointInputConfig](https://doc

If set, Renovate will terminate the whole process group of a terminated child process spawned by Renovate.

## `RENOVATE_X_MATCH_PACKAGE_NAMES_MORE`

If set, you'll get the following behavior.

When using `matchPackageNames` and `matchPackagePatterns` matchers:

1. Renovate first tries to match against `depName`
2. If `depName` doesn't match then Renovate tries to match against `packageName`

## `RENOVATE_X_MERGE_CONFIDENCE_API_BASE_URL`

If set, Renovate will query this API for Merge Confidence data.
Expand Down
16 changes: 8 additions & 8 deletions lib/config/__snapshots__/migration.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1`
"extends": [
"node",
],
"matchPaths": [
"matchFileNames": [
"node/**",
],
},
Expand Down Expand Up @@ -211,7 +211,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1`
"extends": [
"foo",
],
"matchPaths": [
"matchFileNames": [
"examples/**",
],
},
Expand Down Expand Up @@ -293,7 +293,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack
"matchDepTypes": [
"devDependencies",
],
"matchPaths": [
"matchFileNames": [
"package.json",
],
"rangeStrategy": "pin",
Expand All @@ -302,7 +302,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack
"matchDepTypes": [
"dependencies",
],
"matchPaths": [
"matchFileNames": [
"package.json",
],
"rangeStrategy": "pin",
Expand Down Expand Up @@ -332,13 +332,13 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi
],
"packageRules": [
{
"matchPaths": [
"matchFileNames": [
"backend/package.json",
],
"rangeStrategy": "replace",
},
{
"matchPaths": [
"matchFileNames": [
"frontend/package.json",
],
"rangeStrategy": "pin",
Expand All @@ -347,7 +347,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi
"matchDepTypes": [
"devDependencies",
],
"matchPaths": [
"matchFileNames": [
"other/package.json",
],
"rangeStrategy": "pin",
Expand All @@ -356,7 +356,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi
"matchDepTypes": [
"dependencies",
],
"matchPaths": [
"matchFileNames": [
"other/package.json",
],
"rangeStrategy": "pin",
Expand Down
1 change: 0 additions & 1 deletion lib/config/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ describe('config/index', () => {
const config = getManagerConfig(parentConfig, 'npm');
expect(config).toContainEntries([
['fileMatch', ['(^|/)package\\.json$']],
['rollbackPrs', true],
]);
expect(getManagerConfig(parentConfig, 'html')).toContainEntries([
['fileMatch', ['\\.html?$']],
Expand Down
30 changes: 29 additions & 1 deletion lib/config/migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,41 @@ describe('config/migration', () => {
matchManagers: ['dockerfile'],
matchPackageNames: ['foo'],
matchPackagePatterns: ['^bar'],
matchPaths: ['package.json'],
matchFileNames: ['package.json'],
matchSourceUrlPrefixes: ['https://github.com/lodash'],
matchUpdateTypes: ['major'],
},
],
});
});

it('migrates in order of precedence', () => {
const config: TestRenovateConfig = {
packageRules: [
{
matchFiles: ['matchFiles'],
matchPaths: ['matchPaths'],
},
{
matchPaths: ['matchPaths'],
matchFiles: ['matchFiles'],
},
],
};
const { isMigrated, migratedConfig } =
configMigration.migrateConfig(config);
expect(isMigrated).toBeTrue();
expect(migratedConfig).toEqual({
packageRules: [
{
matchFileNames: ['matchPaths'],
},
{
matchFileNames: ['matchFiles'],
},
],
});
});
});

it('it migrates nested packageRules', () => {
Expand Down
Loading