Skip to content

Commit

Permalink
feat: possibility to change Repository Problems header in dependency …
Browse files Browse the repository at this point in the history
…dashboard issue (#23551)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Nabeel Saabna <48175656+nabeelsaabna@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 8, 2023
1 parent 661c576 commit 15cfe4b
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 2 deletions.
8 changes: 8 additions & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,14 @@ These datasources can be referred by RegexManagers or can be used to overwrite d

For more details see the [`custom` datasource documentation](/modules/datasource/custom/).

## customizeDashboard

You can use the `customizeDashboard` object to customize dependency dashboard.

Supported fields:

- `repoProblemsHeader`: This field will replace the header of the Repository Problems in dependency dashboard issue.

### defaultRegistryUrlTemplate

`registryUrl` which is used, if none is return by extraction.
Expand Down
9 changes: 9 additions & 0 deletions lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,15 @@ const options: RenovateOptions[] = [
type: 'string',
default: `This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).`,
},
{
name: 'customizeDashboard',
description: 'Customize sections in the dependency dashboard issue.',
type: 'object',
default: {},
additionalProperties: {
type: 'string',
},
},
{
name: 'lockFileMaintenance',
description: 'Configuration for lock file maintenance.',
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export interface RenovateConfig
constraintsFiltering?: ConstraintsFilter;

checkedBranches?: string[];
customizeDashboard?: Record<string, string>;
}

export interface CustomDatasourceConfig {
Expand Down
1 change: 1 addition & 0 deletions lib/config/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ export async function validateConfig(
'migratePresets',
'productLinks',
'secrets',
'customizeDashboard',
].includes(key)
) {
const res = validatePlainObject(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,28 @@ None detected
"
`;

exports[`workers/repository/dependency-dashboard ensureDependencyDashboard() contains logged problems with custom header 1`] = `
"This issue lists Renovate updates and detected dependencies. Read the [Dependency Dashboard](https://docs.renovatebot.com/key-concepts/dashboard/) docs to learn more.
## Repository problems
platform is github
- ERROR: i am a non-duplicated problem
## Pending Status Checks
These updates await pending status checks. To force their creation now, click the checkbox below.
- [ ] <!-- approvePr-branch=branchName1 -->pr1
## Detected dependencies
None detected
"
`;

exports[`workers/repository/dependency-dashboard ensureDependencyDashboard() open or update Dependency Dashboard when all branches are closed and dependencyDashboardAutoclose is false 1`] = `
"This is a header
Expand Down
32 changes: 32 additions & 0 deletions lib/workers/repository/dependency-dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,38 @@ describe('workers/repository/dependency-dashboard', () => {
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
});

it('contains logged problems with custom header', async () => {
const branches: BranchConfig[] = [
{
...mock<BranchConfig>(),
prTitle: 'pr1',
upgrades: [
{ ...mock<PrUpgrade>(), depName: 'dep1', repository: 'repo1' },
],
result: 'pending',
branchName: 'branchName1',
},
];
logger.getProblems.mockReturnValueOnce([
{
level: ERROR,
msg: 'i am a non-duplicated problem',
},
]);
config.dependencyDashboard = true;
config.customizeDashboard = {
repoProblemsHeader: 'platform is {{platform}}',
};

await dependencyDashboard.ensureDependencyDashboard(config, branches);

expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
expect(platform.ensureIssue.mock.calls[0][0].body).toContain(
'platform is github'
);
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
});

it('dependency Dashboard All Pending Approval', async () => {
const branches: BranchConfig[] = [
{
Expand Down
7 changes: 5 additions & 2 deletions lib/workers/repository/dependency-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ function appendRepoProblems(config: RenovateConfig, issueBody: string): string {
'repository problems'
);
newIssueBody += '## Repository problems\n\n';
newIssueBody +=
'These problems occurred while renovating this repository.\n\n';
const repoProblemsHeader =
config.customizeDashboard?.['repoProblemsHeader'] ??
'These problems occurred while renovating this repository.';
newIssueBody += template.compile(repoProblemsHeader, config) + '\n\n';

for (const repoProblem of repoProblems) {
newIssueBody += ` - ${repoProblem}\n`;
}
Expand Down

0 comments on commit 15cfe4b

Please sign in to comment.