Skip to content

Commit ea7fd6e

Browse files
feat: Add configurable artifactErrorWarning user string (renovatebot#37177)
1 parent ac65158 commit ea7fd6e

File tree

4 files changed

+89
-4
lines changed

4 files changed

+89
-4
lines changed

docs/usage/configuration-options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4506,6 +4506,7 @@ If you want, you can change the text in the comment with the `userStrings` confi
45064506

45074507
You can edit these user-facing strings:
45084508

4509+
- `artifactErrorWarning`: Text of the PR comment when artifact errors occur during updates.
45094510
- `ignoreDigest`: Text of the PR comment for digest upgrades.
45104511
- `ignoreMajor`: Text of the PR comment for major upgrades.
45114512
- `ignoreOther`: Text of the PR comment for other (neither digest nor major) upgrades.
@@ -4516,6 +4517,7 @@ For example:
45164517
```json
45174518
{
45184519
"userStrings": {
4520+
"artifactErrorWarning": "Custom text for artifact errors.",
45194521
"ignoreTopic": "Custom topic for PR comment",
45204522
"ignoreMajor": "Custom text for major upgrades.",
45214523
"ignoreDigest": "Custom text for digest upgrades.",

lib/config/options/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,6 +3060,7 @@ const options: RenovateOptions[] = [
30603060
'Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for the `{{{depName}}}` `{{{newDigestShort}}}` update again.',
30613061
ignoreOther:
30623062
'Because you closed this PR without merging, Renovate will ignore this update (`{{{newValue}}}`). You will get a PR once a newer version is released. To ignore this dependency forever, add it to the `ignoreDeps` array of your Renovate config.',
3063+
artifactErrorWarning: 'You probably do not want to merge this PR as-is.',
30633064
},
30643065
},
30653066
{

lib/workers/repository/update/branch/index.spec.ts

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ describe('workers/repository/update/branch/index', () => {
10831083
expect(prAutomerge.checkAutoMerge).toHaveBeenCalledTimes(0);
10841084
});
10851085

1086-
it('ensures PR and adds lock file error comment if no releaseTimestamp', async () => {
1086+
it('ensures PR and adds lock file error comment with default message if no releaseTimestamp', async () => {
10871087
getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce(
10881088
partial<PackageFilesResult>({
10891089
updatedPackageFiles: [partial<FileChange>()],
@@ -1102,7 +1102,86 @@ describe('workers/repository/update/branch/index', () => {
11021102
prAutomerge.checkAutoMerge.mockResolvedValueOnce({ automerged: true });
11031103
commit.commitFilesToBranch.mockResolvedValueOnce(null);
11041104
await branchWorker.processBranch(config);
1105-
expect(platform.ensureComment).toHaveBeenCalledTimes(1);
1105+
expect(platform.ensureComment).toHaveBeenCalledWith(
1106+
expect.objectContaining({
1107+
content: expect.stringContaining(
1108+
'You probably do not want to merge this PR as-is',
1109+
),
1110+
}),
1111+
);
1112+
expect(prWorker.ensurePr).toHaveBeenCalledTimes(1);
1113+
expect(prAutomerge.checkAutoMerge).toHaveBeenCalledTimes(0);
1114+
});
1115+
1116+
it('ensures PR and adds lock file error comment with user configured message if no releaseTimestamp', async () => {
1117+
getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce(
1118+
partial<PackageFilesResult>({
1119+
updatedPackageFiles: [partial<FileChange>()],
1120+
}),
1121+
);
1122+
npmPostExtract.getAdditionalFiles.mockResolvedValueOnce({
1123+
artifactErrors: [partial<ArtifactError>()],
1124+
updatedArtifacts: [partial<FileChange>()],
1125+
});
1126+
scm.branchExists.mockResolvedValue(true);
1127+
automerge.tryBranchAutomerge.mockResolvedValueOnce('failed');
1128+
prWorker.ensurePr.mockResolvedValueOnce({
1129+
type: 'with-pr',
1130+
pr: partial<Pr>(),
1131+
});
1132+
prAutomerge.checkAutoMerge.mockResolvedValueOnce({ automerged: true });
1133+
commit.commitFilesToBranch.mockResolvedValueOnce(null);
1134+
const customMessage =
1135+
'Please check the lock file changes carefully before merging.';
1136+
const inconfig = {
1137+
...config,
1138+
userStrings: {
1139+
artifactErrorWarning: customMessage,
1140+
},
1141+
};
1142+
await branchWorker.processBranch(inconfig);
1143+
expect(platform.ensureComment).toHaveBeenCalledWith(
1144+
expect.objectContaining({
1145+
content: expect.stringContaining(customMessage),
1146+
}),
1147+
);
1148+
expect(prWorker.ensurePr).toHaveBeenCalledTimes(1);
1149+
expect(prAutomerge.checkAutoMerge).toHaveBeenCalledTimes(0);
1150+
});
1151+
1152+
it('ensures PR and adds lock file error comment with templated user configured message if no releaseTimestamp', async () => {
1153+
getUpdated.getUpdatedPackageFiles.mockResolvedValueOnce(
1154+
partial<PackageFilesResult>({
1155+
updatedPackageFiles: [partial<FileChange>()],
1156+
}),
1157+
);
1158+
npmPostExtract.getAdditionalFiles.mockResolvedValueOnce({
1159+
artifactErrors: [partial<ArtifactError>()],
1160+
updatedArtifacts: [partial<FileChange>()],
1161+
});
1162+
scm.branchExists.mockResolvedValue(true);
1163+
automerge.tryBranchAutomerge.mockResolvedValueOnce('failed');
1164+
prWorker.ensurePr.mockResolvedValueOnce({
1165+
type: 'with-pr',
1166+
pr: partial<Pr>(),
1167+
});
1168+
prAutomerge.checkAutoMerge.mockResolvedValueOnce({ automerged: true });
1169+
commit.commitFilesToBranch.mockResolvedValueOnce(null);
1170+
const inconfig = {
1171+
...config,
1172+
userStrings: {
1173+
artifactErrorWarning:
1174+
'Lock file error in {{manager}} - please review carefully.',
1175+
},
1176+
};
1177+
await branchWorker.processBranch(inconfig);
1178+
expect(platform.ensureComment).toHaveBeenCalledWith(
1179+
expect.objectContaining({
1180+
content: expect.stringContaining(
1181+
'Lock file error in some-manager - please review carefully.',
1182+
),
1183+
}),
1184+
);
11061185
expect(prWorker.ensurePr).toHaveBeenCalledTimes(1);
11071186
expect(prAutomerge.checkAutoMerge).toHaveBeenCalledTimes(0);
11081187
});

lib/workers/repository/update/branch/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,11 @@ export async function processBranch(
873873
let content = `Renovate failed to update `;
874874
content +=
875875
config.artifactErrors.length > 1 ? 'artifacts' : 'an artifact';
876-
content +=
877-
' related to this branch. You probably do not want to merge this PR as-is.';
876+
content += ' related to this branch. ';
877+
content += template.compile(
878+
config.userStrings!.artifactErrorWarning,
879+
config,
880+
);
878881
content += emojify(
879882
`\n\n:recycle: Renovate will retry this branch, including artifacts, only when one of the following happens:\n\n`,
880883
);

0 commit comments

Comments
 (0)