diff --git a/lib/workers/repository/errors-warnings.spec.ts b/lib/workers/repository/errors-warnings.spec.ts index 382f5baaef622128f47fc252270c474904a26fc4..c935be6022bc3e84c6a43f7382039b5fb849fce0 100644 --- a/lib/workers/repository/errors-warnings.spec.ts +++ b/lib/workers/repository/errors-warnings.spec.ts @@ -51,6 +51,7 @@ describe('workers/repository/errors-warnings', () => { }); it('returns 2 pr warnings text dependencyDashboard true', () => { + const config: RenovateConfig = {}; const dependencyDashboard = true; const packageFiles: Record<string, PackageFile[]> = { npm: [ @@ -84,7 +85,7 @@ describe('workers/repository/errors-warnings', () => { ], }; - const res = getDepWarningsPR(packageFiles, dependencyDashboard); + const res = getDepWarningsPR(packageFiles, config, dependencyDashboard); expect(res).toMatchInlineSnapshot(` " --- @@ -98,6 +99,7 @@ describe('workers/repository/errors-warnings', () => { }); it('returns 2 pr warnings text dependencyDashboard false', () => { + const config: RenovateConfig = {}; const dependencyDashboard = false; const packageFiles: Record<string, PackageFile[]> = { npm: [ @@ -131,7 +133,7 @@ describe('workers/repository/errors-warnings', () => { ], }; - const res = getDepWarningsPR(packageFiles, dependencyDashboard); + const res = getDepWarningsPR(packageFiles, config, dependencyDashboard); expect(res).toMatchInlineSnapshot(` " --- @@ -145,8 +147,18 @@ describe('workers/repository/errors-warnings', () => { }); it('PR warning returns empty string', () => { + const config: RenovateConfig = {}; + const packageFiles: Record<string, PackageFile[]> = {}; + const res = getDepWarningsPR(packageFiles, config); + expect(res).toBe(''); + }); + + it('suppress notifications contains dependencyLookupWarnings flag then return empty string', () => { + const config: RenovateConfig = { + suppressNotifications: ['dependencyLookupWarnings'], + }; const packageFiles: Record<string, PackageFile[]> = {}; - const res = getDepWarningsPR(packageFiles); + const res = getDepWarningsPR(packageFiles, config); expect(res).toBe(''); }); }); @@ -261,6 +273,7 @@ describe('workers/repository/errors-warnings', () => { describe('getDepWarningsOnboardingPR()', () => { it('returns onboarding warning text', () => { + const config: RenovateConfig = {}; const packageFiles: Record<string, PackageFile[]> = { npm: [ { @@ -292,7 +305,7 @@ describe('workers/repository/errors-warnings', () => { }, ], }; - const res = getDepWarningsOnboardingPR(packageFiles); + const res = getDepWarningsOnboardingPR(packageFiles, config); expect(res).toMatchInlineSnapshot(` " --- @@ -309,5 +322,14 @@ describe('workers/repository/errors-warnings', () => { " `); }); + + it('suppress notifications contains dependencyLookupWarnings flag then return empty string', () => { + const config: RenovateConfig = { + suppressNotifications: ['dependencyLookupWarnings'], + }; + const packageFiles: Record<string, PackageFile[]> = {}; + const res = getDepWarningsOnboardingPR(packageFiles, config); + expect(res).toBe(''); + }); }); }); diff --git a/lib/workers/repository/errors-warnings.ts b/lib/workers/repository/errors-warnings.ts index 56b17dc46304a6441c383f39442bcadb5794e94a..d06f2bb1c723c960b67e75800fccce9c3c618e64 100644 --- a/lib/workers/repository/errors-warnings.ts +++ b/lib/workers/repository/errors-warnings.ts @@ -59,9 +59,13 @@ function getDepWarnings( } export function getDepWarningsOnboardingPR( - packageFiles: Record<string, PackageFile[]> + packageFiles: Record<string, PackageFile[]>, + config: RenovateConfig ): string { const { warnings, warningFiles } = getDepWarnings(packageFiles); + if (config.suppressNotifications?.includes('dependencyLookupWarnings')) { + return ''; + } let warningText = ''; if (!warnings.length) { return ''; @@ -83,9 +87,13 @@ export function getDepWarningsOnboardingPR( export function getDepWarningsPR( packageFiles: Record<string, PackageFile[]>, + config: RenovateConfig, dependencyDashboard?: boolean ): string { const { warnings, warningFiles } = getDepWarnings(packageFiles); + if (config.suppressNotifications?.includes('dependencyLookupWarnings')) { + return ''; + } let warningText = ''; if (!warnings.length) { return ''; diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts index 2bf76f3ee5526b561ca3616525b963e2484928a2..e391fc8dd008621ec701c79e9855b099e8743a5c 100644 --- a/lib/workers/repository/onboarding/pr/index.ts +++ b/lib/workers/repository/onboarding/pr/index.ts @@ -122,7 +122,7 @@ If you need any further assistance then you can also [request help here](${ prBody = prBody.replace('{{CONFIG}}\n', configDesc); prBody = prBody.replace( '{{WARNINGS}}\n', - getWarnings(config) + getDepWarningsOnboardingPR(packageFiles!) + getWarnings(config) + getDepWarningsOnboardingPR(packageFiles!, config) ); prBody = prBody.replace('{{ERRORS}}\n', getErrors(config)); prBody = prBody.replace('{{BASEBRANCH}}\n', getBaseBranchDesc(config)); diff --git a/lib/workers/repository/update/pr/body/index.spec.ts b/lib/workers/repository/update/pr/body/index.spec.ts index 207fab4f0735f801f51cc302ffa52e7b11050eea..a60caf1a6d226f74562475379b8e015f0bdf9a97 100644 --- a/lib/workers/repository/update/pr/body/index.spec.ts +++ b/lib/workers/repository/update/pr/body/index.spec.ts @@ -64,7 +64,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); expect(res).toBeEmptyString(); }); @@ -94,7 +95,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); expect(upgrade).toMatchObject({ @@ -132,7 +134,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); expect(upgrade).toMatchObject({ @@ -160,7 +163,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); expect(res).toContain('PR BODY'); expect(res).toContain(`<!--renovate-debug`); @@ -184,7 +188,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); expect(res).toContain(['aaa', '**Rebasing**: BAR', 'bbb'].join('\n')); }); @@ -206,7 +211,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); const match = prDebugDataRe.exec(res); @@ -255,7 +261,8 @@ describe('workers/repository/update/pr/body/index', () => { createdInVer: '1.2.3', targetBranch: 'base', }, - } + }, + {} ); const expected = '---\n\n### âš Dependency Lookup Warnings âš ' + diff --git a/lib/workers/repository/update/pr/body/index.ts b/lib/workers/repository/update/pr/body/index.ts index 23aca1b5dcbde6edc6afd9cc12c668fa8169bb83..ee8d89e99bfccfcfdc5030dea1282e9fa698b327 100644 --- a/lib/workers/repository/update/pr/body/index.ts +++ b/lib/workers/repository/update/pr/body/index.ts @@ -1,3 +1,4 @@ +import type { RenovateConfig } from '../../../../../config/types'; import { PrDebugData, platform } from '../../../../../modules/platform'; import { regEx } from '../../../../../util/regex'; import { toBase64 } from '../../../../../util/string'; @@ -67,7 +68,8 @@ const rebasingRegex = regEx(/\*\*Rebasing\*\*: .*/); export function getPrBody( branchConfig: BranchConfig, - prBodyConfig: PrBodyConfig + prBodyConfig: PrBodyConfig, + config: RenovateConfig ): string { massageUpdateMetadata(branchConfig); let warnings = ''; @@ -75,6 +77,7 @@ export function getPrBody( if (branchConfig.packageFiles) { warnings += getDepWarningsPR( branchConfig.packageFiles, + config, branchConfig.dependencyDashboard ); } diff --git a/lib/workers/repository/update/pr/index.ts b/lib/workers/repository/update/pr/index.ts index 2a2dea9432c145e78f73c4feb66368d412ef9d1d..ff626d34a0171105f3abbc508d5235b2a4c3bc5e 100644 --- a/lib/workers/repository/update/pr/index.ts +++ b/lib/workers/repository/update/pr/index.ts @@ -315,12 +315,16 @@ export async function ensurePr( } } - const prBody = getPrBody(config, { - debugData: updatePrDebugData( - config.baseBranch, - existingPr?.bodyStruct?.debugData - ), - }); + const prBody = getPrBody( + config, + { + debugData: updatePrDebugData( + config.baseBranch, + existingPr?.bodyStruct?.debugData + ), + }, + config + ); try { if (existingPr) {