Skip to content

Commit

Permalink
fix: lazy branch status (#11799)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Sep 17, 2021
1 parent 66bc252 commit 8997383
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/workers/pr/index.ts
Expand Up @@ -149,7 +149,7 @@ export async function ensurePr(

logger.trace({ config }, 'ensurePr');
// If there is a group, it will use the config of the first upgrade in the array
const { branchName, prTitle, upgrades } = config;
const { branchName, ignoreTests, prTitle, upgrades } = config;
const dependencyDashboardCheck = (config.dependencyDashboardChecks || {})[
config.branchName
];
Expand All @@ -164,18 +164,15 @@ export async function ensurePr(
logger.debug('Forcing PR because of artifact errors');
config.forcePr = true;
}

const branchStatus = await resolveBranchStatus(
config.branchName,
config.ignoreTests
);
let branchStatus: BranchStatus;

// Only create a PR if a branch automerge has failed
if (
config.automerge === true &&
config.automergeType.startsWith('branch') &&
!config.forcePr
) {
branchStatus ||= await resolveBranchStatus(branchName, ignoreTests);
logger.debug(
`Branch is configured for branch automerge, branch status) is: ${branchStatus}`
);
Expand Down Expand Up @@ -204,6 +201,7 @@ export async function ensurePr(
}
if (config.prCreation === 'status-success') {
logger.debug('Checking branch combined status');
branchStatus ||= await resolveBranchStatus(branchName, ignoreTests);
if (branchStatus !== BranchStatus.green) {
logger.debug(`Branch status is "${branchStatus}" - not creating PR`);
return { prBlockedBy: 'AwaitingTests' };
Expand All @@ -221,6 +219,7 @@ export async function ensurePr(
!config.forcePr
) {
logger.debug('Checking branch combined status');
branchStatus ||= await resolveBranchStatus(branchName, ignoreTests);
if (branchStatus === BranchStatus.yellow) {
logger.debug(`Branch status is "${branchStatus}" - checking timeout`);
const lastCommitTime = await getBranchLastCommitTime(branchName);
Expand Down

0 comments on commit 8997383

Please sign in to comment.