Skip to content

Commit

Permalink
fix(automerge): force PR creation on dashboard approval (#21924)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed May 2, 2023
1 parent 168b872 commit d6edbb2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
17 changes: 17 additions & 0 deletions lib/workers/repository/update/pr/index.spec.ts
Expand Up @@ -396,6 +396,23 @@ describe('workers/repository/update/pr/index', () => {
expect(prCache.setPrCache).not.toHaveBeenCalled();
});

it('forces PR on dashboard check', async () => {
platform.createPr.mockResolvedValueOnce(pr);

const res = await ensurePr({
...config,
automerge: true,
automergeType: 'branch',
reviewers: ['somebody'],
dependencyDashboardChecks: {
'renovate-branch': 'approvePr',
},
});

expect(res).toEqual({ type: 'with-pr', pr });
expect(prCache.setPrCache).toHaveBeenCalled();
});

it('adds assignees for PR automerge with red status', async () => {
const changedPr: Pr = {
...pr,
Expand Down
7 changes: 6 additions & 1 deletion lib/workers/repository/update/pr/index.ts
Expand Up @@ -143,6 +143,11 @@ export async function ensurePr(
config.forcePr = true;
}

if (dependencyDashboardCheck === 'approvePr') {
logger.debug('Forcing PR because of dependency dashboard approval');
config.forcePr = true;
}

if (!existingPr) {
// Only create a PR if a branch automerge has failed
if (
Expand Down Expand Up @@ -172,7 +177,7 @@ export async function ensurePr(
return { type: 'without-pr', prBlockedBy: 'BranchAutomerge' };
}
}
if (!existingPr && config.prCreation === 'status-success') {
if (config.prCreation === 'status-success') {
logger.debug('Checking branch combined status');
if ((await getBranchStatus()) !== 'green') {
logger.debug(`Branch status isn't green - not creating PR`);
Expand Down

0 comments on commit d6edbb2

Please sign in to comment.