Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lazy branch status #11799

Merged
merged 1 commit into from Sep 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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