2020-09-21 20:04:11 +00:00
|
|
|
import { ERROR, WARN } from 'bunyan';
|
2020-01-10 10:35:49 +00:00
|
|
|
import { mock } from 'jest-mock-extended';
|
2020-09-21 20:04:11 +00:00
|
|
|
import {
|
|
|
|
RenovateConfig,
|
|
|
|
getConfig,
|
2021-04-23 16:58:48 +00:00
|
|
|
loadFixture,
|
2020-09-21 20:04:11 +00:00
|
|
|
logger,
|
|
|
|
platform,
|
|
|
|
} from '../../../test/util';
|
2021-11-23 20:10:45 +00:00
|
|
|
import { GlobalConfig } from '../../config/global';
|
2021-10-06 05:43:32 +00:00
|
|
|
import { PlatformId } from '../../constants';
|
2022-03-03 09:35:26 +00:00
|
|
|
import type { Platform } from '../../modules/platform';
|
2021-04-15 17:06:55 +00:00
|
|
|
import { BranchConfig, BranchResult, BranchUpgradeConfig } from '../types';
|
2020-07-21 13:13:56 +00:00
|
|
|
import * as dependencyDashboard from './dependency-dashboard';
|
2019-07-17 08:14:56 +00:00
|
|
|
|
2020-03-02 11:06:16 +00:00
|
|
|
type PrUpgrade = BranchUpgradeConfig;
|
|
|
|
|
2020-01-10 10:35:49 +00:00
|
|
|
let config: RenovateConfig;
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2019-07-04 14:00:00 +00:00
|
|
|
beforeEach(() => {
|
2020-09-21 20:04:11 +00:00
|
|
|
jest.clearAllMocks();
|
2020-01-10 10:35:49 +00:00
|
|
|
config = getConfig();
|
2021-10-06 05:43:32 +00:00
|
|
|
config.platform = PlatformId.Github;
|
2019-07-04 14:00:00 +00:00
|
|
|
config.errors = [];
|
|
|
|
config.warnings = [];
|
|
|
|
});
|
|
|
|
|
|
|
|
async function dryRun(
|
2020-01-10 10:35:49 +00:00
|
|
|
branches: BranchConfig[],
|
2021-11-08 19:20:03 +00:00
|
|
|
|
2020-05-07 08:23:45 +00:00
|
|
|
platform: jest.Mocked<Platform>,
|
2019-07-04 14:00:00 +00:00
|
|
|
ensureIssueClosingCalls = 0,
|
2021-06-05 11:19:20 +00:00
|
|
|
ensureIssueCalls = 0
|
2019-07-04 14:00:00 +00:00
|
|
|
) {
|
2020-09-21 20:04:11 +00:00
|
|
|
jest.clearAllMocks();
|
2022-04-11 20:29:02 +00:00
|
|
|
GlobalConfig.set({ dryRun: 'full' });
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(
|
|
|
|
ensureIssueClosingCalls
|
|
|
|
);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(ensureIssueCalls);
|
|
|
|
}
|
|
|
|
|
2021-08-18 05:46:56 +00:00
|
|
|
describe('workers/repository/dependency-dashboard', () => {
|
2021-06-16 12:05:36 +00:00
|
|
|
describe('readDashboardBody()', () => {
|
|
|
|
it('reads dashboard body', async () => {
|
|
|
|
const conf: RenovateConfig = {};
|
|
|
|
conf.prCreation = 'approval';
|
|
|
|
platform.findIssue.mockResolvedValueOnce({
|
|
|
|
title: '',
|
|
|
|
number: 1,
|
|
|
|
body:
|
|
|
|
loadFixture('master-issue_with_8_PR.txt').replace('- [ ]', '- [x]') +
|
|
|
|
'\n\n - [x] <!-- rebase-all-open-prs -->',
|
|
|
|
});
|
|
|
|
await dependencyDashboard.readDashboardBody(conf);
|
2021-11-07 15:34:42 +00:00
|
|
|
expect(conf).toEqual({
|
|
|
|
dependencyDashboardChecks: {
|
|
|
|
branchName1: 'approve',
|
|
|
|
},
|
|
|
|
dependencyDashboardIssue: 1,
|
|
|
|
dependencyDashboardRebaseAllOpen: true,
|
|
|
|
dependencyDashboardTitle: 'Dependency Dashboard',
|
|
|
|
prCreation: 'approval',
|
|
|
|
});
|
2021-06-16 12:05:36 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-14 05:07:44 +00:00
|
|
|
describe('ensureDependencyDashboard()', () => {
|
2021-02-05 21:21:24 +00:00
|
|
|
beforeEach(() => {
|
2021-11-23 20:10:45 +00:00
|
|
|
GlobalConfig.reset();
|
2021-02-05 21:21:24 +00:00
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-06-14 05:07:44 +00:00
|
|
|
it('do nothing if dependencyDashboard is disabled', async () => {
|
2020-01-10 10:35:49 +00:00
|
|
|
const branches: BranchConfig[] = [];
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2021-08-25 12:11:18 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(1);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
2021-06-14 05:07:44 +00:00
|
|
|
it('do nothing if it has no dependencyDashboardApproval branches', async () => {
|
2019-07-04 14:00:00 +00:00
|
|
|
const branches = [
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr1',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr2',
|
2020-07-11 09:55:30 +00:00
|
|
|
dependencyDashboardApproval: false,
|
2019-07-04 14:00:00 +00:00
|
|
|
},
|
|
|
|
];
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2021-08-25 12:11:18 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(1);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
2020-07-11 09:55:30 +00:00
|
|
|
it('closes Dependency Dashboard when there is 0 PR opened and dependencyDashboardAutoclose is true', async () => {
|
2020-01-10 10:35:49 +00:00
|
|
|
const branches: BranchConfig[] = [];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
|
|
|
config.dependencyDashboardAutoclose = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.ensureIssueClosing.mock.calls[0][0]).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
2020-07-11 09:55:30 +00:00
|
|
|
it('closes Dependency Dashboard when all branches are automerged and dependencyDashboardAutoclose is true', async () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
const branches: BranchConfig[] = [
|
2020-08-31 14:05:38 +00:00
|
|
|
{
|
|
|
|
...mock<BranchConfig>(),
|
|
|
|
prTitle: 'pr1',
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Automerged,
|
2020-08-31 14:05:38 +00:00
|
|
|
},
|
2019-07-04 14:00:00 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr2',
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Automerged,
|
2020-07-11 09:55:30 +00:00
|
|
|
dependencyDashboardApproval: false,
|
2019-07-04 14:00:00 +00:00
|
|
|
},
|
|
|
|
];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
|
|
|
config.dependencyDashboardAutoclose = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.ensureIssueClosing.mock.calls[0][0]).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(0);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
2020-07-11 09:55:30 +00:00
|
|
|
it('open or update Dependency Dashboard when all branches are closed and dependencyDashboardAutoclose is false', async () => {
|
2020-01-10 10:35:49 +00:00
|
|
|
const branches: BranchConfig[] = [];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
2022-01-26 12:23:56 +00:00
|
|
|
config.dependencyDashboardHeader = 'This is a header';
|
2020-08-24 12:35:22 +00:00
|
|
|
config.dependencyDashboardFooter = 'And this is a footer';
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
2021-02-24 08:34:25 +00:00
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
|
|
|
config.dependencyDashboardTitle
|
|
|
|
);
|
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('open or update Dependency Dashboard when rules contain approvals', async () => {
|
|
|
|
const branches: BranchConfig[] = [];
|
2022-01-26 12:23:56 +00:00
|
|
|
config.repository = 'test';
|
2021-02-24 08:34:25 +00:00
|
|
|
config.packageRules = [
|
|
|
|
{
|
|
|
|
dependencyDashboardApproval: true,
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
];
|
2022-01-26 12:23:56 +00:00
|
|
|
config.dependencyDashboardHeader =
|
|
|
|
'This is a header for platform:{{platform}}';
|
|
|
|
config.dependencyDashboardFooter =
|
|
|
|
'And this is a footer for repository:{{repository}}';
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2021-02-24 08:34:25 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
2022-01-26 12:23:56 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toMatch(
|
|
|
|
/platform:github/
|
|
|
|
);
|
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toMatch(
|
|
|
|
/repository:test/
|
|
|
|
);
|
2020-08-24 12:35:22 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
|
2019-07-04 14:00:00 +00:00
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('checks an issue with 2 Pending Approvals, 2 not scheduled, 2 pr-hourly-limit-reached and 2 in error', async () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
const branches: BranchConfig[] = [
|
2019-07-04 14:00:00 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr1',
|
2020-03-02 11:06:16 +00:00
|
|
|
upgrades: [{ ...mock<BranchUpgradeConfig>(), depName: 'dep1' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NeedsApproval,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr2',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep2' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NeedsApproval,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName2',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr3',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep3' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NotScheduled,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName3',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr4',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep4' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NotScheduled,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName4',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr5',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep5' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.PrLimitReached,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName5',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr6',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep6' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.PrLimitReached,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName6',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr7',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep7' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Error,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName7',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr8',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep8' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Error,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName8',
|
|
|
|
},
|
2021-06-07 10:15:19 +00:00
|
|
|
{
|
|
|
|
...mock<BranchConfig>(),
|
|
|
|
prTitle: 'pr9',
|
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep9' }],
|
|
|
|
result: BranchResult.Done,
|
|
|
|
prBlockedBy: 'BranchAutomerge',
|
|
|
|
branchName: 'branchName9',
|
|
|
|
},
|
2019-07-04 14:00:00 +00:00
|
|
|
];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toBe(
|
2021-04-26 14:15:03 +00:00
|
|
|
loadFixture('master-issue_with_8_PR.txt')
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('checks an issue with 2 PR pr-edited', async () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
const branches: BranchConfig[] = [
|
2019-07-04 14:00:00 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2021-06-05 11:19:20 +00:00
|
|
|
prNo: 1,
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr1',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep1' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.PrEdited,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2021-06-05 11:19:20 +00:00
|
|
|
prNo: 2,
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr2',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep2' },
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep3' },
|
|
|
|
],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.PrEdited,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName2',
|
|
|
|
},
|
|
|
|
];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toBe(
|
2021-04-26 14:15:03 +00:00
|
|
|
loadFixture('master-issue_with_2_PR_edited.txt')
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// same with dry run
|
2021-06-05 11:19:20 +00:00
|
|
|
await dryRun(branches, platform, 0, 0);
|
2019-07-04 14:00:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('checks an issue with 3 PR in progress and rebase all option', async () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
const branches: BranchConfig[] = [
|
2019-07-04 14:00:00 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr1',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep1' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Rebase,
|
2021-06-05 11:19:20 +00:00
|
|
|
prNo: 1,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr2',
|
2021-06-05 11:19:20 +00:00
|
|
|
prNo: 2,
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep2' },
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep3' },
|
|
|
|
],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Rebase,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName2',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr3',
|
2021-06-05 11:19:20 +00:00
|
|
|
prNo: 3,
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep3' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Rebase,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName3',
|
|
|
|
},
|
|
|
|
];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toBe(
|
2021-04-26 14:15:03 +00:00
|
|
|
loadFixture('master-issue_with_3_PR_in_progress.txt')
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// same with dry run
|
2021-06-05 11:19:20 +00:00
|
|
|
await dryRun(branches, platform, 0, 0);
|
2019-07-04 14:00:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('checks an issue with 2 PR closed / ignored', async () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
const branches: BranchConfig[] = [
|
2019-07-04 14:00:00 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr1',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep1' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.AlreadyExisted,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-04 14:00:00 +00:00
|
|
|
prTitle: 'pr2',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep2' },
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep3' },
|
|
|
|
],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.AlreadyExisted,
|
2019-07-04 14:00:00 +00:00
|
|
|
branchName: 'branchName2',
|
|
|
|
},
|
|
|
|
];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-04 14:00:00 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toBe(
|
2021-04-26 14:15:03 +00:00
|
|
|
loadFixture('master-issue_with_2_PR_closed_ignored.txt')
|
2019-07-04 14:00:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// same with dry run
|
2021-06-05 11:19:20 +00:00
|
|
|
await dryRun(branches, platform, 0, 0);
|
2019-07-04 14:00:00 +00:00
|
|
|
});
|
2019-07-11 11:48:41 +00:00
|
|
|
|
|
|
|
it('checks an issue with 3 PR in approval', async () => {
|
2020-03-02 11:06:16 +00:00
|
|
|
const branches: BranchConfig[] = [
|
2019-07-11 11:48:41 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-11 11:48:41 +00:00
|
|
|
prTitle: 'pr1',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep1' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NeedsPrApproval,
|
2019-07-11 11:48:41 +00:00
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-11 11:48:41 +00:00
|
|
|
prTitle: 'pr2',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep2' },
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep3' },
|
|
|
|
],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NeedsPrApproval,
|
2019-07-11 11:48:41 +00:00
|
|
|
branchName: 'branchName2',
|
|
|
|
},
|
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-07-11 11:48:41 +00:00
|
|
|
prTitle: 'pr3',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep3' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.NeedsPrApproval,
|
2019-07-11 11:48:41 +00:00
|
|
|
branchName: 'branchName3',
|
|
|
|
},
|
2019-08-26 06:51:04 +00:00
|
|
|
{
|
2020-01-10 10:35:49 +00:00
|
|
|
...mock<BranchConfig>(),
|
2019-08-26 06:51:04 +00:00
|
|
|
prTitle: 'pr4',
|
2020-01-10 10:35:49 +00:00
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep4' }],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Pending,
|
2019-08-26 06:51:04 +00:00
|
|
|
branchName: 'branchName4',
|
|
|
|
},
|
2019-07-11 11:48:41 +00:00
|
|
|
];
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboard = true;
|
|
|
|
config.dependencyDashboardPrApproval = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2019-07-11 11:48:41 +00:00
|
|
|
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
|
2020-07-11 09:55:30 +00:00
|
|
|
config.dependencyDashboardTitle
|
2019-07-11 11:48:41 +00:00
|
|
|
);
|
2020-01-07 10:40:53 +00:00
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toBe(
|
2021-04-26 14:15:03 +00:00
|
|
|
loadFixture('master-issue_with_3_PR_in_approval.txt')
|
2019-07-11 11:48:41 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
2020-09-21 20:04:11 +00:00
|
|
|
|
|
|
|
it('contains logged problems', async () => {
|
|
|
|
const branches: BranchConfig[] = [
|
|
|
|
{
|
|
|
|
...mock<BranchConfig>(),
|
|
|
|
prTitle: 'pr1',
|
|
|
|
upgrades: [
|
|
|
|
{ ...mock<PrUpgrade>(), depName: 'dep1', repository: 'repo1' },
|
|
|
|
],
|
2021-04-15 17:06:55 +00:00
|
|
|
result: BranchResult.Pending,
|
2020-09-21 20:04:11 +00:00
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
logger.getProblems.mockReturnValueOnce([
|
|
|
|
{
|
|
|
|
level: ERROR,
|
|
|
|
msg: 'everything is broken',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: WARN,
|
|
|
|
msg: 'just a bit',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: ERROR,
|
|
|
|
msg: 'i am a duplicated problem',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: ERROR,
|
|
|
|
msg: 'i am a duplicated problem',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: ERROR,
|
|
|
|
msg: 'i am a non-duplicated problem',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: WARN,
|
|
|
|
msg: 'i am a non-duplicated problem',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
level: WARN,
|
|
|
|
msg: 'i am an artifact error',
|
|
|
|
artifactErrors: {},
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
config.dependencyDashboard = true;
|
2021-06-01 13:07:54 +00:00
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
2020-09-21 20:04:11 +00:00
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-06-18 17:31:25 +00:00
|
|
|
it('rechecks branches', async () => {
|
|
|
|
const branches: BranchConfig[] = [
|
|
|
|
{
|
|
|
|
...mock<BranchConfig>(),
|
|
|
|
prTitle: 'pr1',
|
|
|
|
upgrades: [{ ...mock<BranchUpgradeConfig>(), depName: 'dep1' }],
|
|
|
|
result: BranchResult.NeedsApproval,
|
|
|
|
branchName: 'branchName1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...mock<BranchConfig>(),
|
|
|
|
prTitle: 'pr2',
|
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep2' }],
|
|
|
|
result: BranchResult.NeedsApproval,
|
|
|
|
branchName: 'branchName2',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...mock<BranchConfig>(),
|
|
|
|
prTitle: 'pr3',
|
|
|
|
upgrades: [{ ...mock<PrUpgrade>(), depName: 'dep3' }],
|
|
|
|
result: BranchResult.NotScheduled,
|
|
|
|
branchName: 'branchName3',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
config.dependencyDashboard = true;
|
|
|
|
config.dependencyDashboardChecks = { branchName2: 'approve-branch' };
|
|
|
|
config.dependencyDashboardIssue = 1;
|
|
|
|
platform.getIssue.mockResolvedValueOnce({
|
|
|
|
title: 'Dependency Dashboard',
|
|
|
|
body: `This issue contains a list of Renovate updates and their statuses.
|
|
|
|
|
|
|
|
## Pending Approval
|
|
|
|
|
|
|
|
These branches will be created by Renovate only once you click their checkbox below.
|
|
|
|
|
|
|
|
- [ ] <!-- approve-branch=branchName1 -->pr1
|
|
|
|
- [x] <!-- approve-branch=branchName2 -->pr2
|
|
|
|
|
|
|
|
## Awaiting Schedule
|
|
|
|
|
2021-06-20 15:44:03 +00:00
|
|
|
These updates are awaiting their schedule. Click on a checkbox to get an update now.
|
2022-01-29 05:02:25 +00:00
|
|
|
|
2021-06-18 17:31:25 +00:00
|
|
|
- [x] <!-- unschedule-branch=branchName3 -->pr3
|
|
|
|
|
|
|
|
- [x] <!-- rebase-all-open-prs -->'
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
|
|
|
|
});
|
2021-07-09 07:41:43 +00:00
|
|
|
|
|
|
|
it('forwards configured labels to the ensure issue call', async () => {
|
|
|
|
const branches: BranchConfig[] = [];
|
|
|
|
config.dependencyDashboard = true;
|
|
|
|
config.dependencyDashboardLabels = ['RenovateBot', 'Maintenance'];
|
|
|
|
await dependencyDashboard.ensureDependencyDashboard(config, branches);
|
|
|
|
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
|
|
|
|
expect(platform.ensureIssue.mock.calls[0][0].labels).toStrictEqual([
|
|
|
|
'RenovateBot',
|
|
|
|
'Maintenance',
|
|
|
|
]);
|
|
|
|
|
|
|
|
// same with dry run
|
|
|
|
await dryRun(branches, platform);
|
|
|
|
});
|
2019-07-04 14:00:00 +00:00
|
|
|
});
|
|
|
|
});
|