From 1169d19a33a50e5cc89c5fc9ff910ecfd24a1bef Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 5 Apr 2023 06:44:55 +0200 Subject: [PATCH 01/22] feat!: allow post upgrade templating by default (#21326) Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/self-hosted-configuration.md | 8 +++----- lib/config/options/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index a46d563be6d49e..7f5a8d29a0cb20 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -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'], }; ``` @@ -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 diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index f71066be46c06b..c4f17846cbd2a7 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -24,9 +24,9 @@ const options: RenovateOptions[] = [ { name: 'allowPostUpgradeCommandTemplating', description: - 'Set this to `true` to allow templating for post-upgrade commands.', + 'Set this to `false` to disable template compilation for post-upgrade commands.', type: 'boolean', - default: false, + default: true, globalOnly: true, }, { From a9f52197561479de4120c82858406f5b01a6858a Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 5 Apr 2023 11:27:22 +0200 Subject: [PATCH 02/22] feat(automerge)!: default to platformAutomerge=true (#21327) Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/configuration-options.md | 10 +++++----- docs/usage/key-concepts/automerge.md | 12 +++++------- lib/config/options/index.ts | 2 +- lib/modules/platform/gitea/index.md | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 5283cde1724deb..fce02cbd7176aa 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2513,28 +2513,28 @@ If enabled Renovate will pin Docker images or GitHub Actions by means of their S ## platformAutomerge -!!! warning - Before you enable `platformAutomerge` you should enable your Git hosting platform's capabilities to enforce test passing before PR merge. +!!! note + 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. 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. diff --git a/docs/usage/key-concepts/automerge.md b/docs/usage/key-concepts/automerge.md index 579ebc8a9bc948..d4203845fb680c 100644 --- a/docs/usage/key-concepts/automerge.md +++ b/docs/usage/key-concepts/automerge.md @@ -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: @@ -112,7 +111,7 @@ For example: "enabled": true, "automerge": true, "automergeType": "pr", - "platformAutomerge": true + "platformAutomerge": false } } ``` @@ -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", @@ -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 diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index c4f17846cbd2a7..fa50c18406e1c9 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -2611,7 +2611,7 @@ const options: RenovateOptions[] = [ description: `Controls if platform-native auto-merge is used.`, type: 'boolean', supportedPlatforms: ['azure', 'gitea', 'github', 'gitlab'], - default: false, + default: true, }, { name: 'userStrings', diff --git a/lib/modules/platform/gitea/index.md b/lib/modules/platform/gitea/index.md index 098fb39be1f9fc..1f68d933542c5e 100644 --- a/lib/modules/platform/gitea/index.md +++ b/lib/modules/platform/gitea/index.md @@ -18,7 +18,7 @@ Either the account should have full name and email address set to allow Renovate ## Unsupported platform features/concepts - **Adding reviewers to PRs not supported**: Gitea versions older than `v1.14.0` do not have the required API. -- **Setting `platformAutomerge` to use platform-native automerge for PRs not supported**: Gitea versions older than v1.17.0 do not have the required API. +- **`platformAutomerge` (`true` by default) for platform-native automerge not supported**: Gitea versions older than v1.17.0 do not have the required API. - **Git upload filters**: If you're using a Gitea version older than `v1.16.0` then you must enable [clone filters](https://docs.gitea.io/en-us/clone-filters/). ## Features awaiting implementation From c1b63f6d793afaa1fae5b2cc42fad9e634f4b23e Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Wed, 26 Apr 2023 08:26:13 +0200 Subject: [PATCH 03/22] feat(platform/gitlab)!: prefer `commit_email` (#21122 gitAuthor discover for GitLab now prefers the field `commit_email` over `email`. BREAKING CHANGE: GitLab gitAuthor will change from the account's "email" to "commit_email" if they are different. --- lib/modules/platform/gitlab/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 17e6a497288831..d9fadc2ad9f9c9 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -107,12 +107,16 @@ export async function initPlatform({ try { if (!gitAuthor) { const user = ( - await gitlabApi.getJson<{ email: string; name: string; id: number }>( - `user`, - { token } - ) + await gitlabApi.getJson<{ + email: string; + name: string; + id: number; + commit_email?: string; + }>(`user`, { token }) ).body; - platformConfig.gitAuthor = `${user.name} <${user.email}>`; + platformConfig.gitAuthor = `${user.name} <${ + user.commit_email ?? user.email + }>`; } // istanbul ignore if: experimental feature if (process.env.RENOVATE_X_PLATFORM_VERSION) { From ca7357fd5fb5281cae3e58bffc0be4a1373c175f Mon Sep 17 00:00:00 2001 From: Bastian Gutschke Date: Wed, 26 Apr 2023 19:05:27 +0200 Subject: [PATCH 04/22] fix(post-upgrade-tasks)!: enable dot option for file filters (#21282) Set `{ dot: true }` for minimatch. BREAKING CHANGE: dot files will now be included by default for all minimatch results --- docs/usage/configuration-options.md | 1 + .../repository/update/branch/execute-post-upgrade-commands.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index fce02cbd7176aa..57b16c87ee19d0 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2605,6 +2605,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 diff --git a/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts b/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts index be8b39f4ec65c6..9efb844b0dc2bb 100644 --- a/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts +++ b/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts @@ -106,7 +106,7 @@ export async function postUpgradeCommandsExecutor( for (const relativePath of status.modified.concat(status.not_added)) { for (const pattern of fileFilters) { - if (minimatch(relativePath, pattern)) { + if (minimatch(relativePath, pattern, { dot: true })) { logger.debug( { file: relativePath, pattern }, 'Post-upgrade file saved' @@ -134,7 +134,7 @@ export async function postUpgradeCommandsExecutor( for (const relativePath of status.deleted || []) { for (const pattern of fileFilters) { - if (minimatch(relativePath, pattern)) { + if (minimatch(relativePath, pattern, { dot: true })) { logger.debug( { file: relativePath, pattern }, 'Post-upgrade file removed' From bbc72d95635dafe82e50e3139c72e7ccee5838f3 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 5 May 2023 19:47:16 +0200 Subject: [PATCH 05/22] feat(npm)!: disable rollbackPrs for npm by default (#21970) --- docs/usage/configuration-options.md | 5 ++--- lib/config/index.spec.ts | 1 - lib/modules/manager/npm/index.ts | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 57b16c87ee19d0..d7f0554f864b93 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -3268,9 +3268,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 diff --git a/lib/config/index.spec.ts b/lib/config/index.spec.ts index 001ea8c8b53488..94e6822cf72dfc 100644 --- a/lib/config/index.spec.ts +++ b/lib/config/index.spec.ts @@ -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?$']], diff --git a/lib/modules/manager/npm/index.ts b/lib/modules/manager/npm/index.ts index 3ac8a7f281b4ea..9d309bd8a23348 100644 --- a/lib/modules/manager/npm/index.ts +++ b/lib/modules/manager/npm/index.ts @@ -17,7 +17,6 @@ export const supportsLockFileMaintenance = true; export const defaultConfig = { fileMatch: ['(^|/)package\\.json$'], - rollbackPrs: true, versioning: npmVersioning.id, digest: { prBodyDefinitions: { From 3f432a426b94dff85be098864d7982d0e54f0a54 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sun, 7 May 2023 22:07:47 +0200 Subject: [PATCH 06/22] fix(presets)!: remove compatibility:additionalBranchPrefix (#22015) --- lib/config/presets/common.ts | 1 + lib/config/presets/internal/compatibility.ts | 28 -------------------- lib/config/presets/internal/index.ts | 2 -- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 lib/config/presets/internal/compatibility.ts diff --git a/lib/config/presets/common.ts b/lib/config/presets/common.ts index 8ae2839ed0b5c7..8e0a6a03327b97 100644 --- a/lib/config/presets/common.ts +++ b/lib/config/presets/common.ts @@ -12,6 +12,7 @@ export const removedPresets: Record = { ':masterIssueApproval': ':dependencyDashboardApproval', ':switchToGradleLite': null, ':unpublishSafe': 'npm:unpublishSafe', + 'compatibility:additionalBranchPrefix': null, 'config:application': 'config:js-app', 'config:base-js': 'config:base', 'config:library': 'config:js-lib', diff --git a/lib/config/presets/internal/compatibility.ts b/lib/config/presets/internal/compatibility.ts deleted file mode 100644 index 57e12a8d82fb2e..00000000000000 --- a/lib/config/presets/internal/compatibility.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { Preset } from '../types'; - -/* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */ - -export const presets: Record = { - additionalBranchPrefix: { - buildkite: { - additionalBranchPrefix: 'buildkite-', - }, - cargo: { - additionalBranchPrefix: 'rust-', - }, - description: - 'Backwards-compatibility preset to restore `additionalBranchPrefix` settings for multiple managers which were removed in Renovate `v25`.', - docker: { - additionalBranchPrefix: 'docker-', - }, - homebrew: { - additionalBranchPrefix: 'homebrew-', - }, - packageRules: [ - { - additionalBranchPrefix: 'helm-', - matchDatasources: ['helm'], - }, - ], - }, -}; diff --git a/lib/config/presets/internal/index.ts b/lib/config/presets/internal/index.ts index 63765664558b69..e37788d17fc4c8 100644 --- a/lib/config/presets/internal/index.ts +++ b/lib/config/presets/internal/index.ts @@ -1,5 +1,4 @@ import type { Preset, PresetConfig } from '../types'; -import * as compatibilityPreset from './compatibility'; import * as configPreset from './config'; import * as defaultPreset from './default'; import * as dockerPreset from './docker'; @@ -17,7 +16,6 @@ import * as workaroundsPreset from './workarounds'; /* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */ export const groups: Record> = { - compatibility: compatibilityPreset.presets, config: configPreset.presets, default: defaultPreset.presets, docker: dockerPreset.presets, From 6e95ba75e20954fda58733ab8544b7715da33c2f Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 24 May 2023 08:07:00 +0200 Subject: [PATCH 07/22] feat(package-rules)!: remove fuzzy matchPaths matching (#22394) --- docs/usage/configuration-options.md | 5 ----- lib/config/options/index.ts | 2 +- lib/util/package-rules/index.spec.ts | 2 +- lib/util/package-rules/paths.spec.ts | 11 ++--------- lib/util/package-rules/paths.ts | 20 +++----------------- 5 files changed, 7 insertions(+), 33 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index d7f0554f864b93..2b2a12eed1a1fc 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2287,11 +2287,6 @@ The following matches any file in directories starting with `app/`: } ``` - -!!! 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: diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index fa50c18406e1c9..ed4eefcab2fbad 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1307,7 +1307,7 @@ const options: RenovateOptions[] = [ { name: 'matchPaths', description: - 'List of strings or glob patterns to match against package files. Only works inside a `packageRules` object.', + 'List of glob patterns to match against package files. Only works inside a `packageRules` object.', type: 'array', subType: 'string', stage: 'repository', diff --git a/lib/util/package-rules/index.spec.ts b/lib/util/package-rules/index.spec.ts index 9e6f48f4b38d11..ecfeee4914794c 100644 --- a/lib/util/package-rules/index.spec.ts +++ b/lib/util/package-rules/index.spec.ts @@ -989,7 +989,7 @@ describe('util/package-rules/index', () => { ...config, depName: 'test', }); - expect(res3.x).toBeDefined(); + expect(res3.x).toBeUndefined(); }); it('empty rules', () => { diff --git a/lib/util/package-rules/paths.spec.ts b/lib/util/package-rules/paths.spec.ts index 9b0c1db55484aa..4e0bfed3567995 100644 --- a/lib/util/package-rules/paths.spec.ts +++ b/lib/util/package-rules/paths.spec.ts @@ -17,7 +17,7 @@ describe('util/package-rules/paths', () => { expect(result).toBeFalse(); }); - it('should return true and log warning on partial match only', () => { + it('should return false on partial match only', () => { const result = pathsMatcher.matches( { packageFile: 'opentelemetry/http/package.json', @@ -26,14 +26,7 @@ describe('util/package-rules/paths', () => { matchPaths: ['opentelemetry/http'], } ); - expect(result).toBeTrue(); - expect(logger.warn).toHaveBeenCalledWith( - { - packageFile: 'opentelemetry/http/package.json', - rulePath: 'opentelemetry/http', - }, - 'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.' - ); + expect(result).toBeFalse(); }); it('should return true and not log warning on partial and glob match', () => { diff --git a/lib/util/package-rules/paths.ts b/lib/util/package-rules/paths.ts index 7bd882c56966e0..7fa70aaa9ef991 100644 --- a/lib/util/package-rules/paths.ts +++ b/lib/util/package-rules/paths.ts @@ -1,7 +1,6 @@ import is from '@sindresorhus/is'; import { minimatch } from 'minimatch'; import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; -import { logger } from '../../logger'; import { Matcher } from './base'; export class PathsMatcher extends Matcher { @@ -16,21 +15,8 @@ export class PathsMatcher extends Matcher { return false; } - return matchPaths.some((rulePath) => { - if (minimatch(packageFile, rulePath, { dot: true })) { - return true; - } - - if (packageFile.includes(rulePath)) { - logger.warn( - { - rulePath, - packageFile, - }, - 'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.' - ); - return true; - } - }); + return matchPaths.some((rulePath) => + minimatch(packageFile, rulePath, { dot: true }) + ); } } From 107e2bcd6a361364c6d81b8f1911686123d0d243 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Thu, 25 May 2023 17:46:28 +0200 Subject: [PATCH 08/22] feat!: merge matchPaths and matchFiles into matchFileNames (#22406) --- docs/usage/configuration-options.md | 77 +++++++++---------- .../__snapshots__/migration.spec.ts.snap | 16 ++-- lib/config/migration.spec.ts | 30 +++++++- .../custom/automerge-major-migration.spec.ts | 4 +- .../custom/automerge-minor-migration.spec.ts | 4 +- .../custom/automerge-patch-migration.spec.ts | 4 +- .../custom/package-rules-migration.spec.ts | 2 +- .../custom/package-rules-migration.ts | 4 +- lib/config/options/index.ts | 13 +--- lib/config/presets/internal/default.ts | 2 +- lib/config/types.ts | 4 +- lib/config/validation.ts | 3 +- lib/modules/manager/npm/extract/index.ts | 2 +- lib/util/package-rules/files.spec.ts | 6 +- lib/util/package-rules/files.ts | 18 +++-- lib/util/package-rules/index.spec.ts | 6 +- lib/util/package-rules/matchers.ts | 6 +- lib/util/package-rules/paths.spec.ts | 45 ----------- lib/util/package-rules/paths.ts | 22 ------ .../__snapshots__/vulnerability.spec.ts.snap | 10 +-- .../repository/init/vulnerability.spec.ts | 2 +- lib/workers/repository/init/vulnerability.ts | 6 +- .../repository/updates/flatten.spec.ts | 2 +- 23 files changed, 118 insertions(+), 170 deletions(-) delete mode 100644 lib/util/package-rules/paths.spec.ts delete mode 100644 lib/util/package-rules/paths.ts diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 2b2a12eed1a1fc..acd6a58f18dc4a 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -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 } ] @@ -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 @@ -2255,38 +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" - } - ] -} -``` - ### matchSourceUrlPrefixes Here's an example of where you use this to group together all packages from the `renovatebot` GitHub org: diff --git a/lib/config/__snapshots__/migration.spec.ts.snap b/lib/config/__snapshots__/migration.spec.ts.snap index 572cc3bbdb1787..c4df79d9deb94f 100644 --- a/lib/config/__snapshots__/migration.spec.ts.snap +++ b/lib/config/__snapshots__/migration.spec.ts.snap @@ -164,7 +164,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1` "extends": [ "node", ], - "matchPaths": [ + "matchFileNames": [ "node/**", ], }, @@ -211,7 +211,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1` "extends": [ "foo", ], - "matchPaths": [ + "matchFileNames": [ "examples/**", ], }, @@ -293,7 +293,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack "matchDepTypes": [ "devDependencies", ], - "matchPaths": [ + "matchFileNames": [ "package.json", ], "rangeStrategy": "pin", @@ -302,7 +302,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack "matchDepTypes": [ "dependencies", ], - "matchPaths": [ + "matchFileNames": [ "package.json", ], "rangeStrategy": "pin", @@ -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", @@ -347,7 +347,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi "matchDepTypes": [ "devDependencies", ], - "matchPaths": [ + "matchFileNames": [ "other/package.json", ], "rangeStrategy": "pin", @@ -356,7 +356,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi "matchDepTypes": [ "dependencies", ], - "matchPaths": [ + "matchFileNames": [ "other/package.json", ], "rangeStrategy": "pin", diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index fcb40a6609d2d6..eae90ddd53c9fe 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -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', () => { diff --git a/lib/config/migrations/custom/automerge-major-migration.spec.ts b/lib/config/migrations/custom/automerge-major-migration.spec.ts index 0d2a9a7d30ba60..9dd5ebd21c87d0 100644 --- a/lib/config/migrations/custom/automerge-major-migration.spec.ts +++ b/lib/config/migrations/custom/automerge-major-migration.spec.ts @@ -19,13 +19,13 @@ describe('config/migrations/custom/automerge-major-migration', () => { { automergeMajor: 'some-value', major: { - matchFiles: ['test'], + matchFileNames: ['test'], }, }, { major: { automerge: true, - matchFiles: ['test'], + matchFileNames: ['test'], }, } ); diff --git a/lib/config/migrations/custom/automerge-minor-migration.spec.ts b/lib/config/migrations/custom/automerge-minor-migration.spec.ts index 9597466a7b3682..5ce417773f84c6 100644 --- a/lib/config/migrations/custom/automerge-minor-migration.spec.ts +++ b/lib/config/migrations/custom/automerge-minor-migration.spec.ts @@ -19,13 +19,13 @@ describe('config/migrations/custom/automerge-minor-migration', () => { { automergeMinor: 'some-value', minor: { - matchFiles: ['test'], + matchFileNames: ['test'], }, }, { minor: { automerge: true, - matchFiles: ['test'], + matchFileNames: ['test'], }, } ); diff --git a/lib/config/migrations/custom/automerge-patch-migration.spec.ts b/lib/config/migrations/custom/automerge-patch-migration.spec.ts index bc7014fa541f61..124f599fe921b3 100644 --- a/lib/config/migrations/custom/automerge-patch-migration.spec.ts +++ b/lib/config/migrations/custom/automerge-patch-migration.spec.ts @@ -19,13 +19,13 @@ describe('config/migrations/custom/automerge-patch-migration', () => { { automergePatch: 'some-value', patch: { - matchFiles: ['test'], + matchFileNames: ['test'], }, }, { patch: { automerge: true, - matchFiles: ['test'], + matchFileNames: ['test'], }, } ); diff --git a/lib/config/migrations/custom/package-rules-migration.spec.ts b/lib/config/migrations/custom/package-rules-migration.spec.ts index e77f20476fab5e..b5f6afaf7a016a 100644 --- a/lib/config/migrations/custom/package-rules-migration.spec.ts +++ b/lib/config/migrations/custom/package-rules-migration.spec.ts @@ -48,7 +48,7 @@ describe('config/migrations/custom/package-rules-migration', () => { { packageRules: [ { - matchPaths: [], + matchFileNames: [], packgageRules: { languages: ['javascript'], }, diff --git a/lib/config/migrations/custom/package-rules-migration.ts b/lib/config/migrations/custom/package-rules-migration.ts index e3be4c4c910ac0..9da8469fe3c23c 100644 --- a/lib/config/migrations/custom/package-rules-migration.ts +++ b/lib/config/migrations/custom/package-rules-migration.ts @@ -2,7 +2,9 @@ import type { PackageRule } from '../../types'; import { AbstractMigration } from '../base/abstract-migration'; export const renameMap = { - paths: 'matchPaths', + matchFiles: 'matchFileNames', + matchPaths: 'matchFileNames', + paths: 'matchFileNames', languages: 'matchLanguages', baseBranchList: 'matchBaseBranches', managers: 'matchManagers', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index ed4eefcab2fbad..4957af9fdb3a2c 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1294,7 +1294,7 @@ const options: RenovateOptions[] = [ env: false, }, { - name: 'matchFiles', + name: 'matchFileNames', description: 'List of strings to do an exact match against package and lock files with full path. Only works inside a `packageRules` object.', type: 'array', @@ -1304,17 +1304,6 @@ const options: RenovateOptions[] = [ cli: false, env: false, }, - { - name: 'matchPaths', - description: - 'List of glob patterns to match against package files. Only works inside a `packageRules` object.', - type: 'array', - subType: 'string', - stage: 'repository', - parent: 'packageRules', - cli: false, - env: false, - }, // Version behaviour { name: 'allowedVersions', diff --git a/lib/config/presets/internal/default.ts b/lib/config/presets/internal/default.ts index 4a7ca0f2577a20..f65b0c48c93eb9 100644 --- a/lib/config/presets/internal/default.ts +++ b/lib/config/presets/internal/default.ts @@ -361,7 +361,7 @@ export const presets: Record = { 'Use semanticCommitType `{{arg0}}` for all package files matching path `{{arg1}}`.', packageRules: [ { - matchPaths: ['{{arg0}}'], + matchFileNames: ['{{arg0}}'], semanticCommitType: '{{arg1}}', }, ], diff --git a/lib/config/types.ts b/lib/config/types.ts index 5c390b09c825a0..a06a7adc8d8ba6 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -313,8 +313,7 @@ export interface PackageRule Record { description?: string | string[]; isVulnerabilityAlert?: boolean; - matchFiles?: string[]; - matchPaths?: string[]; + matchFileNames?: string[]; matchLanguages?: string[]; matchBaseBranches?: string[]; matchManagers?: string | string[]; @@ -459,6 +458,7 @@ export type RenovateOptions = export interface PackageRuleInputConfig extends Record { versioning?: string; packageFile?: string; + lockFiles?: string[]; depType?: string; depTypes?: string[]; depName?: string; diff --git a/lib/config/validation.ts b/lib/config/validation.ts index f5c7b59c5c5657..254e36cb40c8f2 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -311,8 +311,7 @@ export async function validateConfig( } const selectors = [ - 'matchFiles', - 'matchPaths', + 'matchFileNames', 'matchLanguages', 'matchBaseBranches', 'matchManagers', diff --git a/lib/modules/manager/npm/extract/index.ts b/lib/modules/manager/npm/extract/index.ts index 00c3fb7d3e0444..467cdef6b849fc 100644 --- a/lib/modules/manager/npm/extract/index.ts +++ b/lib/modules/manager/npm/extract/index.ts @@ -64,7 +64,7 @@ export async function extractPackageFile( const error = new Error(CONFIG_VALIDATION); error.validationSource = packageFile; error.validationError = - 'Nested package.json must not contain renovate configuration. Please use `packageRules` with `matchPaths` in your main config instead.'; + 'Nested package.json must not contain Renovate configuration. Please use `packageRules` with `matchFileNames` in your main config instead.'; throw error; } const packageJsonName = packageJson.name; diff --git a/lib/util/package-rules/files.spec.ts b/lib/util/package-rules/files.spec.ts index 374d2650355465..ac30c31247f00d 100644 --- a/lib/util/package-rules/files.spec.ts +++ b/lib/util/package-rules/files.spec.ts @@ -1,7 +1,7 @@ -import { FilesMatcher } from './files'; +import { FileNamesMatcher } from './files'; describe('util/package-rules/files', () => { - const fileMatcher = new FilesMatcher(); + const fileMatcher = new FileNamesMatcher(); describe('match', () => { it('should return false if packageFile is not defined', () => { @@ -10,7 +10,7 @@ describe('util/package-rules/files', () => { packageFile: undefined, }, { - matchFiles: ['frontend/package.json'], + matchFileNames: ['frontend/package.json'], } ); expect(result).toBeFalse(); diff --git a/lib/util/package-rules/files.ts b/lib/util/package-rules/files.ts index e1ab76f4d70192..bb6cd57a3c5c90 100644 --- a/lib/util/package-rules/files.ts +++ b/lib/util/package-rules/files.ts @@ -1,23 +1,27 @@ import is from '@sindresorhus/is'; +import { minimatch } from 'minimatch'; import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; import { Matcher } from './base'; -export class FilesMatcher extends Matcher { +export class FileNamesMatcher extends Matcher { override matches( { packageFile, lockFiles }: PackageRuleInputConfig, - { matchFiles }: PackageRule + { matchFileNames }: PackageRule ): boolean | null { - if (is.undefined(matchFiles)) { + if (is.undefined(matchFileNames)) { return null; } if (is.undefined(packageFile)) { return false; } - return matchFiles.some( - (fileName) => - packageFile === fileName || - (is.array(lockFiles) && lockFiles?.includes(fileName)) + return matchFileNames.some( + (matchFileName) => + minimatch(packageFile, matchFileName, { dot: true }) || + (is.array(lockFiles) && + lockFiles.some((lockFile) => + minimatch(lockFile, matchFileName, { dot: true }) + )) ); } } diff --git a/lib/util/package-rules/index.spec.ts b/lib/util/package-rules/index.spec.ts index ecfeee4914794c..0718b5243126a8 100644 --- a/lib/util/package-rules/index.spec.ts +++ b/lib/util/package-rules/index.spec.ts @@ -930,7 +930,7 @@ describe('util/package-rules/index', () => { packageFile: 'examples/foo/package.json', packageRules: [ { - matchFiles: ['package.json'], + matchFileNames: ['package.json'], x: 1, }, ], @@ -954,7 +954,7 @@ describe('util/package-rules/index', () => { lockFiles: ['yarn.lock'], packageRules: [ { - matchFiles: ['yarn.lock'], + matchFileNames: ['yarn.lock'], x: 1, }, ], @@ -968,7 +968,7 @@ describe('util/package-rules/index', () => { packageFile: 'examples/foo/package.json', packageRules: [ { - matchPaths: ['examples/**', 'lib/'], + matchFileNames: ['examples/**', 'lib/'], x: 1, }, ], diff --git a/lib/util/package-rules/matchers.ts b/lib/util/package-rules/matchers.ts index 2a11fdd8180d58..dd2672c777b678 100644 --- a/lib/util/package-rules/matchers.ts +++ b/lib/util/package-rules/matchers.ts @@ -5,14 +5,13 @@ import { DatasourcesMatcher } from './datasources'; import { DepNameMatcher } from './dep-names'; import { DepPatternsMatcher } from './dep-patterns'; import { DepTypesMatcher } from './dep-types'; -import { FilesMatcher } from './files'; +import { FileNamesMatcher } from './files'; import { LanguagesMatcher } from './languages'; import { ManagersMatcher } from './managers'; import { MergeConfidenceMatcher } from './merge-confidence'; import { PackageNameMatcher } from './package-names'; import { PackagePatternsMatcher } from './package-patterns'; import { PackagePrefixesMatcher } from './package-prefixes'; -import { PathsMatcher } from './paths'; import { SourceUrlPrefixesMatcher } from './sourceurl-prefixes'; import { SourceUrlsMatcher } from './sourceurls'; import type { MatcherApi } from './types'; @@ -29,8 +28,7 @@ matchers.push([ new PackagePatternsMatcher(), new PackagePrefixesMatcher(), ]); -matchers.push([new FilesMatcher()]); -matchers.push([new PathsMatcher()]); +matchers.push([new FileNamesMatcher()]); matchers.push([new DepTypesMatcher()]); matchers.push([new LanguagesMatcher()]); matchers.push([new BaseBranchesMatcher()]); diff --git a/lib/util/package-rules/paths.spec.ts b/lib/util/package-rules/paths.spec.ts deleted file mode 100644 index 4e0bfed3567995..00000000000000 --- a/lib/util/package-rules/paths.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { logger } from '../../logger'; -import { PathsMatcher } from './paths'; - -describe('util/package-rules/paths', () => { - const pathsMatcher = new PathsMatcher(); - - describe('match', () => { - it('should return false if packageFile is not defined', () => { - const result = pathsMatcher.matches( - { - packageFile: undefined, - }, - { - matchPaths: ['opentelemetry/http'], - } - ); - expect(result).toBeFalse(); - }); - - it('should return false on partial match only', () => { - const result = pathsMatcher.matches( - { - packageFile: 'opentelemetry/http/package.json', - }, - { - matchPaths: ['opentelemetry/http'], - } - ); - expect(result).toBeFalse(); - }); - - it('should return true and not log warning on partial and glob match', () => { - const result = pathsMatcher.matches( - { - packageFile: 'package.json', - }, - { - matchPaths: ['package.json'], - } - ); - expect(result).toBeTrue(); - expect(logger.warn).not.toHaveBeenCalled(); - }); - }); -}); diff --git a/lib/util/package-rules/paths.ts b/lib/util/package-rules/paths.ts deleted file mode 100644 index 7fa70aaa9ef991..00000000000000 --- a/lib/util/package-rules/paths.ts +++ /dev/null @@ -1,22 +0,0 @@ -import is from '@sindresorhus/is'; -import { minimatch } from 'minimatch'; -import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; -import { Matcher } from './base'; - -export class PathsMatcher extends Matcher { - override matches( - { packageFile }: PackageRuleInputConfig, - { matchPaths }: PackageRule - ): boolean | null { - if (is.undefined(matchPaths)) { - return null; - } - if (is.undefined(packageFile)) { - return false; - } - - return matchPaths.some((rulePath) => - minimatch(packageFile, rulePath, { dot: true }) - ); - } -} diff --git a/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap b/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap index e731e34f30e745..1c6a552c0026b5 100644 --- a/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap +++ b/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap @@ -7,7 +7,7 @@ exports[`workers/repository/init/vulnerability detectVulnerabilityAlerts() retur "matchDatasources": [ "npm", ], - "matchFiles": [ + "matchFileNames": [ "backend/package-lock.json", ], "matchPackageNames": [ @@ -31,7 +31,7 @@ exports[`workers/repository/init/vulnerability detectVulnerabilityAlerts() retur "matchDatasources": [ "go", ], - "matchFiles": [ + "matchFileNames": [ "go.mod", ], "matchPackageNames": [ @@ -61,7 +61,7 @@ go", "matchDatasources": [ "github-tags", ], - "matchFiles": [ + "matchFileNames": [ ".github/workflows/build.yaml", ], "matchPackageNames": [ @@ -91,7 +91,7 @@ actions", "matchDatasources": [ "pypi", ], - "matchFiles": [ + "matchFileNames": [ "requirements.txt", ], "matchPackageNames": [ @@ -136,7 +136,7 @@ Ansible before versions 2.1.4, 2.2.1 is vulnerable to an improper input validati "matchDatasources": [ "maven", ], - "matchFiles": [ + "matchFileNames": [ "pom.xml", ], "matchPackageNames": [ diff --git a/lib/workers/repository/init/vulnerability.spec.ts b/lib/workers/repository/init/vulnerability.spec.ts index 7b47d5ab7aa06a..90e0b9f328cc6d 100644 --- a/lib/workers/repository/init/vulnerability.spec.ts +++ b/lib/workers/repository/init/vulnerability.spec.ts @@ -332,7 +332,7 @@ describe('workers/repository/init/vulnerability', () => { const res = await detectVulnerabilityAlerts(config); expect(res.packageRules).toMatchSnapshot(); expect(res.packageRules).toHaveLength(5); - expect(res.packageRules?.[1]?.matchFiles?.[0]).toBe('go.mod'); + expect(res.packageRules?.[1]?.matchFileNames?.[0]).toBe('go.mod'); expect(res.packageRules?.[2]?.matchCurrentVersion).toBe('1.8.2'); expect(res.remediations).toMatchSnapshot({ 'backend/package-lock.json': [ diff --git a/lib/workers/repository/init/vulnerability.ts b/lib/workers/repository/init/vulnerability.ts index 7cf228988eb556..69a5cc44c46c39 100644 --- a/lib/workers/repository/init/vulnerability.ts +++ b/lib/workers/repository/init/vulnerability.ts @@ -208,7 +208,7 @@ export async function detectVulnerabilityAlerts( datasource === PypiDatasource.id ? `==${val.firstPatchedVersion!}` : val.firstPatchedVersion; - const matchFiles = + const matchFileNames = datasource === GoDatasource.id ? [fileName.replace('go.sum', 'go.mod')] : [fileName]; @@ -216,7 +216,7 @@ export async function detectVulnerabilityAlerts( matchDatasources: [datasource], matchPackageNames: [depName], matchCurrentVersion, - matchFiles, + matchFileNames, }; const supportedRemediationFileTypes = ['package-lock.json']; if ( @@ -252,7 +252,7 @@ export async function detectVulnerabilityAlerts( // istanbul ignore if if ( config.transitiveRemediation && - matchRule.matchFiles?.[0] === 'package.json' + matchRule.matchFileNames?.[0] === 'package.json' ) { matchRule.force!.rangeStrategy = 'replace'; } diff --git a/lib/workers/repository/updates/flatten.spec.ts b/lib/workers/repository/updates/flatten.spec.ts index b0c83caf13de27..88e3cd8e61565a 100644 --- a/lib/workers/repository/updates/flatten.spec.ts +++ b/lib/workers/repository/updates/flatten.spec.ts @@ -24,7 +24,7 @@ describe('workers/repository/updates/flatten', () => { automerge: true, }, { - matchPaths: ['frontend/package.json'], + matchFileNames: ['frontend/package.json'], lockFileMaintenance: { enabled: false, }, From 8bc9a6a168887615ecc1a53394700436ce65cbbd Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Mon, 12 Jun 2023 16:02:46 +0200 Subject: [PATCH 09/22] feat(package-rules)!: match packageName for matchPackageNames Closes #20926 --- docs/usage/self-hosted-experimental.md | 9 ---- lib/util/package-rules/index.spec.ts | 41 ------------------- lib/util/package-rules/package-names.spec.ts | 26 ++++++++++++ lib/util/package-rules/package-names.ts | 14 ++++--- .../package-rules/package-patterns.spec.ts | 26 ++++++++++++ lib/util/package-rules/package-patterns.ts | 39 ++++++++++-------- 6 files changed, 83 insertions(+), 72 deletions(-) diff --git a/docs/usage/self-hosted-experimental.md b/docs/usage/self-hosted-experimental.md index 5945938bef3cbf..65b0850ad9826b 100644 --- a/docs/usage/self-hosted-experimental.md +++ b/docs/usage/self-hosted-experimental.md @@ -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. diff --git a/lib/util/package-rules/index.spec.ts b/lib/util/package-rules/index.spec.ts index 0718b5243126a8..e34456503d66d2 100644 --- a/lib/util/package-rules/index.spec.ts +++ b/lib/util/package-rules/index.spec.ts @@ -1210,45 +1210,4 @@ describe('util/package-rules/index', () => { expect(res1.x).toBeUndefined(); expect(res2.x).toBe(1); }); - - describe('test matchers supporting RENOVATE_X_MATCH_PACKAGE_NAMES_MORE', () => { - const processEnvOrg: NodeJS.ProcessEnv = process.env; - - afterEach(() => { - process.env = processEnvOrg; - }); - - it.each` - matcherName | isXEnvEnabled | expected - ${'matchPackageNames'} | ${false} | ${undefined} - ${'matchPackagePatterns'} | ${false} | ${undefined} - ${'matchPackageNames'} | ${true} | ${1} - ${'matchPackagePatterns'} | ${true} | ${1} - `( - 'tests $matcherName selector when experimental env is $isXEnvEnabled (expected res=$expected)', - ({ matcherName, isXEnvEnabled, expected }) => { - if (isXEnvEnabled) { - process.env.RENOVATE_X_MATCH_PACKAGE_NAMES_MORE = 'true'; - } - const config: TestConfig = { - packageRules: [ - { - [matcherName]: ['does-match'], - x: 1, - }, - ], - }; - - const res = applyPackageRules({ - ...config, - depName: 'does-not-match', - packageName: 'does-match', - }); - - applyPackageRules(config); // coverage - - expect(res.x).toBe(expected); - } - ); - }); }); diff --git a/lib/util/package-rules/package-names.spec.ts b/lib/util/package-rules/package-names.spec.ts index 1e6641ab94bc6e..a2d4fbf75787b6 100644 --- a/lib/util/package-rules/package-names.spec.ts +++ b/lib/util/package-rules/package-names.spec.ts @@ -15,6 +15,32 @@ describe('util/package-rules/package-names', () => { ); expect(result).toBeFalse(); }); + + it('should matchPackageName', () => { + const result = packageNameMatcher.matches( + { + depName: 'abc', + packageName: 'def', + }, + { + matchPackageNames: ['def'], + } + ); + expect(result).toBeTrue(); + }); + + it('should fall back to matching depName', () => { + const result = packageNameMatcher.matches( + { + depName: 'abc', + packageName: 'def', + }, + { + matchPackageNames: ['abc'], + } + ); + expect(result).toBeTrue(); + }); }); describe('exclude', () => { diff --git a/lib/util/package-rules/package-names.ts b/lib/util/package-rules/package-names.ts index 385cf164ac4654..2671720099c587 100644 --- a/lib/util/package-rules/package-names.ts +++ b/lib/util/package-rules/package-names.ts @@ -1,5 +1,6 @@ import is from '@sindresorhus/is'; import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; +import { logger } from '../../logger'; import { Matcher } from './base'; export class PackageNameMatcher extends Matcher { @@ -14,15 +15,16 @@ export class PackageNameMatcher extends Matcher { return false; } - if (matchPackageNames.includes(depName)) { + if (matchPackageNames.includes(packageName || depName)) { return true; } - if ( - is.string(packageName) && - process.env.RENOVATE_X_MATCH_PACKAGE_NAMES_MORE - ) { - return matchPackageNames.includes(packageName); + if (matchPackageNames.includes(depName)) { + logger.once.warn( + { packageName, depName }, + 'Use matchDepNames instead of matchPackageNames' + ); + return true; } return false; diff --git a/lib/util/package-rules/package-patterns.spec.ts b/lib/util/package-rules/package-patterns.spec.ts index f5f6614df7cde2..133867f7ee3d86 100644 --- a/lib/util/package-rules/package-patterns.spec.ts +++ b/lib/util/package-rules/package-patterns.spec.ts @@ -15,5 +15,31 @@ describe('util/package-rules/package-patterns', () => { ); expect(result).toBeFalse(); }); + + it('should match packageName', () => { + const result = packageNameMatcher.matches( + { + depName: 'abc', + packageName: 'def', + }, + { + matchPackagePatterns: ['def'], + } + ); + expect(result).toBeTrue(); + }); + + it('should fall back to matching depName', () => { + const result = packageNameMatcher.matches( + { + depName: 'abc', + packageName: 'def', + }, + { + matchPackagePatterns: ['abc'], + } + ); + expect(result).toBeTrue(); + }); }); }); diff --git a/lib/util/package-rules/package-patterns.ts b/lib/util/package-rules/package-patterns.ts index 2b7b29e5807e63..f52ea243460597 100644 --- a/lib/util/package-rules/package-patterns.ts +++ b/lib/util/package-rules/package-patterns.ts @@ -5,6 +5,19 @@ import { regEx } from '../regex'; import { Matcher } from './base'; import { massagePattern } from './utils'; +function matchPatternsAgainstName( + matchPackagePatterns: string[], + name: string +): boolean { + let isMatch = false; + for (const packagePattern of matchPackagePatterns) { + if (isPackagePatternMatch(packagePattern, name)) { + isMatch = true; + } + } + return isMatch; +} + export class PackagePatternsMatcher extends Matcher { override matches( { depName, packageName }: PackageRuleInputConfig, @@ -18,26 +31,20 @@ export class PackagePatternsMatcher extends Matcher { return false; } - const namesToMatchAgainst = [depName]; - if ( - is.string(packageName) && - process.env.RENOVATE_X_MATCH_PACKAGE_NAMES_MORE + matchPatternsAgainstName(matchPackagePatterns, packageName || depName) ) { - namesToMatchAgainst.push(packageName); + return true; } - - let isMatch = false; - for (const packagePattern of matchPackagePatterns) { - if ( - namesToMatchAgainst.some((p) => - isPackagePatternMatch(packagePattern, p) - ) - ) { - isMatch = true; - } + if (matchPatternsAgainstName(matchPackagePatterns, depName)) { + logger.once.warn( + { packageName, depName }, + 'Use matchDepPatterns instead of matchPackagePatterns' + ); + return true; } - return isMatch; + + return false; } override excludes( From fcb67af421747b5e2ee1f1e1aca045d3fcb8a593 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 5 Apr 2023 06:44:55 +0200 Subject: [PATCH 10/22] feat!: allow post upgrade templating by default (#21326) Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/self-hosted-configuration.md | 8 +++----- lib/config/options/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index a46d563be6d49e..7f5a8d29a0cb20 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -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'], }; ``` @@ -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 diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index ce143bdf4c053d..56bbdbc5f1c1be 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -24,9 +24,9 @@ const options: RenovateOptions[] = [ { name: 'allowPostUpgradeCommandTemplating', description: - 'Set this to `true` to allow templating for post-upgrade commands.', + 'Set this to `false` to disable template compilation for post-upgrade commands.', type: 'boolean', - default: false, + default: true, globalOnly: true, }, { From 22ad73cdcfcb92e9e847ee1112d1f7492668203f Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 5 Apr 2023 11:27:22 +0200 Subject: [PATCH 11/22] feat(automerge)!: default to platformAutomerge=true (#21327) Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- docs/usage/configuration-options.md | 10 +++++----- docs/usage/key-concepts/automerge.md | 12 +++++------- lib/config/options/index.ts | 2 +- lib/modules/platform/gitea/index.md | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 8c2cf43b7a9781..f363ae58597d45 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2521,28 +2521,28 @@ If enabled Renovate will pin Docker images or GitHub Actions by means of their S ## platformAutomerge -!!! warning - Before you enable `platformAutomerge` you should enable your Git hosting platform's capabilities to enforce test passing before PR merge. +!!! note + 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. 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. diff --git a/docs/usage/key-concepts/automerge.md b/docs/usage/key-concepts/automerge.md index 579ebc8a9bc948..d4203845fb680c 100644 --- a/docs/usage/key-concepts/automerge.md +++ b/docs/usage/key-concepts/automerge.md @@ -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: @@ -112,7 +111,7 @@ For example: "enabled": true, "automerge": true, "automergeType": "pr", - "platformAutomerge": true + "platformAutomerge": false } } ``` @@ -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", @@ -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 diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 56bbdbc5f1c1be..e0f79c2714730d 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -2613,7 +2613,7 @@ const options: RenovateOptions[] = [ description: `Controls if platform-native auto-merge is used.`, type: 'boolean', supportedPlatforms: ['azure', 'gitea', 'github', 'gitlab'], - default: false, + default: true, }, { name: 'userStrings', diff --git a/lib/modules/platform/gitea/index.md b/lib/modules/platform/gitea/index.md index a6c51d7f8ff797..24d259cf596a37 100644 --- a/lib/modules/platform/gitea/index.md +++ b/lib/modules/platform/gitea/index.md @@ -25,7 +25,7 @@ If you use Gitea packages, add the `read:packages` scope. ## Unsupported platform features/concepts - **Adding reviewers to PRs not supported**: Gitea versions older than `v1.14.0` lack the required API -- **Setting `platformAutomerge` to use platform-native automerge for PRs not supported**: Gitea versions older than `v1.17.0` lack the required API +- **`platformAutomerge` (on by default) for PRs not supported**: Gitea versions older than `v1.17.0` lack the required API - **Git upload filters**: If you're using a Gitea version older than `v1.16.0` then you must enable [clone filters](https://docs.gitea.io/en-us/clone-filters/) ## Features awaiting implementation From 9df6457e5b569fb39f420fe4d41c89ef03c48b67 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Wed, 26 Apr 2023 08:26:13 +0200 Subject: [PATCH 12/22] feat(platform/gitlab)!: prefer `commit_email` (#21122 gitAuthor discover for GitLab now prefers the field `commit_email` over `email`. BREAKING CHANGE: GitLab gitAuthor will change from the account's "email" to "commit_email" if they are different. --- lib/modules/platform/gitlab/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/modules/platform/gitlab/index.ts b/lib/modules/platform/gitlab/index.ts index 8817d5178d7342..bddde9958462fb 100644 --- a/lib/modules/platform/gitlab/index.ts +++ b/lib/modules/platform/gitlab/index.ts @@ -107,12 +107,16 @@ export async function initPlatform({ try { if (!gitAuthor) { const user = ( - await gitlabApi.getJson<{ email: string; name: string; id: number }>( - `user`, - { token } - ) + await gitlabApi.getJson<{ + email: string; + name: string; + id: number; + commit_email?: string; + }>(`user`, { token }) ).body; - platformConfig.gitAuthor = `${user.name} <${user.email}>`; + platformConfig.gitAuthor = `${user.name} <${ + user.commit_email ?? user.email + }>`; } // istanbul ignore if: experimental feature if (process.env.RENOVATE_X_PLATFORM_VERSION) { From c7f0604ba7c9779a6ae5a32359a8c569ae4fb9a9 Mon Sep 17 00:00:00 2001 From: Bastian Gutschke Date: Wed, 26 Apr 2023 19:05:27 +0200 Subject: [PATCH 13/22] fix(post-upgrade-tasks)!: enable dot option for file filters (#21282) Set `{ dot: true }` for minimatch. BREAKING CHANGE: dot files will now be included by default for all minimatch results --- docs/usage/configuration-options.md | 1 + .../repository/update/branch/execute-post-upgrade-commands.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index f363ae58597d45..262f1caa9b430d 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2613,6 +2613,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 diff --git a/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts b/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts index be8b39f4ec65c6..9efb844b0dc2bb 100644 --- a/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts +++ b/lib/workers/repository/update/branch/execute-post-upgrade-commands.ts @@ -106,7 +106,7 @@ export async function postUpgradeCommandsExecutor( for (const relativePath of status.modified.concat(status.not_added)) { for (const pattern of fileFilters) { - if (minimatch(relativePath, pattern)) { + if (minimatch(relativePath, pattern, { dot: true })) { logger.debug( { file: relativePath, pattern }, 'Post-upgrade file saved' @@ -134,7 +134,7 @@ export async function postUpgradeCommandsExecutor( for (const relativePath of status.deleted || []) { for (const pattern of fileFilters) { - if (minimatch(relativePath, pattern)) { + if (minimatch(relativePath, pattern, { dot: true })) { logger.debug( { file: relativePath, pattern }, 'Post-upgrade file removed' From be162f9facdba9ca8d55531b494a72d6703ce037 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 5 May 2023 19:47:16 +0200 Subject: [PATCH 14/22] feat(npm)!: disable rollbackPrs for npm by default (#21970) --- docs/usage/configuration-options.md | 5 ++--- lib/config/index.spec.ts | 1 - lib/modules/manager/npm/index.ts | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 262f1caa9b430d..7b8fe488db7364 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -3286,9 +3286,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 diff --git a/lib/config/index.spec.ts b/lib/config/index.spec.ts index 001ea8c8b53488..94e6822cf72dfc 100644 --- a/lib/config/index.spec.ts +++ b/lib/config/index.spec.ts @@ -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?$']], diff --git a/lib/modules/manager/npm/index.ts b/lib/modules/manager/npm/index.ts index 3ac8a7f281b4ea..9d309bd8a23348 100644 --- a/lib/modules/manager/npm/index.ts +++ b/lib/modules/manager/npm/index.ts @@ -17,7 +17,6 @@ export const supportsLockFileMaintenance = true; export const defaultConfig = { fileMatch: ['(^|/)package\\.json$'], - rollbackPrs: true, versioning: npmVersioning.id, digest: { prBodyDefinitions: { From 775eb9961f0583f168693e89c72c832588601bc8 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sun, 7 May 2023 22:07:47 +0200 Subject: [PATCH 15/22] fix(presets)!: remove compatibility:additionalBranchPrefix (#22015) --- lib/config/presets/common.ts | 1 + lib/config/presets/internal/compatibility.ts | 28 -------------------- lib/config/presets/internal/index.ts | 2 -- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 lib/config/presets/internal/compatibility.ts diff --git a/lib/config/presets/common.ts b/lib/config/presets/common.ts index 8ae2839ed0b5c7..8e0a6a03327b97 100644 --- a/lib/config/presets/common.ts +++ b/lib/config/presets/common.ts @@ -12,6 +12,7 @@ export const removedPresets: Record = { ':masterIssueApproval': ':dependencyDashboardApproval', ':switchToGradleLite': null, ':unpublishSafe': 'npm:unpublishSafe', + 'compatibility:additionalBranchPrefix': null, 'config:application': 'config:js-app', 'config:base-js': 'config:base', 'config:library': 'config:js-lib', diff --git a/lib/config/presets/internal/compatibility.ts b/lib/config/presets/internal/compatibility.ts deleted file mode 100644 index 57e12a8d82fb2e..00000000000000 --- a/lib/config/presets/internal/compatibility.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { Preset } from '../types'; - -/* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */ - -export const presets: Record = { - additionalBranchPrefix: { - buildkite: { - additionalBranchPrefix: 'buildkite-', - }, - cargo: { - additionalBranchPrefix: 'rust-', - }, - description: - 'Backwards-compatibility preset to restore `additionalBranchPrefix` settings for multiple managers which were removed in Renovate `v25`.', - docker: { - additionalBranchPrefix: 'docker-', - }, - homebrew: { - additionalBranchPrefix: 'homebrew-', - }, - packageRules: [ - { - additionalBranchPrefix: 'helm-', - matchDatasources: ['helm'], - }, - ], - }, -}; diff --git a/lib/config/presets/internal/index.ts b/lib/config/presets/internal/index.ts index 63765664558b69..e37788d17fc4c8 100644 --- a/lib/config/presets/internal/index.ts +++ b/lib/config/presets/internal/index.ts @@ -1,5 +1,4 @@ import type { Preset, PresetConfig } from '../types'; -import * as compatibilityPreset from './compatibility'; import * as configPreset from './config'; import * as defaultPreset from './default'; import * as dockerPreset from './docker'; @@ -17,7 +16,6 @@ import * as workaroundsPreset from './workarounds'; /* eslint sort-keys: ["error", "asc", {caseSensitive: false, natural: true}] */ export const groups: Record> = { - compatibility: compatibilityPreset.presets, config: configPreset.presets, default: defaultPreset.presets, docker: dockerPreset.presets, From ff724cf190f9cd305fe9e7dbfab42425f019a4a4 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 24 May 2023 08:07:00 +0200 Subject: [PATCH 16/22] feat(package-rules)!: remove fuzzy matchPaths matching (#22394) --- docs/usage/configuration-options.md | 5 ----- lib/config/options/index.ts | 2 +- lib/util/package-rules/index.spec.ts | 2 +- lib/util/package-rules/paths.spec.ts | 11 ++--------- lib/util/package-rules/paths.ts | 20 +++----------------- 5 files changed, 7 insertions(+), 33 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 7b8fe488db7364..dccc8588244373 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -2295,11 +2295,6 @@ The following matches any file in directories starting with `app/`: } ``` - -!!! 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: diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index e0f79c2714730d..ee52b5669813cc 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1307,7 +1307,7 @@ const options: RenovateOptions[] = [ { name: 'matchPaths', description: - 'List of strings or glob patterns to match against package files. Only works inside a `packageRules` object.', + 'List of glob patterns to match against package files. Only works inside a `packageRules` object.', type: 'array', subType: 'string', stage: 'repository', diff --git a/lib/util/package-rules/index.spec.ts b/lib/util/package-rules/index.spec.ts index 9e6f48f4b38d11..ecfeee4914794c 100644 --- a/lib/util/package-rules/index.spec.ts +++ b/lib/util/package-rules/index.spec.ts @@ -989,7 +989,7 @@ describe('util/package-rules/index', () => { ...config, depName: 'test', }); - expect(res3.x).toBeDefined(); + expect(res3.x).toBeUndefined(); }); it('empty rules', () => { diff --git a/lib/util/package-rules/paths.spec.ts b/lib/util/package-rules/paths.spec.ts index 9b0c1db55484aa..4e0bfed3567995 100644 --- a/lib/util/package-rules/paths.spec.ts +++ b/lib/util/package-rules/paths.spec.ts @@ -17,7 +17,7 @@ describe('util/package-rules/paths', () => { expect(result).toBeFalse(); }); - it('should return true and log warning on partial match only', () => { + it('should return false on partial match only', () => { const result = pathsMatcher.matches( { packageFile: 'opentelemetry/http/package.json', @@ -26,14 +26,7 @@ describe('util/package-rules/paths', () => { matchPaths: ['opentelemetry/http'], } ); - expect(result).toBeTrue(); - expect(logger.warn).toHaveBeenCalledWith( - { - packageFile: 'opentelemetry/http/package.json', - rulePath: 'opentelemetry/http', - }, - 'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.' - ); + expect(result).toBeFalse(); }); it('should return true and not log warning on partial and glob match', () => { diff --git a/lib/util/package-rules/paths.ts b/lib/util/package-rules/paths.ts index 7bd882c56966e0..7fa70aaa9ef991 100644 --- a/lib/util/package-rules/paths.ts +++ b/lib/util/package-rules/paths.ts @@ -1,7 +1,6 @@ import is from '@sindresorhus/is'; import { minimatch } from 'minimatch'; import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; -import { logger } from '../../logger'; import { Matcher } from './base'; export class PathsMatcher extends Matcher { @@ -16,21 +15,8 @@ export class PathsMatcher extends Matcher { return false; } - return matchPaths.some((rulePath) => { - if (minimatch(packageFile, rulePath, { dot: true })) { - return true; - } - - if (packageFile.includes(rulePath)) { - logger.warn( - { - rulePath, - packageFile, - }, - 'Partial matches for `matchPaths` are deprecated. Please use a minimatch glob pattern or switch to `matchFiles` if you need exact matching.' - ); - return true; - } - }); + return matchPaths.some((rulePath) => + minimatch(packageFile, rulePath, { dot: true }) + ); } } From 77cf950f93d8f49f2a15a28a9c146f9f68998911 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Thu, 25 May 2023 17:46:28 +0200 Subject: [PATCH 17/22] feat!: merge matchPaths and matchFiles into matchFileNames (#22406) --- docs/usage/configuration-options.md | 77 +++++++++---------- .../__snapshots__/migration.spec.ts.snap | 16 ++-- lib/config/migration.spec.ts | 30 +++++++- .../custom/automerge-major-migration.spec.ts | 4 +- .../custom/automerge-minor-migration.spec.ts | 4 +- .../custom/automerge-patch-migration.spec.ts | 4 +- .../custom/package-rules-migration.spec.ts | 2 +- .../custom/package-rules-migration.ts | 4 +- lib/config/options/index.ts | 13 +--- lib/config/presets/internal/default.ts | 2 +- lib/config/types.ts | 4 +- lib/config/validation.ts | 3 +- lib/modules/manager/npm/extract/index.ts | 2 +- lib/util/package-rules/files.spec.ts | 6 +- lib/util/package-rules/files.ts | 18 +++-- lib/util/package-rules/index.spec.ts | 6 +- lib/util/package-rules/matchers.ts | 6 +- lib/util/package-rules/paths.spec.ts | 45 ----------- lib/util/package-rules/paths.ts | 22 ------ .../__snapshots__/vulnerability.spec.ts.snap | 10 +-- .../repository/init/vulnerability.spec.ts | 2 +- lib/workers/repository/init/vulnerability.ts | 6 +- .../repository/updates/flatten.spec.ts | 2 +- 23 files changed, 118 insertions(+), 170 deletions(-) delete mode 100644 lib/util/package-rules/paths.spec.ts delete mode 100644 lib/util/package-rules/paths.ts diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index dccc8588244373..dcfb385674416e 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -1871,28 +1871,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 } ] @@ -2187,23 +2187,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 @@ -2263,38 +2290,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" - } - ] -} -``` - ### matchSourceUrlPrefixes Here's an example of where you use this to group together all packages from the `renovatebot` GitHub org: diff --git a/lib/config/__snapshots__/migration.spec.ts.snap b/lib/config/__snapshots__/migration.spec.ts.snap index 572cc3bbdb1787..c4df79d9deb94f 100644 --- a/lib/config/__snapshots__/migration.spec.ts.snap +++ b/lib/config/__snapshots__/migration.spec.ts.snap @@ -164,7 +164,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1` "extends": [ "node", ], - "matchPaths": [ + "matchFileNames": [ "node/**", ], }, @@ -211,7 +211,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates config 1` "extends": [ "foo", ], - "matchPaths": [ + "matchFileNames": [ "examples/**", ], }, @@ -293,7 +293,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack "matchDepTypes": [ "devDependencies", ], - "matchPaths": [ + "matchFileNames": [ "package.json", ], "rangeStrategy": "pin", @@ -302,7 +302,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates more pack "matchDepTypes": [ "dependencies", ], - "matchPaths": [ + "matchFileNames": [ "package.json", ], "rangeStrategy": "pin", @@ -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", @@ -347,7 +347,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi "matchDepTypes": [ "devDependencies", ], - "matchPaths": [ + "matchFileNames": [ "other/package.json", ], "rangeStrategy": "pin", @@ -356,7 +356,7 @@ exports[`config/migration migrateConfig(config, parentConfig) migrates packageFi "matchDepTypes": [ "dependencies", ], - "matchPaths": [ + "matchFileNames": [ "other/package.json", ], "rangeStrategy": "pin", diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index fcb40a6609d2d6..eae90ddd53c9fe 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -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', () => { diff --git a/lib/config/migrations/custom/automerge-major-migration.spec.ts b/lib/config/migrations/custom/automerge-major-migration.spec.ts index 0d2a9a7d30ba60..9dd5ebd21c87d0 100644 --- a/lib/config/migrations/custom/automerge-major-migration.spec.ts +++ b/lib/config/migrations/custom/automerge-major-migration.spec.ts @@ -19,13 +19,13 @@ describe('config/migrations/custom/automerge-major-migration', () => { { automergeMajor: 'some-value', major: { - matchFiles: ['test'], + matchFileNames: ['test'], }, }, { major: { automerge: true, - matchFiles: ['test'], + matchFileNames: ['test'], }, } ); diff --git a/lib/config/migrations/custom/automerge-minor-migration.spec.ts b/lib/config/migrations/custom/automerge-minor-migration.spec.ts index 9597466a7b3682..5ce417773f84c6 100644 --- a/lib/config/migrations/custom/automerge-minor-migration.spec.ts +++ b/lib/config/migrations/custom/automerge-minor-migration.spec.ts @@ -19,13 +19,13 @@ describe('config/migrations/custom/automerge-minor-migration', () => { { automergeMinor: 'some-value', minor: { - matchFiles: ['test'], + matchFileNames: ['test'], }, }, { minor: { automerge: true, - matchFiles: ['test'], + matchFileNames: ['test'], }, } ); diff --git a/lib/config/migrations/custom/automerge-patch-migration.spec.ts b/lib/config/migrations/custom/automerge-patch-migration.spec.ts index bc7014fa541f61..124f599fe921b3 100644 --- a/lib/config/migrations/custom/automerge-patch-migration.spec.ts +++ b/lib/config/migrations/custom/automerge-patch-migration.spec.ts @@ -19,13 +19,13 @@ describe('config/migrations/custom/automerge-patch-migration', () => { { automergePatch: 'some-value', patch: { - matchFiles: ['test'], + matchFileNames: ['test'], }, }, { patch: { automerge: true, - matchFiles: ['test'], + matchFileNames: ['test'], }, } ); diff --git a/lib/config/migrations/custom/package-rules-migration.spec.ts b/lib/config/migrations/custom/package-rules-migration.spec.ts index e77f20476fab5e..b5f6afaf7a016a 100644 --- a/lib/config/migrations/custom/package-rules-migration.spec.ts +++ b/lib/config/migrations/custom/package-rules-migration.spec.ts @@ -48,7 +48,7 @@ describe('config/migrations/custom/package-rules-migration', () => { { packageRules: [ { - matchPaths: [], + matchFileNames: [], packgageRules: { languages: ['javascript'], }, diff --git a/lib/config/migrations/custom/package-rules-migration.ts b/lib/config/migrations/custom/package-rules-migration.ts index e3be4c4c910ac0..9da8469fe3c23c 100644 --- a/lib/config/migrations/custom/package-rules-migration.ts +++ b/lib/config/migrations/custom/package-rules-migration.ts @@ -2,7 +2,9 @@ import type { PackageRule } from '../../types'; import { AbstractMigration } from '../base/abstract-migration'; export const renameMap = { - paths: 'matchPaths', + matchFiles: 'matchFileNames', + matchPaths: 'matchFileNames', + paths: 'matchFileNames', languages: 'matchLanguages', baseBranchList: 'matchBaseBranches', managers: 'matchManagers', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index ee52b5669813cc..f9033c008b7400 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -1294,7 +1294,7 @@ const options: RenovateOptions[] = [ env: false, }, { - name: 'matchFiles', + name: 'matchFileNames', description: 'List of strings to do an exact match against package and lock files with full path. Only works inside a `packageRules` object.', type: 'array', @@ -1304,17 +1304,6 @@ const options: RenovateOptions[] = [ cli: false, env: false, }, - { - name: 'matchPaths', - description: - 'List of glob patterns to match against package files. Only works inside a `packageRules` object.', - type: 'array', - subType: 'string', - stage: 'repository', - parent: 'packageRules', - cli: false, - env: false, - }, // Version behaviour { name: 'allowedVersions', diff --git a/lib/config/presets/internal/default.ts b/lib/config/presets/internal/default.ts index 4a7ca0f2577a20..f65b0c48c93eb9 100644 --- a/lib/config/presets/internal/default.ts +++ b/lib/config/presets/internal/default.ts @@ -361,7 +361,7 @@ export const presets: Record = { 'Use semanticCommitType `{{arg0}}` for all package files matching path `{{arg1}}`.', packageRules: [ { - matchPaths: ['{{arg0}}'], + matchFileNames: ['{{arg0}}'], semanticCommitType: '{{arg1}}', }, ], diff --git a/lib/config/types.ts b/lib/config/types.ts index ac915cd80304f5..6be1fd39ae7fa2 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -315,8 +315,7 @@ export interface PackageRule Record { description?: string | string[]; isVulnerabilityAlert?: boolean; - matchFiles?: string[]; - matchPaths?: string[]; + matchFileNames?: string[]; matchLanguages?: string[]; matchBaseBranches?: string[]; matchManagers?: string | string[]; @@ -461,6 +460,7 @@ export type RenovateOptions = export interface PackageRuleInputConfig extends Record { versioning?: string; packageFile?: string; + lockFiles?: string[]; depType?: string; depTypes?: string[]; depName?: string; diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 34797bbb8b30f4..13ddfd300706a7 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -302,8 +302,7 @@ export async function validateConfig( } const selectors = [ - 'matchFiles', - 'matchPaths', + 'matchFileNames', 'matchLanguages', 'matchBaseBranches', 'matchManagers', diff --git a/lib/modules/manager/npm/extract/index.ts b/lib/modules/manager/npm/extract/index.ts index 00c3fb7d3e0444..467cdef6b849fc 100644 --- a/lib/modules/manager/npm/extract/index.ts +++ b/lib/modules/manager/npm/extract/index.ts @@ -64,7 +64,7 @@ export async function extractPackageFile( const error = new Error(CONFIG_VALIDATION); error.validationSource = packageFile; error.validationError = - 'Nested package.json must not contain renovate configuration. Please use `packageRules` with `matchPaths` in your main config instead.'; + 'Nested package.json must not contain Renovate configuration. Please use `packageRules` with `matchFileNames` in your main config instead.'; throw error; } const packageJsonName = packageJson.name; diff --git a/lib/util/package-rules/files.spec.ts b/lib/util/package-rules/files.spec.ts index 374d2650355465..ac30c31247f00d 100644 --- a/lib/util/package-rules/files.spec.ts +++ b/lib/util/package-rules/files.spec.ts @@ -1,7 +1,7 @@ -import { FilesMatcher } from './files'; +import { FileNamesMatcher } from './files'; describe('util/package-rules/files', () => { - const fileMatcher = new FilesMatcher(); + const fileMatcher = new FileNamesMatcher(); describe('match', () => { it('should return false if packageFile is not defined', () => { @@ -10,7 +10,7 @@ describe('util/package-rules/files', () => { packageFile: undefined, }, { - matchFiles: ['frontend/package.json'], + matchFileNames: ['frontend/package.json'], } ); expect(result).toBeFalse(); diff --git a/lib/util/package-rules/files.ts b/lib/util/package-rules/files.ts index e1ab76f4d70192..bb6cd57a3c5c90 100644 --- a/lib/util/package-rules/files.ts +++ b/lib/util/package-rules/files.ts @@ -1,23 +1,27 @@ import is from '@sindresorhus/is'; +import { minimatch } from 'minimatch'; import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; import { Matcher } from './base'; -export class FilesMatcher extends Matcher { +export class FileNamesMatcher extends Matcher { override matches( { packageFile, lockFiles }: PackageRuleInputConfig, - { matchFiles }: PackageRule + { matchFileNames }: PackageRule ): boolean | null { - if (is.undefined(matchFiles)) { + if (is.undefined(matchFileNames)) { return null; } if (is.undefined(packageFile)) { return false; } - return matchFiles.some( - (fileName) => - packageFile === fileName || - (is.array(lockFiles) && lockFiles?.includes(fileName)) + return matchFileNames.some( + (matchFileName) => + minimatch(packageFile, matchFileName, { dot: true }) || + (is.array(lockFiles) && + lockFiles.some((lockFile) => + minimatch(lockFile, matchFileName, { dot: true }) + )) ); } } diff --git a/lib/util/package-rules/index.spec.ts b/lib/util/package-rules/index.spec.ts index ecfeee4914794c..0718b5243126a8 100644 --- a/lib/util/package-rules/index.spec.ts +++ b/lib/util/package-rules/index.spec.ts @@ -930,7 +930,7 @@ describe('util/package-rules/index', () => { packageFile: 'examples/foo/package.json', packageRules: [ { - matchFiles: ['package.json'], + matchFileNames: ['package.json'], x: 1, }, ], @@ -954,7 +954,7 @@ describe('util/package-rules/index', () => { lockFiles: ['yarn.lock'], packageRules: [ { - matchFiles: ['yarn.lock'], + matchFileNames: ['yarn.lock'], x: 1, }, ], @@ -968,7 +968,7 @@ describe('util/package-rules/index', () => { packageFile: 'examples/foo/package.json', packageRules: [ { - matchPaths: ['examples/**', 'lib/'], + matchFileNames: ['examples/**', 'lib/'], x: 1, }, ], diff --git a/lib/util/package-rules/matchers.ts b/lib/util/package-rules/matchers.ts index 2a11fdd8180d58..dd2672c777b678 100644 --- a/lib/util/package-rules/matchers.ts +++ b/lib/util/package-rules/matchers.ts @@ -5,14 +5,13 @@ import { DatasourcesMatcher } from './datasources'; import { DepNameMatcher } from './dep-names'; import { DepPatternsMatcher } from './dep-patterns'; import { DepTypesMatcher } from './dep-types'; -import { FilesMatcher } from './files'; +import { FileNamesMatcher } from './files'; import { LanguagesMatcher } from './languages'; import { ManagersMatcher } from './managers'; import { MergeConfidenceMatcher } from './merge-confidence'; import { PackageNameMatcher } from './package-names'; import { PackagePatternsMatcher } from './package-patterns'; import { PackagePrefixesMatcher } from './package-prefixes'; -import { PathsMatcher } from './paths'; import { SourceUrlPrefixesMatcher } from './sourceurl-prefixes'; import { SourceUrlsMatcher } from './sourceurls'; import type { MatcherApi } from './types'; @@ -29,8 +28,7 @@ matchers.push([ new PackagePatternsMatcher(), new PackagePrefixesMatcher(), ]); -matchers.push([new FilesMatcher()]); -matchers.push([new PathsMatcher()]); +matchers.push([new FileNamesMatcher()]); matchers.push([new DepTypesMatcher()]); matchers.push([new LanguagesMatcher()]); matchers.push([new BaseBranchesMatcher()]); diff --git a/lib/util/package-rules/paths.spec.ts b/lib/util/package-rules/paths.spec.ts deleted file mode 100644 index 4e0bfed3567995..00000000000000 --- a/lib/util/package-rules/paths.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { logger } from '../../logger'; -import { PathsMatcher } from './paths'; - -describe('util/package-rules/paths', () => { - const pathsMatcher = new PathsMatcher(); - - describe('match', () => { - it('should return false if packageFile is not defined', () => { - const result = pathsMatcher.matches( - { - packageFile: undefined, - }, - { - matchPaths: ['opentelemetry/http'], - } - ); - expect(result).toBeFalse(); - }); - - it('should return false on partial match only', () => { - const result = pathsMatcher.matches( - { - packageFile: 'opentelemetry/http/package.json', - }, - { - matchPaths: ['opentelemetry/http'], - } - ); - expect(result).toBeFalse(); - }); - - it('should return true and not log warning on partial and glob match', () => { - const result = pathsMatcher.matches( - { - packageFile: 'package.json', - }, - { - matchPaths: ['package.json'], - } - ); - expect(result).toBeTrue(); - expect(logger.warn).not.toHaveBeenCalled(); - }); - }); -}); diff --git a/lib/util/package-rules/paths.ts b/lib/util/package-rules/paths.ts deleted file mode 100644 index 7fa70aaa9ef991..00000000000000 --- a/lib/util/package-rules/paths.ts +++ /dev/null @@ -1,22 +0,0 @@ -import is from '@sindresorhus/is'; -import { minimatch } from 'minimatch'; -import type { PackageRule, PackageRuleInputConfig } from '../../config/types'; -import { Matcher } from './base'; - -export class PathsMatcher extends Matcher { - override matches( - { packageFile }: PackageRuleInputConfig, - { matchPaths }: PackageRule - ): boolean | null { - if (is.undefined(matchPaths)) { - return null; - } - if (is.undefined(packageFile)) { - return false; - } - - return matchPaths.some((rulePath) => - minimatch(packageFile, rulePath, { dot: true }) - ); - } -} diff --git a/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap b/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap index e731e34f30e745..1c6a552c0026b5 100644 --- a/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap +++ b/lib/workers/repository/init/__snapshots__/vulnerability.spec.ts.snap @@ -7,7 +7,7 @@ exports[`workers/repository/init/vulnerability detectVulnerabilityAlerts() retur "matchDatasources": [ "npm", ], - "matchFiles": [ + "matchFileNames": [ "backend/package-lock.json", ], "matchPackageNames": [ @@ -31,7 +31,7 @@ exports[`workers/repository/init/vulnerability detectVulnerabilityAlerts() retur "matchDatasources": [ "go", ], - "matchFiles": [ + "matchFileNames": [ "go.mod", ], "matchPackageNames": [ @@ -61,7 +61,7 @@ go", "matchDatasources": [ "github-tags", ], - "matchFiles": [ + "matchFileNames": [ ".github/workflows/build.yaml", ], "matchPackageNames": [ @@ -91,7 +91,7 @@ actions", "matchDatasources": [ "pypi", ], - "matchFiles": [ + "matchFileNames": [ "requirements.txt", ], "matchPackageNames": [ @@ -136,7 +136,7 @@ Ansible before versions 2.1.4, 2.2.1 is vulnerable to an improper input validati "matchDatasources": [ "maven", ], - "matchFiles": [ + "matchFileNames": [ "pom.xml", ], "matchPackageNames": [ diff --git a/lib/workers/repository/init/vulnerability.spec.ts b/lib/workers/repository/init/vulnerability.spec.ts index 3fd52b0116e2d3..a5edda9408f63c 100644 --- a/lib/workers/repository/init/vulnerability.spec.ts +++ b/lib/workers/repository/init/vulnerability.spec.ts @@ -328,7 +328,7 @@ describe('workers/repository/init/vulnerability', () => { const res = await detectVulnerabilityAlerts(config); expect(res.packageRules).toMatchSnapshot(); expect(res.packageRules).toHaveLength(5); - expect(res.packageRules?.[1]?.matchFiles?.[0]).toBe('go.mod'); + expect(res.packageRules?.[1]?.matchFileNames?.[0]).toBe('go.mod'); expect(res.packageRules?.[2]?.matchCurrentVersion).toBe('1.8.2'); expect(res.remediations).toMatchSnapshot({ 'backend/package-lock.json': [ diff --git a/lib/workers/repository/init/vulnerability.ts b/lib/workers/repository/init/vulnerability.ts index 7cf228988eb556..69a5cc44c46c39 100644 --- a/lib/workers/repository/init/vulnerability.ts +++ b/lib/workers/repository/init/vulnerability.ts @@ -208,7 +208,7 @@ export async function detectVulnerabilityAlerts( datasource === PypiDatasource.id ? `==${val.firstPatchedVersion!}` : val.firstPatchedVersion; - const matchFiles = + const matchFileNames = datasource === GoDatasource.id ? [fileName.replace('go.sum', 'go.mod')] : [fileName]; @@ -216,7 +216,7 @@ export async function detectVulnerabilityAlerts( matchDatasources: [datasource], matchPackageNames: [depName], matchCurrentVersion, - matchFiles, + matchFileNames, }; const supportedRemediationFileTypes = ['package-lock.json']; if ( @@ -252,7 +252,7 @@ export async function detectVulnerabilityAlerts( // istanbul ignore if if ( config.transitiveRemediation && - matchRule.matchFiles?.[0] === 'package.json' + matchRule.matchFileNames?.[0] === 'package.json' ) { matchRule.force!.rangeStrategy = 'replace'; } diff --git a/lib/workers/repository/updates/flatten.spec.ts b/lib/workers/repository/updates/flatten.spec.ts index 68e14d4aaf1d7f..acf624181513b3 100644 --- a/lib/workers/repository/updates/flatten.spec.ts +++ b/lib/workers/repository/updates/flatten.spec.ts @@ -25,7 +25,7 @@ describe('workers/repository/updates/flatten', () => { automerge: true, }, { - matchPaths: ['frontend/package.json'], + matchFileNames: ['frontend/package.json'], lockFileMaintenance: { enabled: false, }, From 136eece977a3827e2bd329744bec7477ab0bdfc7 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Mon, 12 Jun 2023 21:22:07 +0545 Subject: [PATCH 18/22] feat!: remove `skipInstalls` config option (#22648) --- docs/usage/self-hosted-configuration.md | 8 +------ lib/config/options/index.ts | 8 ------- lib/config/types.ts | 1 - lib/modules/manager/npm/extract/index.spec.ts | 2 +- lib/modules/manager/npm/extract/index.ts | 22 ++++++++----------- lib/modules/manager/types.ts | 6 ++--- .../extract-fingerprint-config.spec.ts | 4 ---- 7 files changed, 14 insertions(+), 37 deletions(-) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index 7f5a8d29a0cb20..52fff74b4e526b 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -29,7 +29,7 @@ module.exports = { In the `renovate.json` file, define the commands and files to be included in the final commit. -The command to install dependencies (`npm ci --ignore-scripts`) is needed because, by default, the installation of dependencies is skipped (see the `skipInstalls` global option). +The command to install dependencies (`npm ci --ignore-scripts`) is needed because, by default, the installation of dependencies is skipped. ```json { @@ -798,12 +798,6 @@ It could then be used in a repository config or preset like so: Secret names must start with an upper or lower case character and can have only characters, digits, or underscores. -## 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. -If this is set to false, then a full install of modules will be done. -This is currently applicable to `npm` and `lerna`/`npm` only, and only used in cases where bugs in `npm` result in incorrect lock files being updated. - ## token ## unicodeEmoji diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index f9033c008b7400..4eddf0660922c3 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -729,14 +729,6 @@ const options: RenovateOptions[] = [ description: 'Set to `false` to disable lock file updating.', type: 'boolean', }, - { - name: 'skipInstalls', - description: - 'Skip installing modules/dependencies if lock file updating is possible without a full install.', - type: 'boolean', - default: null, - globalOnly: true, - }, { name: 'autodiscover', description: 'Autodiscover all repositories.', diff --git a/lib/config/types.ts b/lib/config/types.ts index 6be1fd39ae7fa2..b822ec436f7727 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -262,7 +262,6 @@ export interface RenovateConfig secrets?: Record; constraints?: Record; - skipInstalls?: boolean | null; constraintsFiltering?: ConstraintsFilter; diff --git a/lib/modules/manager/npm/extract/index.spec.ts b/lib/modules/manager/npm/extract/index.spec.ts index d43e4702551c73..170f4ff30d151a 100644 --- a/lib/modules/manager/npm/extract/index.spec.ts +++ b/lib/modules/manager/npm/extract/index.spec.ts @@ -9,7 +9,7 @@ const realFs = jest.requireActual( ); const defaultExtractConfig = { - skipInstalls: null, + skipInstalls: true, } satisfies ExtractConfig; const input01Content = Fixtures.get('inputs/01.json', '..'); diff --git a/lib/modules/manager/npm/extract/index.ts b/lib/modules/manager/npm/extract/index.ts index 467cdef6b849fc..6db976a92e5316 100644 --- a/lib/modules/manager/npm/extract/index.ts +++ b/lib/modules/manager/npm/extract/index.ts @@ -473,19 +473,15 @@ export async function extractPackageFile( return null; } } - let skipInstalls = config.skipInstalls; - if (skipInstalls === null) { - if ((hasFancyRefs && lockFiles.npmLock) || yarnZeroInstall) { - // https://github.com/npm/cli/issues/1432 - // Explanation: - // - npm install --package-lock-only is buggy for transitive deps in file: and npm: references - // - So we set skipInstalls to false if file: or npm: refs are found *and* the user hasn't explicitly set the value already - // - Also, do not skip install if Yarn zero-install is used - logger.debug('Automatically setting skipInstalls to false'); - skipInstalls = false; - } else { - skipInstalls = true; - } + let skipInstalls = true; // skip installing modules by default + if ((hasFancyRefs && lockFiles.npmLock) || yarnZeroInstall) { + // https://github.com/npm/cli/issues/1432 + // Explanation: + // - npm install --package-lock-only is buggy for transitive deps in file: and npm: references + // - So we set skipInstalls to false if file: or npm: refs are found *and* the user hasn't explicitly set the value already + // - Also, do not skip install if Yarn zero-install is used + logger.debug('Automatically setting skipInstalls to false'); + skipInstalls = false; } return { diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index 311288b6bf9369..f037a97f1afaef 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -20,7 +20,7 @@ export interface ExtractConfig extends CustomExtractConfig { registryAliases?: Record; npmrc?: string; npmrcMerge?: boolean; - skipInstalls?: boolean | null; + skipInstalls?: boolean; } export interface CustomExtractConfig extends RegexManagerTemplates { @@ -64,7 +64,7 @@ export interface PackageFileContent> lockFiles?: string[]; npmrc?: string; packageFileVersion?: string; - skipInstalls?: boolean | null; + skipInstalls?: boolean; matchStrings?: string[]; matchStringsStrategy?: MatchStringsStrategy; } @@ -274,7 +274,7 @@ export interface PostUpdateConfig> ManagerData { updatedPackageFiles?: FileChange[]; postUpdateOptions?: string[]; - skipInstalls?: boolean | null; + skipInstalls?: boolean; ignoreScripts?: boolean; packageFile?: string; diff --git a/lib/workers/repository/extract/extract-fingerprint-config.spec.ts b/lib/workers/repository/extract/extract-fingerprint-config.spec.ts index c0ac40404f4e46..e3d252ba282147 100644 --- a/lib/workers/repository/extract/extract-fingerprint-config.spec.ts +++ b/lib/workers/repository/extract/extract-fingerprint-config.spec.ts @@ -47,7 +47,6 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { registryAliases: { notStable: 'http://some.link.2', }, - skipInstalls: null, }); expect( fingerprintConfig.managers.find((manager) => manager.manager === 'regex') @@ -66,7 +65,6 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { registryAliases: { stable: 'http://some.link', }, - skipInstalls: null, }); }); @@ -90,7 +88,6 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { npmrc: 'some-string', npmrcMerge: true, registryAliases: {}, - skipInstalls: null, }); expect( fingerprintConfig.managers.find( @@ -109,7 +106,6 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { npmrc: 'some-string', npmrcMerge: true, registryAliases: {}, - skipInstalls: null, }); expect( fingerprintConfig.managers.find((manager) => manager.manager === 'regex') From 1eb2533276b388957f17dc15901bf8441fde9173 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sat, 17 Jun 2023 13:04:05 +0545 Subject: [PATCH 19/22] feat!: replace `dockerImagePrefix` with `dockerSidecarImage` (#22708) Co-authored-by: Rhys Arkins Co-authored-by: Michael Kriese --- docs/usage/self-hosted-configuration.md | 10 +++--- lib/config/global.ts | 2 +- lib/config/options/index.ts | 6 ++-- lib/config/types.ts | 2 +- lib/modules/manager/bundler/artifacts.spec.ts | 29 +++++++-------- lib/modules/manager/cargo/artifacts.spec.ts | 5 +-- .../__snapshots__/artifacts.spec.ts.snap | 8 ++--- .../manager/cocoapods/artifacts.spec.ts | 5 +-- .../manager/composer/artifacts.spec.ts | 5 +-- lib/modules/manager/gomod/artifacts.spec.ts | 35 ++++++++++--------- .../manager/gradle-wrapper/artifacts.spec.ts | 10 ++++-- lib/modules/manager/gradle/artifacts.spec.ts | 7 ++-- .../manager/helmfile/artifacts.spec.ts | 5 +-- .../__snapshots__/artifacts.spec.ts.snap | 8 ++--- lib/modules/manager/helmv3/artifacts.spec.ts | 12 +++++-- .../manager/maven-wrapper/artifacts.spec.ts | 10 ++++-- .../mix/__snapshots__/artifacts.spec.ts.snap | 6 ++-- lib/modules/manager/mix/artifacts.spec.ts | 18 ++++++++-- lib/modules/manager/nix/artifacts.spec.ts | 14 +++++--- .../manager/npm/post-update/lerna.spec.ts | 10 ++++-- .../manager/npm/post-update/npm.spec.ts | 5 +-- .../manager/npm/post-update/pnpm.spec.ts | 5 +-- .../manager/npm/post-update/yarn.spec.ts | 5 +-- lib/modules/manager/nuget/artifacts.spec.ts | 10 ++++-- lib/modules/manager/pep621/artifacts.spec.ts | 10 ++++-- .../manager/pep621/processors/pdm.spec.ts | 10 ++++-- .../manager/pip-compile/artifacts.spec.ts | 14 +++++--- .../pip_requirements/artifacts.spec.ts | 10 ++++-- .../__snapshots__/artifacts.spec.ts.snap | 16 ++++----- lib/modules/manager/pipenv/artifacts.spec.ts | 6 +++- lib/modules/manager/poetry/artifacts.spec.ts | 20 +++++++---- lib/modules/manager/pub/artifacts.spec.ts | 10 ++++-- lib/util/exec/docker/index.spec.ts | 9 +++-- lib/util/exec/docker/index.ts | 8 ++--- lib/util/exec/index.spec.ts | 10 ++++-- renovate.json | 9 +++++ 36 files changed, 231 insertions(+), 133 deletions(-) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index 52fff74b4e526b..da534135fb132d 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -326,17 +326,17 @@ For example, if you set `dockerChildPrefix=myprefix_` then the final container c !!! note Dangling containers are only removed when Renovate runs again with the same prefix. -## dockerImagePrefix +## dockerSidecarImage -By default Renovate pulls the sidecar Docker containers from `docker.io/containerbase`. -You can use the `dockerImagePrefix` option to override this default. +By default Renovate pulls the sidecar Docker containers from `ghcr.io/containerbase/sidecar`. +You can use the `dockerSidecarImage` option to override this default. -Say you want to pull your images from `ghcr.io/containerbase` to bypass Docker Hub limits. +Say you want to pull a custom image from `ghcr.io/your_company/sidecar`. You would put this in your configuration file: ```json { - "dockerImagePrefix": "ghcr.io/containerbase" + "dockerSidecarImage": "ghcr.io/your_company/sidecar" } ``` diff --git a/lib/config/global.ts b/lib/config/global.ts index c1b4e92455f634..0249e60f32be98 100644 --- a/lib/config/global.ts +++ b/lib/config/global.ts @@ -14,7 +14,7 @@ export class GlobalConfig { 'containerbaseDir', 'customEnvVariables', 'dockerChildPrefix', - 'dockerImagePrefix', + 'dockerSidecarImage', 'dockerUser', 'dryRun', 'exposeAllEnv', diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 4eddf0660922c3..82bae582950210 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -344,11 +344,11 @@ const options: RenovateOptions[] = [ default: 'renovate_', }, { - name: 'dockerImagePrefix', + name: 'dockerSidecarImage', description: - 'Change this value to override the default Renovate Docker sidecar image name prefix.', + 'Change this value to override the default Renovate sidecar image.', type: 'string', - default: 'docker.io/containerbase', + default: 'ghcr.io/containerbase/sidecar:8.0.2', globalOnly: true, }, { diff --git a/lib/config/types.ts b/lib/config/types.ts index b822ec436f7727..ad00ee60404919 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -125,7 +125,7 @@ export interface RepoGlobalConfig { cacheHardTtlMinutes?: number; customEnvVariables?: Record; dockerChildPrefix?: string; - dockerImagePrefix?: string; + dockerSidecarImage?: string; dockerUser?: string; dryRun?: DryRunConfig; executionTimeout?: number; diff --git a/lib/modules/manager/bundler/artifacts.spec.ts b/lib/modules/manager/bundler/artifacts.spec.ts index 841f8ecc899d2d..d131b7d5d3ec82 100644 --- a/lib/modules/manager/bundler/artifacts.spec.ts +++ b/lib/modules/manager/bundler/artifacts.spec.ts @@ -37,6 +37,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/cache'), containerbaseDir: join('/tmp/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; const config: UpdateArtifactsConfig = {}; @@ -279,7 +280,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -290,7 +291,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.2.0' + ' && ' + @@ -339,7 +340,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -350,7 +351,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.2.5' + ' && ' + @@ -401,7 +402,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -412,7 +413,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.3.0' + ' && ' + @@ -462,7 +463,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -474,7 +475,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.2.0' + ' && ' + @@ -533,7 +534,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -544,7 +545,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.2.0' + ' && ' + @@ -605,7 +606,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -616,7 +617,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.2.0' + ' && ' + @@ -676,7 +677,7 @@ describe('modules/manager/bundler/artifacts', () => { }) ).toEqual([updatedGemfileLock]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -687,7 +688,7 @@ describe('modules/manager/bundler/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 1.2.0' + ' && ' + diff --git a/lib/modules/manager/cargo/artifacts.spec.ts b/lib/modules/manager/cargo/artifacts.spec.ts index 1ad6453f3c6331..99b32f0f359135 100644 --- a/lib/modules/manager/cargo/artifacts.spec.ts +++ b/lib/modules/manager/cargo/artifacts.spec.ts @@ -21,6 +21,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/cache'), containerbaseDir: join('/tmp/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; describe('modules/manager/cargo/artifacts', () => { @@ -210,7 +211,7 @@ describe('modules/manager/cargo/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, {}, { cmd: @@ -220,7 +221,7 @@ describe('modules/manager/cargo/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool rust 1.65.0' + ' && ' + diff --git a/lib/modules/manager/cocoapods/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/cocoapods/__snapshots__/artifacts.spec.ts.snap index 3dab15063ae67d..78c9fda40c6bca 100644 --- a/lib/modules/manager/cocoapods/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/cocoapods/__snapshots__/artifacts.spec.ts.snap @@ -57,13 +57,13 @@ exports[`modules/manager/cocoapods/artifacts returns pod exec error 1`] = ` exports[`modules/manager/cocoapods/artifacts returns updated Podfile 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool ruby 3.1.0 && install-tool cocoapods 3.1.0 && gem install cocoapods-acknowledgements && pod install"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool ruby 3.1.0 && install-tool cocoapods 3.1.0 && gem install cocoapods-acknowledgements && pod install"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -88,13 +88,13 @@ exports[`modules/manager/cocoapods/artifacts returns updated Podfile 1`] = ` exports[`modules/manager/cocoapods/artifacts returns updated Podfile and Pods files 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool ruby 3.1.0 && install-tool cocoapods 3.1.0 && pod install"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool ruby 3.1.0 && install-tool cocoapods 3.1.0 && pod install"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", diff --git a/lib/modules/manager/cocoapods/artifacts.spec.ts b/lib/modules/manager/cocoapods/artifacts.spec.ts index a4caf0fe10d5b8..6abfc45974d42e 100644 --- a/lib/modules/manager/cocoapods/artifacts.spec.ts +++ b/lib/modules/manager/cocoapods/artifacts.spec.ts @@ -26,6 +26,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/cache'), containerbaseDir: join('/tmp/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; describe('modules/manager/cocoapods/artifacts', () => { @@ -252,7 +253,7 @@ describe('modules/manager/cocoapods/artifacts', () => { config, }); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker run --rm --name=renovate_sidecar --label=renovate_child ' + @@ -261,7 +262,7 @@ describe('modules/manager/cocoapods/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool ruby 3.1.0' + ' && ' + diff --git a/lib/modules/manager/composer/artifacts.spec.ts b/lib/modules/manager/composer/artifacts.spec.ts index bd197b7233d21c..089389a9b57e54 100644 --- a/lib/modules/manager/composer/artifacts.spec.ts +++ b/lib/modules/manager/composer/artifacts.spec.ts @@ -33,6 +33,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), containerbaseDir: join('/tmp/renovate/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; const repoStatus = partial({ @@ -784,7 +785,7 @@ describe('modules/manager/composer/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', options: { encoding: 'utf-8', }, @@ -804,7 +805,7 @@ describe('modules/manager/composer/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool php 7.3' + ' && ' + diff --git a/lib/modules/manager/gomod/artifacts.spec.ts b/lib/modules/manager/gomod/artifacts.spec.ts index aee0645b62011a..434e850d1aa8b5 100644 --- a/lib/modules/manager/gomod/artifacts.spec.ts +++ b/lib/modules/manager/gomod/artifacts.spec.ts @@ -59,6 +59,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), containerbaseDir: join('/tmp/renovate/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; const config: UpdateArtifactsConfig = { @@ -308,7 +309,7 @@ describe('modules/manager/gomod/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -325,7 +326,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + @@ -465,7 +466,7 @@ describe('modules/manager/gomod/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -495,7 +496,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + @@ -576,7 +577,7 @@ describe('modules/manager/gomod/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, {}, { options: { @@ -990,7 +991,7 @@ describe('modules/manager/gomod/artifacts', () => { { file: { contents: 'New go.sum 2', path: 'go.mod', type: 'addition' } }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, {}, { cmd: @@ -1007,7 +1008,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + @@ -1055,7 +1056,7 @@ describe('modules/manager/gomod/artifacts', () => { { file: { contents: 'New go.sum 2', path: 'go.mod', type: 'addition' } }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, {}, { cmd: @@ -1072,7 +1073,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + @@ -1120,7 +1121,7 @@ describe('modules/manager/gomod/artifacts', () => { { file: { contents: 'New go.sum 2', path: 'go.mod', type: 'addition' } }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, {}, { cmd: @@ -1137,7 +1138,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + @@ -1185,7 +1186,7 @@ describe('modules/manager/gomod/artifacts', () => { { file: { contents: 'New go.sum 2', path: 'go.mod', type: 'addition' } }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, {}, { cmd: @@ -1202,7 +1203,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + @@ -1842,7 +1843,7 @@ describe('modules/manager/gomod/artifacts', () => { ]); const expectedResult = [ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', }, {}, { @@ -1860,7 +1861,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.17.0' + ' && ' + @@ -1917,7 +1918,7 @@ describe('modules/manager/gomod/artifacts', () => { ]); const expectedResult = [ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', }, {}, { @@ -1935,7 +1936,7 @@ describe('modules/manager/gomod/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool golang 1.14.0' + ' && ' + diff --git a/lib/modules/manager/gradle-wrapper/artifacts.spec.ts b/lib/modules/manager/gradle-wrapper/artifacts.spec.ts index 06bb6b64ad86be..181362e4fd3b43 100644 --- a/lib/modules/manager/gradle-wrapper/artifacts.spec.ts +++ b/lib/modules/manager/gradle-wrapper/artifacts.spec.ts @@ -179,7 +179,11 @@ describe('modules/manager/gradle-wrapper/artifacts', () => { modified: ['gradle/wrapper/gradle-wrapper.properties'], }) ); - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const result = await updateArtifacts({ packageFileName: 'gradle/wrapper/gradle-wrapper.properties', @@ -198,7 +202,7 @@ describe('modules/manager/gradle-wrapper/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -209,7 +213,7 @@ describe('modules/manager/gradle-wrapper/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool java 11.0.1' + ' && ' + diff --git a/lib/modules/manager/gradle/artifacts.spec.ts b/lib/modules/manager/gradle/artifacts.spec.ts index 087952f444900b..7c0f1be7555f9c 100644 --- a/lib/modules/manager/gradle/artifacts.spec.ts +++ b/lib/modules/manager/gradle/artifacts.spec.ts @@ -35,6 +35,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/cache'), containerbaseDir: join('/tmp/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; const osPlatformSpy = jest.spyOn(os, 'platform'); @@ -322,7 +323,7 @@ describe('modules/manager/gradle/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -333,7 +334,7 @@ describe('modules/manager/gradle/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool java 16.0.1' + ' && ' + @@ -351,7 +352,7 @@ describe('modules/manager/gradle/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool java 16.0.1' + ' && ' + diff --git a/lib/modules/manager/helmfile/artifacts.spec.ts b/lib/modules/manager/helmfile/artifacts.spec.ts index f4c448451ac191..519f35784415f7 100644 --- a/lib/modules/manager/helmfile/artifacts.spec.ts +++ b/lib/modules/manager/helmfile/artifacts.spec.ts @@ -24,6 +24,7 @@ const adminConfig: RepoGlobalConfig = { localDir: join('/tmp/github/some/repo'), // `join` fixes Windows CI cacheDir: join('/tmp/renovate/cache'), containerbaseDir: join('/tmp/renovate/cache/containerbase'), + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }; const config: UpdateArtifactsConfig = {}; @@ -156,7 +157,7 @@ describe('modules/manager/helmfile/artifacts', () => { { binarySource: 'docker', expectedCommands: [ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -166,7 +167,7 @@ describe('modules/manager/helmfile/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool helm v3.7.2' + ' && ' + diff --git a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap index e3580be7b905ce..f4e5d2e08f49c6 100644 --- a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap @@ -456,7 +456,7 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock for lockfil exports[`modules/manager/helmv3/artifacts returns updated Chart.lock with docker 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -468,7 +468,7 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock with docker }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update ''"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update ''"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -590,7 +590,7 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases with docker 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -602,7 +602,7 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add stable the_stable_url && helm repo add repo1 the_repo1_url && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update ''"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add stable the_stable_url && helm repo add repo1 the_repo1_url && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update ''"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", diff --git a/lib/modules/manager/helmv3/artifacts.spec.ts b/lib/modules/manager/helmv3/artifacts.spec.ts index 0116d6b7c65820..ff8e5b3ee94153 100644 --- a/lib/modules/manager/helmv3/artifacts.spec.ts +++ b/lib/modules/manager/helmv3/artifacts.spec.ts @@ -153,7 +153,11 @@ describe('modules/manager/helmv3/artifacts', () => { }); it('returns updated Chart.lock with docker', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.getSiblingFileName.mockReturnValueOnce('Chart.lock'); fs.readLocalFile.mockResolvedValueOnce(ociLockFile1 as never); const execSnapshots = mockExecAll(); @@ -585,7 +589,11 @@ describe('modules/manager/helmv3/artifacts', () => { }); it('sets repositories from registryAliases with docker', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.getSiblingFileName.mockReturnValueOnce('Chart.lock'); fs.readLocalFile.mockResolvedValueOnce(ociLockFile1 as never); const execSnapshots = mockExecAll(); diff --git a/lib/modules/manager/maven-wrapper/artifacts.spec.ts b/lib/modules/manager/maven-wrapper/artifacts.spec.ts index a4a8c91a2fd697..359919d3a1eae8 100644 --- a/lib/modules/manager/maven-wrapper/artifacts.spec.ts +++ b/lib/modules/manager/maven-wrapper/artifacts.spec.ts @@ -174,7 +174,11 @@ describe('modules/manager/maven-wrapper/artifacts', () => { it('updates with docker', async () => { mockMavenFileChangedInGit(); - GlobalConfig.set({ localDir: './', binarySource: 'docker' }); + GlobalConfig.set({ + localDir: './', + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const execSnapshots = mockExecAll({ stdout: '', stderr: '' }); const result = await updateArtifacts({ packageFileName: 'maven', @@ -193,7 +197,7 @@ describe('modules/manager/maven-wrapper/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', options: { encoding: 'utf-8' }, }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, @@ -204,7 +208,7 @@ describe('modules/manager/maven-wrapper/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "../.." ' + - 'containerbase/sidecar' + + 'ghcr.io/containerbase/sidecar' + ' bash -l -c "' + 'install-tool java 17.0.0 ' + '&& ' + diff --git a/lib/modules/manager/mix/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/mix/__snapshots__/artifacts.spec.ts.snap index 903275a1220f48..4741c076830db3 100644 --- a/lib/modules/manager/mix/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/mix/__snapshots__/artifacts.spec.ts.snap @@ -21,7 +21,7 @@ exports[`modules/manager/mix/artifacts authenticates to private repositories 2`] }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool erlang 25.0.0.0 && install-tool elixir v1.13.4 && mix hex.organization auth renovate_test --key valid_test_token && mix deps.update private_package other_package"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool erlang 25.0.0.0 && install-tool elixir v1.13.4 && mix hex.organization auth renovate_test --key valid_test_token && mix deps.update private_package other_package"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -69,7 +69,7 @@ exports[`modules/manager/mix/artifacts returns null if unchanged 1`] = ` exports[`modules/manager/mix/artifacts returns updated mix.lock 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -81,7 +81,7 @@ exports[`modules/manager/mix/artifacts returns updated mix.lock 1`] = ` }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool erlang 25.0.0.0 && install-tool elixir 1.13.4 && mix deps.update plug"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/cache":"/tmp/cache" -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool erlang 25.0.0.0 && install-tool elixir 1.13.4 && mix deps.update plug"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", diff --git a/lib/modules/manager/mix/artifacts.spec.ts b/lib/modules/manager/mix/artifacts.spec.ts index 29801cb9371d68..63a5576810aec4 100644 --- a/lib/modules/manager/mix/artifacts.spec.ts +++ b/lib/modules/manager/mix/artifacts.spec.ts @@ -90,7 +90,11 @@ describe('modules/manager/mix/artifacts', () => { it('returns updated mix.lock', async () => { jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock'); const execSnapshots = mockExecAll(); @@ -161,7 +165,11 @@ describe('modules/manager/mix/artifacts', () => { it('authenticates to private repositories', async () => { jest.spyOn(docker, 'removeDanglingContainers').mockResolvedValueOnce(); - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.readLocalFile.mockResolvedValueOnce('Old mix.lock'); fs.findLocalSiblingOrParent.mockResolvedValueOnce('mix.lock'); const execSnapshots = mockExecAll(); @@ -221,7 +229,11 @@ describe('modules/manager/mix/artifacts', () => { }); it('returns updated mix.lock in subdir', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.findLocalSiblingOrParent.mockResolvedValueOnce('subdir/mix.lock'); mockExecAll(); expect( diff --git a/lib/modules/manager/nix/artifacts.spec.ts b/lib/modules/manager/nix/artifacts.spec.ts index 35509270490ec9..0877831a679387 100644 --- a/lib/modules/manager/nix/artifacts.spec.ts +++ b/lib/modules/manager/nix/artifacts.spec.ts @@ -24,7 +24,11 @@ const adminConfig: RepoGlobalConfig = { cacheDir: join('/tmp/renovate/cache'), containerbaseDir: join('/tmp/renovate/cache/containerbase'), }; -const dockerAdminConfig = { ...adminConfig, binarySource: 'docker' }; +const dockerAdminConfig = { + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', +}; process.env.BUILDPACK = 'true'; @@ -177,7 +181,7 @@ describe('modules/manager/nix/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -187,7 +191,7 @@ describe('modules/manager/nix/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool nix 2.10.0 ' + '&& ' + @@ -308,7 +312,7 @@ describe('modules/manager/nix/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -318,7 +322,7 @@ describe('modules/manager/nix/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool nix 2.10.0 ' + '&& ' + diff --git a/lib/modules/manager/npm/post-update/lerna.spec.ts b/lib/modules/manager/npm/post-update/lerna.spec.ts index 29e9ec5b6eda3b..ca87b5662aaca7 100644 --- a/lib/modules/manager/npm/post-update/lerna.spec.ts +++ b/lib/modules/manager/npm/post-update/lerna.spec.ts @@ -134,7 +134,11 @@ describe('modules/manager/npm/post-update/lerna', () => { it('suppports docker', async () => { const execSnapshots = mockExecAll(); - GlobalConfig.set({ ...globalConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...globalConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const res = await lernaHelper.generateLockFiles( lernaPkgFile('npm'), @@ -144,7 +148,7 @@ describe('modules/manager/npm/post-update/lerna', () => { ); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', }, { cmd: 'docker ps --filter name=renovate_sidecar -aq', @@ -155,7 +159,7 @@ describe('modules/manager/npm/post-update/lerna', () => { '-v "/tmp/cache":"/tmp/cache" ' + '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + - '-w "some-dir" containerbase/sidecar ' + + '-w "some-dir" ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool node 16.16.0 ' + '&& ' + diff --git a/lib/modules/manager/npm/post-update/npm.spec.ts b/lib/modules/manager/npm/post-update/npm.spec.ts index 42d4851b9781e6..ff0f453b6635bb 100644 --- a/lib/modules/manager/npm/post-update/npm.spec.ts +++ b/lib/modules/manager/npm/post-update/npm.spec.ts @@ -246,6 +246,7 @@ describe('modules/manager/npm/post-update/npm', () => { cacheDir: '/tmp', binarySource: 'docker', allowScripts: true, + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }); const execSnapshots = mockExecAll(); fs.readLocalFile.mockResolvedValue('package-lock-contents'); @@ -259,7 +260,7 @@ describe('modules/manager/npm/post-update/npm', () => { expect(fs.readLocalFile).toHaveBeenCalledTimes(1); expect(res.lockFile).toBe('package-lock-contents'); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -268,7 +269,7 @@ describe('modules/manager/npm/post-update/npm', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "some-dir" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool node 16.16.0 ' + '&& ' + diff --git a/lib/modules/manager/npm/post-update/pnpm.spec.ts b/lib/modules/manager/npm/post-update/pnpm.spec.ts index 5acd7a58a4a63c..e3a9fe79ebec23 100644 --- a/lib/modules/manager/npm/post-update/pnpm.spec.ts +++ b/lib/modules/manager/npm/post-update/pnpm.spec.ts @@ -213,6 +213,7 @@ describe('modules/manager/npm/post-update/pnpm', () => { cacheDir: '/tmp', binarySource: 'docker', allowScripts: true, + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }); const execSnapshots = mockExecAll(); fs.readLocalFile.mockResolvedValue('package-lock-contents'); @@ -224,7 +225,7 @@ describe('modules/manager/npm/post-update/pnpm', () => { expect(fs.readLocalFile).toHaveBeenCalledTimes(1); expect(res.lockFile).toBe('package-lock-contents'); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -233,7 +234,7 @@ describe('modules/manager/npm/post-update/pnpm', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "some-dir" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool node 16.16.0 ' + '&& install-tool pnpm 6.0.0 ' + diff --git a/lib/modules/manager/npm/post-update/yarn.spec.ts b/lib/modules/manager/npm/post-update/yarn.spec.ts index 3a525661942559..997bd070438447 100644 --- a/lib/modules/manager/npm/post-update/yarn.spec.ts +++ b/lib/modules/manager/npm/post-update/yarn.spec.ts @@ -536,6 +536,7 @@ describe('modules/manager/npm/post-update/yarn', () => { localDir: '.', binarySource: 'docker', cacheDir: '/tmp/cache', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }); Fixtures.mock( { @@ -555,10 +556,10 @@ describe('modules/manager/npm/post-update/yarn', () => { expect(res.lockFile).toBe(plocktest1YarnLockV1); const options = { encoding: 'utf-8' }; expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar', options }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar', options }, { cmd: - `docker run --rm --name=renovate_sidecar --label=renovate_child -v ".":"." -v "/tmp/cache":"/tmp/cache" -e CI -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "some-dir" containerbase/sidecar ` + + `docker run --rm --name=renovate_sidecar --label=renovate_child -v ".":"." -v "/tmp/cache":"/tmp/cache" -e CI -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "some-dir" ghcr.io/containerbase/sidecar ` + `bash -l -c "` + `install-tool node 16.16.0` + ` && ` + diff --git a/lib/modules/manager/nuget/artifacts.spec.ts b/lib/modules/manager/nuget/artifacts.spec.ts index 5520b23a89ea87..d950b750df16d9 100644 --- a/lib/modules/manager/nuget/artifacts.spec.ts +++ b/lib/modules/manager/nuget/artifacts.spec.ts @@ -222,7 +222,11 @@ describe('modules/manager/nuget/artifacts', () => { }); it('supports docker mode', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const execSnapshots = mockExecAll(); fs.getSiblingFileName.mockReturnValueOnce('packages.lock.json'); git.getFiles.mockResolvedValueOnce({ @@ -249,7 +253,7 @@ describe('modules/manager/nuget/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', }, { cmd: 'docker ps --filter name=renovate_sidecar -aq', @@ -264,7 +268,7 @@ describe('modules/manager/nuget/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool dotnet 7.0.100' + ' && ' + diff --git a/lib/modules/manager/pep621/artifacts.spec.ts b/lib/modules/manager/pep621/artifacts.spec.ts index d28645cf794350..717a03899c64ea 100644 --- a/lib/modules/manager/pep621/artifacts.spec.ts +++ b/lib/modules/manager/pep621/artifacts.spec.ts @@ -58,7 +58,11 @@ describe('modules/manager/pep621/artifacts', () => { it('return processor result', async () => { const execSnapshots = mockExecAll(); - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.getSiblingFileName.mockReturnValueOnce('pdm.lock'); fs.readLocalFile.mockResolvedValueOnce('old test content'); fs.readLocalFile.mockResolvedValueOnce('new test content'); @@ -98,7 +102,7 @@ requires-python = "<3.9" ]); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', options: { encoding: 'utf-8', }, @@ -117,7 +121,7 @@ requires-python = "<3.9" '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 3.8.1 ' + '&& ' + diff --git a/lib/modules/manager/pep621/processors/pdm.spec.ts b/lib/modules/manager/pep621/processors/pdm.spec.ts index 4e1c77a1f4ae4c..54d028b26b72f9 100644 --- a/lib/modules/manager/pep621/processors/pdm.spec.ts +++ b/lib/modules/manager/pep621/processors/pdm.spec.ts @@ -41,7 +41,11 @@ describe('modules/manager/pep621/processors/pdm', () => { it('return null if the lock file is unchanged', async () => { const execSnapshots = mockExecAll(); - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.getSiblingFileName.mockReturnValueOnce('pdm.lock'); fs.readLocalFile.mockResolvedValueOnce('test content'); fs.readLocalFile.mockResolvedValueOnce('test content'); @@ -67,7 +71,7 @@ describe('modules/manager/pep621/processors/pdm', () => { expect(result).toBeNull(); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', }, { cmd: 'docker ps --filter name=renovate_sidecar -aq', @@ -80,7 +84,7 @@ describe('modules/manager/pep621/processors/pdm', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 3.11.2 ' + '&& ' + diff --git a/lib/modules/manager/pip-compile/artifacts.spec.ts b/lib/modules/manager/pip-compile/artifacts.spec.ts index 94c8463f29e48d..c9f31b0e8bbbfb 100644 --- a/lib/modules/manager/pip-compile/artifacts.spec.ts +++ b/lib/modules/manager/pip-compile/artifacts.spec.ts @@ -23,7 +23,11 @@ const adminConfig: RepoGlobalConfig = { cacheDir: join('/tmp/renovate/cache'), containerbaseDir: join('/tmp/renovate/cache/containerbase'), }; -const dockerAdminConfig = { ...adminConfig, binarySource: 'docker' }; +const dockerAdminConfig = { + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', +}; process.env.BUILDPACK = 'true'; @@ -114,7 +118,7 @@ describe('modules/manager/pip-compile/artifacts', () => { ).not.toBeNull(); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -125,7 +129,7 @@ describe('modules/manager/pip-compile/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 3.10.2 ' + '&& ' + @@ -231,7 +235,7 @@ describe('modules/manager/pip-compile/artifacts', () => { ).not.toBeNull(); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -242,7 +246,7 @@ describe('modules/manager/pip-compile/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 3.10.2 ' + '&& ' + diff --git a/lib/modules/manager/pip_requirements/artifacts.spec.ts b/lib/modules/manager/pip_requirements/artifacts.spec.ts index 69e2152cea29b2..8d1ebb0ed7a643 100644 --- a/lib/modules/manager/pip_requirements/artifacts.spec.ts +++ b/lib/modules/manager/pip_requirements/artifacts.spec.ts @@ -184,7 +184,11 @@ describe('modules/manager/pip_requirements/artifacts', () => { }); it('supports docker mode', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); fs.readLocalFile.mockResolvedValueOnce('new content'); fs.ensureCacheDir.mockResolvedValueOnce('/tmp/cache'); const execSnapshots = mockExecAll(); @@ -207,7 +211,7 @@ describe('modules/manager/pip_requirements/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -218,7 +222,7 @@ describe('modules/manager/pip_requirements/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 3.10.2 ' + '&& ' + diff --git a/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap index 81581b65c5806e..98aad0bb631a0a 100644 --- a/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/pipenv/__snapshots__/artifacts.spec.ts.snap @@ -99,7 +99,7 @@ exports[`modules/manager/pipenv/artifacts returns updated Pipfile.lock 1`] = ` exports[`modules/manager/pipenv/artifacts supports docker mode 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -111,7 +111,7 @@ exports[`modules/manager/pipenv/artifacts supports docker mode 1`] = ` }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e PIP_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool python 3.7.6 && pip install --user pipenv && pipenv lock"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e PIP_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool python 3.7.6 && pip install --user pipenv && pipenv lock"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -138,7 +138,7 @@ exports[`modules/manager/pipenv/artifacts supports docker mode 1`] = ` exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -150,7 +150,7 @@ exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile 1`] = }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool python 3.10.2 && pip install --user pipenv==2020.8.13 && pipenv lock"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool python 3.10.2 && pip install --user pipenv==2020.8.13 && pipenv lock"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -176,7 +176,7 @@ exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile 1`] = exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile dev packages 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -188,7 +188,7 @@ exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile dev p }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool python 3.10.2 && pip install --user pipenv==2020.8.13 && pipenv lock"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool python 3.10.2 && pip install --user pipenv==2020.8.13 && pipenv lock"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -214,7 +214,7 @@ exports[`modules/manager/pipenv/artifacts uses pipenv version from Pipfile dev p exports[`modules/manager/pipenv/artifacts uses pipenv version from config 1`] = ` [ { - "cmd": "docker pull containerbase/sidecar", + "cmd": "docker pull ghcr.io/containerbase/sidecar", "options": { "encoding": "utf-8", }, @@ -226,7 +226,7 @@ exports[`modules/manager/pipenv/artifacts uses pipenv version from config 1`] = }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool python 3.10.2 && pip install --user pipenv==2020.1.1 && pipenv lock"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e PIPENV_CACHE_DIR -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool python 3.10.2 && pip install --user pipenv==2020.1.1 && pipenv lock"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", diff --git a/lib/modules/manager/pipenv/artifacts.spec.ts b/lib/modules/manager/pipenv/artifacts.spec.ts index 55718c39d64a3c..0c051946a02247 100644 --- a/lib/modules/manager/pipenv/artifacts.spec.ts +++ b/lib/modules/manager/pipenv/artifacts.spec.ts @@ -26,7 +26,11 @@ const adminConfig: RepoGlobalConfig = { cacheDir: join('/tmp/renovate/cache'), containerbaseDir: join('/tmp/renovate/cache/containerbase'), }; -const dockerAdminConfig = { ...adminConfig, binarySource: 'docker' }; +const dockerAdminConfig = { + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', +}; const config: UpdateArtifactsConfig = {}; const lockMaintenanceConfig = { ...config, isLockFileMaintenance: true }; diff --git a/lib/modules/manager/poetry/artifacts.spec.ts b/lib/modules/manager/poetry/artifacts.spec.ts index 67cc4098f841dd..d09a0908d7a552 100644 --- a/lib/modules/manager/poetry/artifacts.spec.ts +++ b/lib/modules/manager/poetry/artifacts.spec.ts @@ -250,7 +250,11 @@ describe('modules/manager/poetry/artifacts', () => { }); it('returns updated poetry.lock using docker', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const execSnapshots = mockExecAll(); fs.ensureCacheDir.mockResolvedValueOnce('/tmp/renovate/cache/others/pip'); // poetry.lock @@ -288,7 +292,7 @@ describe('modules/manager/poetry/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -299,7 +303,7 @@ describe('modules/manager/poetry/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 3.4.2 ' + '&& ' + @@ -312,7 +316,11 @@ describe('modules/manager/poetry/artifacts', () => { }); it('returns updated poetry.lock using docker (constraints)', async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const execSnapshots = mockExecAll(); fs.ensureCacheDir.mockResolvedValueOnce('/tmp/renovate/cache/others/pip'); @@ -351,7 +359,7 @@ describe('modules/manager/poetry/artifacts', () => { }, ]); expect(execSnapshots).toMatchObject([ - { cmd: 'docker pull containerbase/sidecar' }, + { cmd: 'docker pull ghcr.io/containerbase/sidecar' }, { cmd: 'docker ps --filter name=renovate_sidecar -aq' }, { cmd: @@ -362,7 +370,7 @@ describe('modules/manager/poetry/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + 'install-tool python 2.7.5 ' + '&& ' + diff --git a/lib/modules/manager/pub/artifacts.spec.ts b/lib/modules/manager/pub/artifacts.spec.ts index af46405b091b6e..f051bb8665e049 100644 --- a/lib/modules/manager/pub/artifacts.spec.ts +++ b/lib/modules/manager/pub/artifacts.spec.ts @@ -141,7 +141,11 @@ describe('modules/manager/pub/artifacts', () => { }); it(`supports ${params.sdk} docker mode`, async () => { - GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); + GlobalConfig.set({ + ...adminConfig, + binarySource: 'docker', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); const execSnapshots = mockExecAll(); fs.getSiblingFileName.mockReturnValueOnce(lockFile); fs.readLocalFile.mockResolvedValueOnce(oldLockFileContent); @@ -162,7 +166,7 @@ describe('modules/manager/pub/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'docker pull containerbase/sidecar', + cmd: 'docker pull ghcr.io/containerbase/sidecar', }, { cmd: 'docker ps --filter name=renovate_sidecar -aq', @@ -175,7 +179,7 @@ describe('modules/manager/pub/artifacts', () => { '-e BUILDPACK_CACHE_DIR ' + '-e CONTAINERBASE_CACHE_DIR ' + '-w "/tmp/github/some/repo" ' + - 'containerbase/sidecar ' + + 'ghcr.io/containerbase/sidecar ' + 'bash -l -c "' + `install-tool ${params.sdk} 3.3.9` + ' && ' + diff --git a/lib/util/exec/docker/index.spec.ts b/lib/util/exec/docker/index.spec.ts index 3542031c09851a..150f27aa6796c7 100644 --- a/lib/util/exec/docker/index.spec.ts +++ b/lib/util/exec/docker/index.spec.ts @@ -225,11 +225,14 @@ describe('util/exec/docker/index', () => { (vol ? `${vol} ` : '') + `-e FOO -e BAR ` + `-w "/tmp/foobar" ` + - `containerbase/${img} ` + + `ghcr.io/containerbase/sidecar ` + `bash -l -c "foo && bar"`; beforeEach(() => { - GlobalConfig.set({ dockerUser: 'some-user' }); + GlobalConfig.set({ + dockerUser: 'some-user', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }); }); it('returns executable command', async () => { @@ -267,6 +270,7 @@ describe('util/exec/docker/index', () => { cacheDir: '/tmp/cache', containerbaseDir: '/tmp/containerbase', dockerUser: 'some-user', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }); const volumes: VolumeOption[] = ['/tmp/foo']; const res = await generateDockerCommand(commands, preCommands, { @@ -287,6 +291,7 @@ describe('util/exec/docker/index', () => { cacheDir: '/tmp/cache', containerbaseDir: '/tmp/cache/containerbase', dockerUser: 'some-user', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', }); const volumes: VolumeOption[] = ['/tmp/foo']; const res = await generateDockerCommand(commands, preCommands, { diff --git a/lib/util/exec/docker/index.ts b/lib/util/exec/docker/index.ts index 9d192db5908359..b0552e18f47225 100644 --- a/lib/util/exec/docker/index.ts +++ b/lib/util/exec/docker/index.ts @@ -5,7 +5,6 @@ import { logger } from '../../../logger'; import { getPkgReleases } from '../../../modules/datasource'; import * as versioning from '../../../modules/versioning'; import { newlineRegex, regEx } from '../../regex'; -import { ensureTrailingSlash } from '../../url'; import { rawExec } from '../common'; import type { DockerOptions, Opt, VolumeOption, VolumesPair } from '../types'; @@ -222,7 +221,7 @@ export async function generateDockerCommand( containerbaseDir, dockerUser, dockerChildPrefix, - dockerImagePrefix, + dockerSidecarImage, } = GlobalConfig.get(); const result = ['docker run --rm']; const containerName = getContainerName(image, dockerChildPrefix); @@ -259,9 +258,8 @@ export async function generateDockerCommand( result.push(`-w "${cwd}"`); } - image = `${ensureTrailingSlash( - dockerImagePrefix ?? 'containerbase' - )}${image}`; + // TODO: #7154 + image = dockerSidecarImage!; // TODO: add constraint: const tag = getDockerTag(image, sideCarImageVersion, 'semver'); logger.debug( diff --git a/lib/util/exec/index.spec.ts b/lib/util/exec/index.spec.ts index 19f18c32268b14..669c3b601c3019 100644 --- a/lib/util/exec/index.spec.ts +++ b/lib/util/exec/index.spec.ts @@ -38,7 +38,11 @@ describe('util/exec/index', () => { const defaultCacheVolume = `-v "${cacheDir}":"${cacheDir}"`; const defaultVolumes = `-v "${cwd}":"${cwd}" ${defaultCacheVolume}`; - const globalConfig: RepoGlobalConfig = { cacheDir, containerbaseDir }; + const globalConfig: RepoGlobalConfig = { + cacheDir, + containerbaseDir, + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', + }; beforeEach(() => { dockerModule.resetPrefetchedImages(); @@ -54,7 +58,7 @@ describe('util/exec/index', () => { }); const image = dockerModule.sideCarImage; - const fullImage = `containerbase/${image}`; + const fullImage = `ghcr.io/containerbase/sidecar`; const name = `renovate_${image}`; const inCmd = 'echo hello'; const outCmd = ['echo hello']; @@ -413,7 +417,7 @@ describe('util/exec/index', () => { }, ], adminConfig: { - dockerImagePrefix: 'ghcr.io/containerbase', + dockerSidecarImage: 'ghcr.io/containerbase/sidecar', binarySource: 'docker', }, }, diff --git a/renovate.json b/renovate.json index 86850e28adc841..4824b2dfe9c9bf 100644 --- a/renovate.json +++ b/renovate.json @@ -29,5 +29,14 @@ "matchPaths": ["**/__fixtures__/**"], "enabled": false } + ], + "regexManagers": [ + { + "fileMatch": ["config/options/index.ts"], + "matchStrings": [ + "default: '(?ghcr.io/containerbase/sidecar):(?.*)'" + ], + "datasourceTemplate": "docker" + } ] } From 93a7751fd8746ae399f42e6eae317edf44d64b63 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sun, 18 Jun 2023 09:48:19 +0200 Subject: [PATCH 20/22] feat!: Revert "feat!: remove `skipInstalls` config option (#22648)" This reverts commit 4c68647286157637b6d20c961ee2e3fd3a663ce9. --- docs/usage/self-hosted-configuration.md | 8 ++++++- lib/config/options/index.ts | 8 +++++++ lib/config/types.ts | 1 + lib/modules/manager/npm/extract/index.spec.ts | 2 +- lib/modules/manager/npm/extract/index.ts | 22 +++++++++++-------- lib/modules/manager/types.ts | 6 ++--- .../extract-fingerprint-config.spec.ts | 4 ++++ 7 files changed, 37 insertions(+), 14 deletions(-) diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index da534135fb132d..29ad00fbf4be45 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -29,7 +29,7 @@ module.exports = { In the `renovate.json` file, define the commands and files to be included in the final commit. -The command to install dependencies (`npm ci --ignore-scripts`) is needed because, by default, the installation of dependencies is skipped. +The command to install dependencies (`npm ci --ignore-scripts`) is needed because, by default, the installation of dependencies is skipped (see the `skipInstalls` global option). ```json { @@ -798,6 +798,12 @@ It could then be used in a repository config or preset like so: Secret names must start with an upper or lower case character and can have only characters, digits, or underscores. +## 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. +If this is set to false, then a full install of modules will be done. +This is currently applicable to `npm` and `lerna`/`npm` only, and only used in cases where bugs in `npm` result in incorrect lock files being updated. + ## token ## unicodeEmoji diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 82bae582950210..eb314221a872df 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -729,6 +729,14 @@ const options: RenovateOptions[] = [ description: 'Set to `false` to disable lock file updating.', type: 'boolean', }, + { + name: 'skipInstalls', + description: + 'Skip installing modules/dependencies if lock file updating is possible without a full install.', + type: 'boolean', + default: null, + globalOnly: true, + }, { name: 'autodiscover', description: 'Autodiscover all repositories.', diff --git a/lib/config/types.ts b/lib/config/types.ts index ad00ee60404919..9fbabb40fa68ac 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -262,6 +262,7 @@ export interface RenovateConfig secrets?: Record; constraints?: Record; + skipInstalls?: boolean | null; constraintsFiltering?: ConstraintsFilter; diff --git a/lib/modules/manager/npm/extract/index.spec.ts b/lib/modules/manager/npm/extract/index.spec.ts index 170f4ff30d151a..d43e4702551c73 100644 --- a/lib/modules/manager/npm/extract/index.spec.ts +++ b/lib/modules/manager/npm/extract/index.spec.ts @@ -9,7 +9,7 @@ const realFs = jest.requireActual( ); const defaultExtractConfig = { - skipInstalls: true, + skipInstalls: null, } satisfies ExtractConfig; const input01Content = Fixtures.get('inputs/01.json', '..'); diff --git a/lib/modules/manager/npm/extract/index.ts b/lib/modules/manager/npm/extract/index.ts index 6db976a92e5316..467cdef6b849fc 100644 --- a/lib/modules/manager/npm/extract/index.ts +++ b/lib/modules/manager/npm/extract/index.ts @@ -473,15 +473,19 @@ export async function extractPackageFile( return null; } } - let skipInstalls = true; // skip installing modules by default - if ((hasFancyRefs && lockFiles.npmLock) || yarnZeroInstall) { - // https://github.com/npm/cli/issues/1432 - // Explanation: - // - npm install --package-lock-only is buggy for transitive deps in file: and npm: references - // - So we set skipInstalls to false if file: or npm: refs are found *and* the user hasn't explicitly set the value already - // - Also, do not skip install if Yarn zero-install is used - logger.debug('Automatically setting skipInstalls to false'); - skipInstalls = false; + let skipInstalls = config.skipInstalls; + if (skipInstalls === null) { + if ((hasFancyRefs && lockFiles.npmLock) || yarnZeroInstall) { + // https://github.com/npm/cli/issues/1432 + // Explanation: + // - npm install --package-lock-only is buggy for transitive deps in file: and npm: references + // - So we set skipInstalls to false if file: or npm: refs are found *and* the user hasn't explicitly set the value already + // - Also, do not skip install if Yarn zero-install is used + logger.debug('Automatically setting skipInstalls to false'); + skipInstalls = false; + } else { + skipInstalls = true; + } } return { diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index f037a97f1afaef..311288b6bf9369 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -20,7 +20,7 @@ export interface ExtractConfig extends CustomExtractConfig { registryAliases?: Record; npmrc?: string; npmrcMerge?: boolean; - skipInstalls?: boolean; + skipInstalls?: boolean | null; } export interface CustomExtractConfig extends RegexManagerTemplates { @@ -64,7 +64,7 @@ export interface PackageFileContent> lockFiles?: string[]; npmrc?: string; packageFileVersion?: string; - skipInstalls?: boolean; + skipInstalls?: boolean | null; matchStrings?: string[]; matchStringsStrategy?: MatchStringsStrategy; } @@ -274,7 +274,7 @@ export interface PostUpdateConfig> ManagerData { updatedPackageFiles?: FileChange[]; postUpdateOptions?: string[]; - skipInstalls?: boolean; + skipInstalls?: boolean | null; ignoreScripts?: boolean; packageFile?: string; diff --git a/lib/workers/repository/extract/extract-fingerprint-config.spec.ts b/lib/workers/repository/extract/extract-fingerprint-config.spec.ts index e3d252ba282147..c0ac40404f4e46 100644 --- a/lib/workers/repository/extract/extract-fingerprint-config.spec.ts +++ b/lib/workers/repository/extract/extract-fingerprint-config.spec.ts @@ -47,6 +47,7 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { registryAliases: { notStable: 'http://some.link.2', }, + skipInstalls: null, }); expect( fingerprintConfig.managers.find((manager) => manager.manager === 'regex') @@ -65,6 +66,7 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { registryAliases: { stable: 'http://some.link', }, + skipInstalls: null, }); }); @@ -88,6 +90,7 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { npmrc: 'some-string', npmrcMerge: true, registryAliases: {}, + skipInstalls: null, }); expect( fingerprintConfig.managers.find( @@ -106,6 +109,7 @@ describe('workers/repository/extract/extract-fingerprint-config', () => { npmrc: 'some-string', npmrcMerge: true, registryAliases: {}, + skipInstalls: null, }); expect( fingerprintConfig.managers.find((manager) => manager.manager === 'regex') From 6515df89fbd716aae134209c6f14efcfbc52140e Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Sun, 18 Jun 2023 13:58:25 +0545 Subject: [PATCH 21/22] feat(release-notes)!: support configurable fetching stage (#22781) Changes fetchReleaseNotes from boolean to enum, with values off, branch, pr. Closes #20476 BREAKING CHANGE: Release notes won't be fetched early for commitBody insertion unless explicitly configured with fetchReleaseNotes=branch --- docs/usage/configuration-options.md | 9 ++++- .../fetch-release-notes-migration.spec.ts | 22 +++++++++++ .../custom/fetch-release-notes-migration.ts | 12 ++++++ lib/config/migrations/migrations-service.ts | 2 + lib/config/options/index.ts | 7 ++-- lib/config/types.ts | 4 +- .../repository/changelog/index.spec.ts | 21 +---------- lib/workers/repository/changelog/index.ts | 18 --------- .../repository/update/branch/index.spec.ts | 5 +-- lib/workers/repository/update/branch/index.ts | 14 +++---- .../repository/update/pr/index.spec.ts | 10 ++--- lib/workers/repository/update/pr/index.ts | 2 +- .../repository/updates/branchify.spec.ts | 37 +------------------ lib/workers/repository/updates/branchify.ts | 17 --------- 14 files changed, 66 insertions(+), 114 deletions(-) create mode 100644 lib/config/migrations/custom/fetch-release-notes-migration.spec.ts create mode 100644 lib/config/migrations/custom/fetch-release-notes-migration.ts diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index dcfb385674416e..3ea6947f39fc6a 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -931,7 +931,14 @@ A similar one could strip leading `v` prefixes: ## fetchReleaseNotes -Set this to `false` if you want to disable release notes fetching. +Use this config option to configure release notes fetching. +The available options are: + +- `off` - disable release notes fetching +- `branch` - fetch release notes while creating/updating branch +- `pr`(default) - fetches release notes while creating/updating pull-request + +It is not recommended to set fetchReleaseNotes=branch unless you are embedding release notes in commit information, because it results in a performance decrease. Renovate can fetch release notes when they are hosted on one of these platforms: diff --git a/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts b/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts new file mode 100644 index 00000000000000..2e17148597eec2 --- /dev/null +++ b/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts @@ -0,0 +1,22 @@ +import { FetchReleaseNotesMigration } from './fetch-release-notes-migration'; + +describe('config/migrations/custom/fetch-release-notes-migration', () => { + it('migrates', () => { + expect(FetchReleaseNotesMigration).toMigrate( + { + fetchReleaseNotes: false as never, + }, + { + fetchReleaseNotes: 'off', + } + ); + expect(FetchReleaseNotesMigration).toMigrate( + { + fetchReleaseNotes: true as never, + }, + { + fetchReleaseNotes: 'pr', + } + ); + }); +}); diff --git a/lib/config/migrations/custom/fetch-release-notes-migration.ts b/lib/config/migrations/custom/fetch-release-notes-migration.ts new file mode 100644 index 00000000000000..60b7afe6eaa1a4 --- /dev/null +++ b/lib/config/migrations/custom/fetch-release-notes-migration.ts @@ -0,0 +1,12 @@ +import is from '@sindresorhus/is'; +import { AbstractMigration } from '../base/abstract-migration'; + +export class FetchReleaseNotesMigration extends AbstractMigration { + override readonly propertyName = 'fetchReleaseNotes'; + + override run(value: unknown): void { + if (is.boolean(value)) { + this.rewrite(value ? 'pr' : 'off'); + } + } +} diff --git a/lib/config/migrations/migrations-service.ts b/lib/config/migrations/migrations-service.ts index e7e3b314bb51d1..4818e0f2c2a55b 100644 --- a/lib/config/migrations/migrations-service.ts +++ b/lib/config/migrations/migrations-service.ts @@ -20,6 +20,7 @@ import { DepTypesMigration } from './custom/dep-types-migration'; import { DryRunMigration } from './custom/dry-run-migration'; import { EnabledManagersMigration } from './custom/enabled-managers-migration'; import { ExtendsMigration } from './custom/extends-migration'; +import { FetchReleaseNotesMigration } from './custom/fetch-release-notes-migration'; import { GoModTidyMigration } from './custom/go-mod-tidy-migration'; import { HostRulesMigration } from './custom/host-rules-migration'; import { IgnoreNodeModulesMigration } from './custom/ignore-node-modules-migration'; @@ -148,6 +149,7 @@ export class MigrationsService { DatasourceMigration, RecreateClosedMigration, StabilityDaysMigration, + FetchReleaseNotesMigration, ]; static run(originalConfig: RenovateConfig): RenovateConfig { diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index eb314221a872df..1635e2d1c54c96 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -2540,9 +2540,10 @@ const options: RenovateOptions[] = [ }, { name: 'fetchReleaseNotes', - description: 'Controls if release notes are fetched.', - type: 'boolean', - default: true, + description: 'Controls if and when release notes are fetched.', + type: 'string', + allowedValues: ['off', 'branch', 'pr'], + default: 'pr', cli: false, env: false, }, diff --git a/lib/config/types.ts b/lib/config/types.ts index 9fbabb40fa68ac..b8646e16cfcc0d 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -258,7 +258,7 @@ export interface RenovateConfig vulnerabilitySeverity?: string; regexManagers?: RegExManager[]; - fetchReleaseNotes?: boolean; + fetchReleaseNotes?: FetchReleaseNotesOptions; secrets?: Record; constraints?: Record; @@ -299,6 +299,8 @@ export type UpdateType = | 'bump' | 'replacement'; +export type FetchReleaseNotesOptions = 'off' | 'branch' | 'pr'; + export type MatchStringsStrategy = 'any' | 'recursive' | 'combination'; export type MergeStrategy = diff --git a/lib/workers/repository/changelog/index.spec.ts b/lib/workers/repository/changelog/index.spec.ts index 5ad0dd54bf60c4..709103b105b098 100644 --- a/lib/workers/repository/changelog/index.spec.ts +++ b/lib/workers/repository/changelog/index.spec.ts @@ -1,7 +1,7 @@ import { mockedFunction, partial } from '../../../../test/util'; import type { BranchUpgradeConfig } from '../../types'; import { getChangeLogJSON } from '../update/pr/changelog'; -import { embedChangelogs, needsChangelogs } from '.'; +import { embedChangelogs } from '.'; jest.mock('../update/pr/changelog'); @@ -27,23 +27,4 @@ describe('workers/repository/changelog/index', () => { { logJSON: null }, ]); }); - - it('needsChangelogs', () => { - expect(needsChangelogs(partial())).toBeFalse(); - expect( - needsChangelogs( - partial({ - commitBody: '{{#if logJSON.hasReleaseNotes}}has changelog{{/if}}', - }) - ) - ).toBeFalse(); - expect( - needsChangelogs( - partial({ - commitBody: '{{#if logJSON.hasReleaseNotes}}has changelog{{/if}}', - }), - ['commitBody'] - ) - ).toBeTrue(); - }); }); diff --git a/lib/workers/repository/changelog/index.ts b/lib/workers/repository/changelog/index.ts index 8bc6c455590223..f6c6c6ca4f6881 100644 --- a/lib/workers/repository/changelog/index.ts +++ b/lib/workers/repository/changelog/index.ts @@ -1,8 +1,4 @@ import * as p from '../../../util/promises'; -import { - containsTemplates, - exposedConfigOptions, -} from '../../../util/template'; import type { BranchUpgradeConfig } from '../../types'; import { getChangeLogJSON } from '../update/pr/changelog'; @@ -21,17 +17,3 @@ export async function embedChangelogs( ): Promise { await p.map(branches, embedChangelog, { concurrency: 10 }); } - -export function needsChangelogs( - upgrade: BranchUpgradeConfig, - fields = exposedConfigOptions.filter((o) => o !== 'commitBody') -): boolean { - // commitBody is now compiled when commit is done - for (const field of fields) { - // fields set by `getChangeLogJSON` - if (containsTemplates(upgrade[field], ['logJSON', 'releases'])) { - return true; - } - } - return false; -} diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index fb98eda0326aa6..ebb9d62ba954cf 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -2,7 +2,6 @@ import { fs, git, mocked, - mockedFunction, partial, platform, scm, @@ -34,7 +33,6 @@ import * as _mergeConfidence from '../../../../util/merge-confidence'; import * as _sanitize from '../../../../util/sanitize'; import * as _limits from '../../../global/limits'; import type { BranchConfig, BranchUpgradeConfig } from '../../../types'; -import { needsChangelogs } from '../../changelog'; import type { ResultWithPr } from '../pr'; import * as _prWorker from '../pr'; import * as _prAutomerge from '../pr/automerge'; @@ -816,9 +814,8 @@ describe('workers/repository/update/branch/index', () => { ignoreTests: true, prCreation: 'not-pending', commitBody: '[skip-ci]', - fetchReleaseNotes: true, + fetchReleaseNotes: 'branch', } satisfies BranchConfig; - mockedFunction(needsChangelogs).mockReturnValueOnce(true); scm.getBranchCommit.mockResolvedValue('123test'); //TODO:not needed? expect(await branchWorker.processBranch(inconfig)).toEqual({ branchExists: true, diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index b66fd7850efbe1..64080d340707ec 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -34,7 +34,7 @@ import { toMs } from '../../../../util/pretty-time'; import * as template from '../../../../util/template'; import { isLimitReached } from '../../../global/limits'; import type { BranchConfig, BranchResult, PrBlockedBy } from '../../../types'; -import { embedChangelog, needsChangelogs } from '../../changelog'; +import { embedChangelogs } from '../../changelog'; import { ensurePr } from '../pr'; import { checkAutoMerge } from '../pr/automerge'; import { setArtifactErrorStatus } from './artifacts'; @@ -482,6 +482,10 @@ export async function processBranch( } else { logger.debug('No updated lock files in branch'); } + if (config.fetchReleaseNotes === 'branch') { + await embedChangelogs(config.upgrades); + } + const postUpgradeCommandResults = await executePostUpgradeCommands( config ); @@ -540,14 +544,6 @@ export async function processBranch( // compile commit message with body, which maybe needs changelogs if (config.commitBody) { - if ( - config.fetchReleaseNotes && - needsChangelogs(config, ['commitBody']) - ) { - // we only need first upgrade, the others are only needed on PR update - // we add it to first, so PR fetch can skip fetching for that update - await embedChangelog(config.upgrades[0]); - } // changelog is on first upgrade config.commitMessage = `${config.commitMessage!}\n\n${template.compile( config.commitBody, diff --git a/lib/workers/repository/update/pr/index.spec.ts b/lib/workers/repository/update/pr/index.spec.ts index 06caf733c26267..7316ea6f0e5e09 100644 --- a/lib/workers/repository/update/pr/index.spec.ts +++ b/lib/workers/repository/update/pr/index.spec.ts @@ -102,7 +102,7 @@ describe('workers/repository/update/pr/index', () => { platform.createPr.mockResolvedValueOnce(pr); limits.isLimitReached.mockReturnValueOnce(true); - config.fetchReleaseNotes = true; + config.fetchReleaseNotes = 'pr'; const res = await ensurePr(config); @@ -871,13 +871,13 @@ describe('workers/repository/update/pr/index', () => { bodyFingerprint: fingerprint( generatePrBodyFingerprintConfig({ ...config, - fetchReleaseNotes: true, + fetchReleaseNotes: 'pr', }) ), lastEdited: new Date('2020-01-20T00:00:00Z').toISOString(), }; prCache.getPrCache.mockReturnValueOnce(cachedPr); - const res = await ensurePr({ ...config, fetchReleaseNotes: true }); + const res = await ensurePr({ ...config, fetchReleaseNotes: 'pr' }); expect(res).toEqual({ type: 'with-pr', pr: existingPr, @@ -904,13 +904,13 @@ describe('workers/repository/update/pr/index', () => { bodyFingerprint: fingerprint( generatePrBodyFingerprintConfig({ ...config, - fetchReleaseNotes: true, + fetchReleaseNotes: 'pr', }) ), lastEdited: new Date('2020-01-20T00:00:00Z').toISOString(), }; prCache.getPrCache.mockReturnValueOnce(cachedPr); - const res = await ensurePr({ ...config, fetchReleaseNotes: true }); + const res = await ensurePr({ ...config, fetchReleaseNotes: 'pr' }); expect(res).toEqual({ type: 'with-pr', pr: { diff --git a/lib/workers/repository/update/pr/index.ts b/lib/workers/repository/update/pr/index.ts index 2a2dea9432c145..89316d8409f8ca 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -233,7 +233,7 @@ export async function ensurePr( }`; } - if (config.fetchReleaseNotes) { + if (config.fetchReleaseNotes === 'pr') { // fetch changelogs when not already done; await embedChangelogs(upgrades); } diff --git a/lib/workers/repository/updates/branchify.spec.ts b/lib/workers/repository/updates/branchify.spec.ts index 37c98be11dba29..99c0d262bb4990 100644 --- a/lib/workers/repository/updates/branchify.spec.ts +++ b/lib/workers/repository/updates/branchify.spec.ts @@ -1,4 +1,4 @@ -import { RenovateConfig, mocked, mockedFunction } from '../../../../test/util'; +import { RenovateConfig, mocked } from '../../../../test/util'; import { getConfig } from '../../../config/defaults'; import * as _changelog from '../changelog'; import { branchifyUpgrades } from './branchify'; @@ -124,7 +124,7 @@ describe('workers/repository/updates/branchify', () => { }); it('no fetch changelogs', async () => { - config.fetchReleaseNotes = false; + config.fetchReleaseNotes = 'off'; flattenUpdates.mockResolvedValueOnce([ { depName: 'foo', @@ -153,38 +153,5 @@ describe('workers/repository/updates/branchify', () => { expect(embedChangelogs).not.toHaveBeenCalled(); expect(Object.keys(res.branches)).toHaveLength(2); }); - - it('fetch changelogs if required', async () => { - config.fetchReleaseNotes = true; - config.repoIsOnboarded = true; - mockedFunction(_changelog.needsChangelogs).mockReturnValueOnce(true); - flattenUpdates.mockResolvedValueOnce([ - { - depName: 'foo', - branchName: 'foo', - prTitle: 'some-title', - version: '1.1.0', - groupName: 'My Group', - group: { branchName: 'renovate/{{groupSlug}}' }, - }, - { - depName: 'foo', - branchName: 'foo', - prTitle: 'some-title', - version: '2.0.0', - }, - { - depName: 'bar', - branchName: 'bar-{{version}}', - prTitle: 'some-title', - version: '1.1.0', - groupName: 'My Group', - group: { branchName: 'renovate/my-group' }, - }, - ]); - const res = await branchifyUpgrades(config, {}); - expect(embedChangelogs).toHaveBeenCalledOnce(); - expect(Object.keys(res.branches)).toHaveLength(2); - }); }); }); diff --git a/lib/workers/repository/updates/branchify.ts b/lib/workers/repository/updates/branchify.ts index 4401fb4341640d..d6d0ccf12e53aa 100644 --- a/lib/workers/repository/updates/branchify.ts +++ b/lib/workers/repository/updates/branchify.ts @@ -3,7 +3,6 @@ import type { Merge } from 'type-fest'; import type { RenovateConfig, ValidationMessage } from '../../../config/types'; import { addMeta, logger, removeMeta } from '../../../logger'; import type { BranchConfig, BranchUpgradeConfig } from '../../types'; -import { embedChangelogs, needsChangelogs } from '../changelog'; import { flattenUpdates } from './flatten'; import { generateBranchConfig } from './generate'; @@ -72,22 +71,6 @@ export async function branchifyUpgrades( }) .reverse(); - if (config.fetchReleaseNotes && config.repoIsOnboarded) { - const branches = branchUpgrades[branchName].filter((upg) => - needsChangelogs(upg) - ); - if (branches.length) { - logger.warn( - { - branches: branches.map((b) => b.branchName), - docs: 'https://docs.renovatebot.com/templates/', - }, - 'Fetching changelogs early is deprecated. Remove `logJSON` and `releases` from config templates. They are only allowed in `commitBody` template. See template docs for allowed templates' - ); - await embedChangelogs(branches); - } - } - const branch = generateBranchConfig(branchUpgrades[branchName]); branch.branchName = branchName; branch.packageFiles = packageFiles; From e094aecd4292e6877359fd591b966856471ae830 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 24 Jun 2023 16:33:20 +0200 Subject: [PATCH 22/22] simplify --- lib/util/package-rules/package-names.ts | 2 +- lib/util/package-rules/package-patterns.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/util/package-rules/package-names.ts b/lib/util/package-rules/package-names.ts index 2671720099c587..8e647a8014e7b9 100644 --- a/lib/util/package-rules/package-names.ts +++ b/lib/util/package-rules/package-names.ts @@ -15,7 +15,7 @@ export class PackageNameMatcher extends Matcher { return false; } - if (matchPackageNames.includes(packageName || depName)) { + if (is.string(packageName) && matchPackageNames.includes(packageName)) { return true; } diff --git a/lib/util/package-rules/package-patterns.ts b/lib/util/package-rules/package-patterns.ts index f52ea243460597..a7fc03e2c02911 100644 --- a/lib/util/package-rules/package-patterns.ts +++ b/lib/util/package-rules/package-patterns.ts @@ -32,7 +32,8 @@ export class PackagePatternsMatcher extends Matcher { } if ( - matchPatternsAgainstName(matchPackagePatterns, packageName || depName) + is.string(packageName) && + matchPatternsAgainstName(matchPackagePatterns, packageName) ) { return true; }