fix(automerge): force PR creation on dashboard approval (#21924)

This commit is contained in:
Michael Kriese 2023-05-02 14:40:58 +02:00 committed by GitHub
parent 168b872423
commit d6edbb2e2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -396,6 +396,23 @@ describe('workers/repository/update/pr/index', () => {
expect(prCache.setPrCache).not.toHaveBeenCalled(); 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 () => { it('adds assignees for PR automerge with red status', async () => {
const changedPr: Pr = { const changedPr: Pr = {
...pr, ...pr,

View file

@ -143,6 +143,11 @@ export async function ensurePr(
config.forcePr = true; config.forcePr = true;
} }
if (dependencyDashboardCheck === 'approvePr') {
logger.debug('Forcing PR because of dependency dashboard approval');
config.forcePr = true;
}
if (!existingPr) { if (!existingPr) {
// Only create a PR if a branch automerge has failed // Only create a PR if a branch automerge has failed
if ( if (
@ -172,7 +177,7 @@ export async function ensurePr(
return { type: 'without-pr', prBlockedBy: 'BranchAutomerge' }; return { type: 'without-pr', prBlockedBy: 'BranchAutomerge' };
} }
} }
if (!existingPr && config.prCreation === 'status-success') { if (config.prCreation === 'status-success') {
logger.debug('Checking branch combined status'); logger.debug('Checking branch combined status');
if ((await getBranchStatus()) !== 'green') { if ((await getBranchStatus()) !== 'green') {
logger.debug(`Branch status isn't green - not creating PR`); logger.debug(`Branch status isn't green - not creating PR`);