Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show warning in pr body #17609

Merged
merged 28 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
68b81e6
feat: show warnings in pr body
MaronHatoum Sep 1, 2022
591b469
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 1, 2022
70ab4b7
feat: update
MaronHatoum Sep 1, 2022
cf99bd8
feat: update
MaronHatoum Sep 1, 2022
028fea7
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 4, 2022
e8ca489
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 4, 2022
5a1809a
feat: update
MaronHatoum Sep 4, 2022
fb3cad9
feat: update
MaronHatoum Sep 4, 2022
7f67c5d
Merge branch 'main' into feat/show-warning-pr-body
MaronHatoum Sep 4, 2022
fd9525f
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 5, 2022
a154d35
feat: update
MaronHatoum Sep 5, 2022
9186327
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 5, 2022
d2fba01
feat: update
MaronHatoum Sep 5, 2022
2588209
feat: update
MaronHatoum Sep 5, 2022
1c8abb7
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 5, 2022
2e02584
feat: update
MaronHatoum Sep 5, 2022
d509cd1
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 6, 2022
a98fc9f
feat: update
MaronHatoum Sep 6, 2022
2ad0651
Merge branch 'main' into feat/show-warning-pr-body
MaronHatoum Sep 6, 2022
f4f3ddb
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 6, 2022
10bfcd7
feat: update
MaronHatoum Sep 6, 2022
f4b0198
Merge branch 'main' of https://github.com/renovatebot/renovate into f…
MaronHatoum Sep 7, 2022
5bdc8b4
feat: update
MaronHatoum Sep 7, 2022
36155f8
Merge branch 'main' into feat/show-warning-pr-body
MaronHatoum Sep 7, 2022
e518ac6
Merge branch 'main' into feat/show-warning-pr-body
MaronHatoum Sep 8, 2022
e770bd8
Merge branch 'main' into feat/show-warning-pr-body
rarkins Sep 8, 2022
eace1f7
Merge branch 'main' into feat/show-warning-pr-body
MaronHatoum Sep 11, 2022
7a68c76
Merge branch 'main' into feat/show-warning-pr-body
rarkins Sep 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ const options: RenovateOptions[] = [
'Pull Request body template. Controls which sections are rendered in the body.',
type: 'string',
default:
'{{{header}}}{{{table}}}{{{notes}}}{{{changelogs}}}{{{configDescription}}}{{{controls}}}{{{footer}}}',
'{{{header}}}{{{table}}}{{{warnings}}}{{{notes}}}{{{changelogs}}}{{{configDescription}}}{{{controls}}}{{{footer}}}',
cli: false,
},
{
Expand Down
55 changes: 49 additions & 6 deletions lib/workers/repository/errors-warnings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ describe('workers/repository/errors-warnings', () => {
jest.resetAllMocks();
});

it('returns pr warning text', () => {
it('returns 2 pr warnings text dependencyDashboard true', () => {
const dependencyDashboard = true;
const packageFiles: Record<string, PackageFile[]> = {
npm: [
{
Expand Down Expand Up @@ -82,19 +83,61 @@ describe('workers/repository/errors-warnings', () => {
],
};

const res = getDepWarningsPR(packageFiles);
const res = getDepWarningsPR(packageFiles, dependencyDashboard);
expect(res).toMatchInlineSnapshot(`
"
---

### ⚠ Dependency Lookup Warnings ⚠

Please correct - or verify that you can safely ignore - these lookup failures before you merge this PR.
Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.

- \`Warning 1\`
- \`Warning 2\`
"
`);
});

Files affected: \`package.json\`, \`backend/package.json\`, \`Dockerfile\`
it('returns 2 pr warnings text dependencyDashboard false', () => {
const dependencyDashboard = false;
const packageFiles: Record<string, PackageFile[]> = {
npm: [
{
packageFile: 'package.json',
deps: [
{
warnings: [{ message: 'Warning 1', topic: '' }],
},
{},
],
},
{
packageFile: 'backend/package.json',
deps: [
{
warnings: [{ message: 'Warning 1', topic: '' }],
},
],
},
],
dockerfile: [
{
packageFile: 'Dockerfile',
deps: [
{
warnings: [{ message: 'Warning 2', topic: '' }],
},
],
},
],
};

const res = getDepWarningsPR(packageFiles, dependencyDashboard);
expect(res).toMatchInlineSnapshot(`
"
---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check logs for more information.
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved

"
`);
Expand Down
15 changes: 7 additions & 8 deletions lib/workers/repository/errors-warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ function getDepWarnings(
}

export function getDepWarningsPR(
packageFiles: Record<string, PackageFile[]>
packageFiles: Record<string, PackageFile[]>,
dependencyDashboard?: boolean
): string {
const { warnings, warningFiles } = getDepWarnings(packageFiles);
let warningText = '';
Expand All @@ -69,14 +70,12 @@ export function getDepWarningsPR(
warningText = emojify(
`\n---\n\n### :warning: Dependency Lookup Warnings :warning:\n\n`
);
warningText += `Please correct - or verify that you can safely ignore - these lookup failures before you merge this PR.\n\n`;
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved
for (const w of warnings) {
warningText += `- \`${w}\`\n`;
warningText += 'Warnings were logged while processing this repo. ';
if (dependencyDashboard) {
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved
warningText += `Please check the Dependency Dashboard for more information.\n\n`;
} else {
warningText += `Please check logs for more information.\n\n`;
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved
}
warningText +=
'\nFiles affected: ' +
warningFiles.map((f) => '`' + f + '`').join(', ') +
'\n\n';
return warningText;
}

Expand Down
50 changes: 50 additions & 0 deletions lib/workers/repository/update/pr/body/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { mocked, platform } from '../../../../../../test/util';
import type { PackageFile } from '../../../../../modules/manager/types';
import { prDebugDataRe } from '../../../../../modules/platform/pr-body';
import * as _template from '../../../../../util/template';
import * as _changelogs from './changelogs';
Expand Down Expand Up @@ -199,5 +200,54 @@ describe('workers/repository/update/pr/body/index', () => {
const match = prDebugDataRe.exec(res);
expect(match?.groups?.payload).toBeString();
});

it('pr body warning', async () => {
const massagedMarkDown =
'---\n\n### ⚠ Dependency Lookup Warnings ⚠\n\n' +
'Warnings were logged while processing this repo. ' +
'Please check the Dependency Dashboard for further information\n\n---';
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved

const compiledContent =
'---\n\n\n\n### ⚠ Dependency Lookup Warnings ⚠' +
'\n\n\n\nWarnings were logged while processing this repo. ' +
'Please check the Dependency Dashboard for further information\n\n\n\n---';
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved

platform.massageMarkdown.mockImplementation((x) => massagedMarkDown);
template.compile.mockImplementation((x) => compiledContent);
const packageFiles: Record<string, PackageFile[]> = {
npm: [
{
packageFile: 'package.json',
deps: [
{
warnings: [{ message: 'Warning 1', topic: '' }],
},
{},
],
},
],
};

const res = await getPrBody(
{
manager: 'some-manager',
branchName: 'some-branch',
upgrades: [],
packageFiles: packageFiles,
prBodyTemplate: '{{{warnings}}}',
},
{
debugData: {
updatedInVer: '1.2.3',
createdInVer: '1.2.3',
},
}
);
const expected =
'---\n\n### ⚠ Dependency Lookup Warnings ⚠' +
'\n\nWarnings were logged while processing this repo. ' +
'Please check the Dependency Dashboard for further information\n\n---';
MaronHatoum marked this conversation as resolved.
Show resolved Hide resolved
expect(res).toBe(expected);
});
});
});
10 changes: 10 additions & 0 deletions lib/workers/repository/update/pr/body/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { toBase64 } from '../../../../../util/string';
import * as template from '../../../../../util/template';
import { joinUrlParts } from '../../../../../util/url';
import type { BranchConfig } from '../../../../types';
import { getDepWarningsPR, getWarnings } from '../../../errors-warnings';
import { getChangelogs } from './changelogs';
import { getPrConfigDescription } from './config-description';
import { getControls } from './controls';
Expand Down Expand Up @@ -69,9 +70,18 @@ export async function getPrBody(
prBodyConfig: PrBodyConfig
): Promise<string> {
massageUpdateMetadata(branchConfig);
let warnings = '';
warnings += getWarnings(branchConfig);
if (branchConfig.packageFiles) {
warnings += getDepWarningsPR(
branchConfig.packageFiles,
branchConfig.dependencyDashboard
);
}
const content = {
header: getPrHeader(branchConfig),
table: getPrUpdatesTable(branchConfig),
warnings,
notes: getPrNotes(branchConfig) + getPrExtraNotes(branchConfig),
changelogs: getChangelogs(branchConfig),
configDescription: await getPrConfigDescription(branchConfig),
Expand Down