From f70f0c82beda4712f11f93a4a111ca4f56d4ea5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=BB=D0=BB=D1=8F=20=D0=9C=D0=B0=D0=B7=D1=83=D1=80?= =?UTF-8?q?=D1=8F=D0=BA?= <illay1994@gmail.com> Date: Sun, 5 Nov 2023 19:32:59 +0100 Subject: [PATCH] feat(changelogs): Migrate fetchReleaseNotes to fetchChangeLogs (#25364) Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> Co-authored-by: Rhys Arkins <rhys@arkins.net> --- docs/usage/configuration-options.md | 25 +++++++++--------- docs/usage/dependency-pinning.md | 2 +- docs/usage/examples/self-hosting.md | 2 +- .../usage/getting-started/private-packages.md | 6 ++--- docs/usage/getting-started/running.md | 4 +-- docs/usage/getting-started/use-cases.md | 2 +- docs/usage/key-concepts/automerge.md | 2 +- docs/usage/self-hosted-configuration.md | 2 +- .../fetch-release-notes-migration.spec.ts | 26 ++++++++++++++++++- .../custom/fetch-release-notes-migration.ts | 20 +++++++++++--- lib/config/options/index.ts | 4 +-- lib/config/types.ts | 4 +-- .../repository/update/branch/index.spec.ts | 2 +- lib/workers/repository/update/branch/index.ts | 2 +- .../repository/update/pr/index.spec.ts | 10 +++---- lib/workers/repository/update/pr/index.ts | 2 +- .../repository/updates/branchify.spec.ts | 2 +- 17 files changed, 77 insertions(+), 40 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 94e9aa0927..dd3cdf42b6 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -1276,29 +1276,30 @@ A similar one could strip leading `v` prefixes: } ``` -## fetchReleaseNotes +## fetchChangeLogs -Use this config option to configure release notes fetching. +Use this config option to configure changelogs/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 +- `off` - disable changelogs fetching +- `branch` - fetch changelogs while creating/updating branch +- `pr`(default) - fetches changelogs 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. +Avoid setting `fetchChangeLogs=branch`, because this slows down Renovate. +But if you're embedding changelogs in commit information, you may use `fetchChangeLogs=branch`. -Renovate can fetch release notes when they are hosted on one of these platforms: +Renovate can fetch changelogs when they are hosted on one of these platforms: - Bitbucket Cloud - GitHub (.com and Enterprise Server) - GitLab (.com and CE/EE) -If you are running on any platform except `github.com`, you need to [configure a Personal Access Token](./getting-started/running.md#githubcom-token-for-release-notes) to allow Renovate to fetch release notes from `github.com`. +If you are running on any platform except `github.com`, you need to [configure a Personal Access Token](./getting-started/running.md#githubcom-token-for-release-notes) to allow Renovate to fetch changelogs notes from `github.com`. <!-- prettier-ignore --> !!! note - Renovate can only show release notes from some platforms and some package managers. - We're planning improvements so that Renovate can show more release notes. + Renovate can only show changelogs from some platforms and some package managers. + We're planning improvements so that Renovate can show more changelogs. Read [issue 14138 on GitHub](https://github.com/renovatebot/renovate/issues/14138) to get an overview of the planned work. ## fileMatch @@ -2776,9 +2777,9 @@ Tokens can be configured via `hostRules` using the `"merge-confidence"` `hostTyp ### customChangelogUrl Use this field to set the source URL for a package, including overriding an existing one. -Source URLs are necessary in order to look up release notes. +Source URLs are necessary in order to look up changelogs. -Using this field we can specify the exact URL to fetch release notes from. +Using this field we can specify the exact URL to fetch changelogs from. ```json title="Setting the source URL for the dummy package" { diff --git a/docs/usage/dependency-pinning.md b/docs/usage/dependency-pinning.md index 14a569a7b5..185d136c22 100644 --- a/docs/usage/dependency-pinning.md +++ b/docs/usage/dependency-pinning.md @@ -76,7 +76,7 @@ If you were using SemVer ranges then this new version of `foobar` will likely be Like before, you need to manually work out which dependency caused it - assuming you guess correctly that it was a new dependency version at fault - and pin it manually by editing `package.json` one dependency at a time. Alternatively, if you were instead pinning `foobar` then you would get a PR for `foobar@1.2.0` which awaits your approval. -So first of all, you can choose to read the release notes and/or visually inspect the branch yourself before merging, hopefully saving you from pushing this faulty code to production. +So first of all, you can choose to read the changelogs and/or visually inspect the branch yourself before merging, hopefully saving you from pushing this faulty code to production. If you did not catch the fault before merging, you are still better off with a pinned version. If you discover something wrong in production, you can easily "roll back" commits in your development environment until you find which rollback fixes the problem. diff --git a/docs/usage/examples/self-hosting.md b/docs/usage/examples/self-hosting.md index 28ec2baf62..1545063e08 100644 --- a/docs/usage/examples/self-hosting.md +++ b/docs/usage/examples/self-hosting.md @@ -278,7 +278,7 @@ Only add the script to `cron` after you checked it works. <!-- prettier-ignore --> !!! note - The GitHub.com token as an environment variable is needed to fetch Release Notes that are usually hosted on github.com. + The GitHub.com token as an environment variable is needed to fetch changelogs that are usually hosted on github.com. You don't need to add it if you are already running the bot against github.com, but you do need to add it if you're using GitHub Enterprise Server, GitLab, Azure DevOps, or Bitbucket. ## Kubernetes for GitLab, using Git over SSH diff --git a/docs/usage/getting-started/private-packages.md b/docs/usage/getting-started/private-packages.md index 9e5dad243e..6016669246 100644 --- a/docs/usage/getting-started/private-packages.md +++ b/docs/usage/getting-started/private-packages.md @@ -20,7 +20,7 @@ There are four times in Renovate's behavior when it may need credentials: - Resolving private config presets - Looking up dependency versions -- Looking up release notes +- Looking up changelogs - Passing to package managers when updating lock files or checksums <!-- prettier-ignore --> @@ -142,14 +142,14 @@ Assume this config is used on the `github.com/some-other-org` repo: } ``` -## Looking up Release Notes +## Looking up changelogs When Renovate creates Pull Requests, its default behavior is to locate and embed release notes/changelogs of packages. These release notes are fetched from the source repository of packages and not from the registries themselves, so if they are private then they will require different credentials. When it comes to open source, most packages host their source on `github.com` in public repositories. GitHub greatly rate limits unauthenticated API requests, so you need to configure credentials for `github.com` or the bot will get rate limited quickly. -It can be confusing for people who host their own source code privately to be asked to configure a `github.com` token but without it Release Notes for most open source packages will be blocked. +It can be confusing for people who host their own source code privately to be asked to configure a `github.com` token but without it changelogs for most open source packages will be blocked. Currently the preferred way to configure `github.com` credentials for self-hosted Renovate is: diff --git a/docs/usage/getting-started/running.md b/docs/usage/getting-started/running.md index e710ed7f5f..76b7ff5466 100644 --- a/docs/usage/getting-started/running.md +++ b/docs/usage/getting-started/running.md @@ -209,11 +209,11 @@ Read the platform-specific docs to learn how to setup authentication on your pla - [github.com and GitHub Enterprise Server](https://docs.renovatebot.com/modules/platform/github/) - [GitLab](https://docs.renovatebot.com/modules/platform/gitlab/) -### GitHub.com token for release notes +### GitHub.com token for changelogs If you are running on any platform except github.com, you should also set the environment variable `GITHUB_COM_TOKEN` and put the Personal Access Token for github.com in it. This account can be _any_ account on GitHub, and needs only `read-only` access. -It's used when fetching release notes for repositories in order to increase the hourly API limit. +It's used when fetching changelogs for repositories in order to increase the hourly API limit. It's also OK to configure the same as a host rule instead, if you prefer that. <!-- prettier-ignore --> diff --git a/docs/usage/getting-started/use-cases.md b/docs/usage/getting-started/use-cases.md index 5ab2f1c1fe..b7d5646599 100644 --- a/docs/usage/getting-started/use-cases.md +++ b/docs/usage/getting-started/use-cases.md @@ -25,7 +25,7 @@ Renovate: 1. Checks if any newer versions exist 1. Raises Pull Requests for available updates -The Pull Requests patch the package files directly, and include Release Notes for the newer versions (if they are available). +The Pull Requests patch the package files directly, and include changelogs for the newer versions (if they are available). By default: diff --git a/docs/usage/key-concepts/automerge.md b/docs/usage/key-concepts/automerge.md index 0e1edc0c49..0dee679204 100644 --- a/docs/usage/key-concepts/automerge.md +++ b/docs/usage/key-concepts/automerge.md @@ -19,7 +19,7 @@ This means merging multiple branches in a row won't work reliably, so we prefer What all this means is that Renovate will only automerge at most one branch/PR per target branch per run, before you need to wait for the next run. As a general guide, we recommend that you enable automerge for any type of dependency updates where you would select "merge" anyway. -For any updates where you want to review the release notes - or code - before you merge, you can keep automerge disabled. +For any updates where you want to review the changelogs - or code - before you merge, you can keep automerge disabled. Automerge works particularly well for `devDependencies` as well as for production `dependencies` in projects which have great test coverage. diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index 60d6cb7d5b..c5fc1b5967 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -759,7 +759,7 @@ Override this object if you want to change the URLs that Renovate links to, e.g. ## redisUrl If this value is set then Renovate will use Redis for its global cache instead of the local file system. -The global cache is used to store lookup results (e.g. dependency versions and release notes) between repositories and runs. +The global cache is used to store lookup results (e.g. dependency versions and changelogs) between repositories and runs. For non encrypted connections, diff --git a/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts b/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts index 2e17148597..fc15f7d488 100644 --- a/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts +++ b/lib/config/migrations/custom/fetch-release-notes-migration.spec.ts @@ -7,15 +7,39 @@ describe('config/migrations/custom/fetch-release-notes-migration', () => { fetchReleaseNotes: false as never, }, { - fetchReleaseNotes: 'off', + fetchChangeLogs: 'off', } ); expect(FetchReleaseNotesMigration).toMigrate( { fetchReleaseNotes: true as never, }, + { + fetchChangeLogs: 'pr', + } + ); + expect(FetchReleaseNotesMigration).toMigrate( { fetchReleaseNotes: 'pr', + }, + { + fetchChangeLogs: 'pr', + } + ); + expect(FetchReleaseNotesMigration).toMigrate( + { + fetchReleaseNotes: 'off', + }, + { + fetchChangeLogs: 'off', + } + ); + expect(FetchReleaseNotesMigration).toMigrate( + { + fetchReleaseNotes: 'branch', + }, + { + fetchChangeLogs: 'branch', } ); }); diff --git a/lib/config/migrations/custom/fetch-release-notes-migration.ts b/lib/config/migrations/custom/fetch-release-notes-migration.ts index 60b7afe6ea..dda051f8fa 100644 --- a/lib/config/migrations/custom/fetch-release-notes-migration.ts +++ b/lib/config/migrations/custom/fetch-release-notes-migration.ts @@ -1,12 +1,24 @@ import is from '@sindresorhus/is'; -import { AbstractMigration } from '../base/abstract-migration'; +import type { RenovateConfig } from '../../types'; +import { RenamePropertyMigration } from '../base/rename-property-migration'; -export class FetchReleaseNotesMigration extends AbstractMigration { - override readonly propertyName = 'fetchReleaseNotes'; +export class FetchReleaseNotesMigration extends RenamePropertyMigration { + constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { + super( + 'fetchReleaseNotes', + 'fetchChangeLogs', + originalConfig, + migratedConfig + ); + } override run(value: unknown): void { + let newValue: unknown = value; + if (is.boolean(value)) { - this.rewrite(value ? 'pr' : 'off'); + newValue = value ? 'pr' : 'off'; } + + super.run(newValue); } } diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index 9449762b77..ded1bd3602 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -2621,8 +2621,8 @@ const options: RenovateOptions[] = [ env: false, }, { - name: 'fetchReleaseNotes', - description: 'Controls if and when release notes are fetched.', + name: 'fetchChangeLogs', + description: 'Controls if and when changelogs/release notes are fetched.', type: 'string', allowedValues: ['off', 'branch', 'pr'], default: 'pr', diff --git a/lib/config/types.ts b/lib/config/types.ts index 6a3178f6e0..0c4ef22649 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -250,7 +250,7 @@ export interface RenovateConfig customManagers?: CustomManager[]; customDatasources?: Record<string, CustomDatasourceConfig>; - fetchReleaseNotes?: FetchReleaseNotesOptions; + fetchChangeLogs?: FetchChangeLogsOptions; secrets?: Record<string, string>; constraints?: Record<string, string>; @@ -298,7 +298,7 @@ export type UpdateType = | 'bump' | 'replacement'; -export type FetchReleaseNotesOptions = 'off' | 'branch' | 'pr'; +export type FetchChangeLogsOptions = 'off' | 'branch' | 'pr'; export type MatchStringsStrategy = 'any' | 'recursive' | 'combination'; diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index df1b53166e..68bcbf57b0 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -836,7 +836,7 @@ describe('workers/repository/update/branch/index', () => { ignoreTests: true, prCreation: 'not-pending', commitBody: '[skip-ci]', - fetchReleaseNotes: 'branch', + fetchChangeLogs: 'branch', } satisfies BranchConfig; scm.getBranchCommit.mockResolvedValue('123test'); //TODO:not needed? expect(await branchWorker.processBranch(inconfig)).toEqual({ diff --git a/lib/workers/repository/update/branch/index.ts b/lib/workers/repository/update/branch/index.ts index a78d2f1fca..d7c5541117 100644 --- a/lib/workers/repository/update/branch/index.ts +++ b/lib/workers/repository/update/branch/index.ts @@ -490,7 +490,7 @@ export async function processBranch( } else { logger.debug('No updated lock files in branch'); } - if (config.fetchReleaseNotes === 'branch') { + if (config.fetchChangeLogs === 'branch') { await embedChangelogs(config.upgrades); } diff --git a/lib/workers/repository/update/pr/index.spec.ts b/lib/workers/repository/update/pr/index.spec.ts index 866eca46bc..77340a78f9 100644 --- a/lib/workers/repository/update/pr/index.spec.ts +++ b/lib/workers/repository/update/pr/index.spec.ts @@ -101,7 +101,7 @@ describe('workers/repository/update/pr/index', () => { platform.createPr.mockResolvedValueOnce(pr); limits.isLimitReached.mockReturnValueOnce(true); - config.fetchReleaseNotes = 'pr'; + config.fetchChangeLogs = 'pr'; const res = await ensurePr(config); @@ -871,13 +871,13 @@ describe('workers/repository/update/pr/index', () => { bodyFingerprint: fingerprint( generatePrBodyFingerprintConfig({ ...config, - fetchReleaseNotes: 'pr', + fetchChangeLogs: 'pr', }) ), lastEdited: new Date('2020-01-20T00:00:00Z').toISOString(), }; prCache.getPrCache.mockReturnValueOnce(cachedPr); - const res = await ensurePr({ ...config, fetchReleaseNotes: 'pr' }); + const res = await ensurePr({ ...config, fetchChangeLogs: 'pr' }); expect(res).toEqual({ type: 'with-pr', pr: existingPr, @@ -904,13 +904,13 @@ describe('workers/repository/update/pr/index', () => { bodyFingerprint: fingerprint( generatePrBodyFingerprintConfig({ ...config, - fetchReleaseNotes: 'pr', + fetchChangeLogs: 'pr', }) ), lastEdited: new Date('2020-01-20T00:00:00Z').toISOString(), }; prCache.getPrCache.mockReturnValueOnce(cachedPr); - const res = await ensurePr({ ...config, fetchReleaseNotes: 'pr' }); + const res = await ensurePr({ ...config, fetchChangeLogs: '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 dbe17da722..36bd01f8a2 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -234,7 +234,7 @@ export async function ensurePr( }`; } - if (config.fetchReleaseNotes === 'pr') { + if (config.fetchChangeLogs === '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 a190b65f17..1a52fdd718 100644 --- a/lib/workers/repository/updates/branchify.spec.ts +++ b/lib/workers/repository/updates/branchify.spec.ts @@ -123,7 +123,7 @@ describe('workers/repository/updates/branchify', () => { }); it('no fetch changelogs', async () => { - config.fetchReleaseNotes = 'off'; + config.fetchChangeLogs = 'off'; flattenUpdates.mockResolvedValueOnce([ { depName: 'foo', -- GitLab