Skip to content

Commit

Permalink
feat: add more log when automerged removed from status/check failed
Browse files Browse the repository at this point in the history
  • Loading branch information
christophehurpeau committed Apr 24, 2019
1 parent 107dff1 commit 2020480
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/pr-handlers/actions/autoMergeIfPossible.ts
Expand Up @@ -17,11 +17,16 @@ const hasFailedStatusOrChecks = async (
}),
);

const hasFailedChecks = checks.data.check_runs.some(
const failedChecks = checks.data.check_runs.filter(
(check) => check.conclusion === 'failure',
);

if (hasFailedChecks) return true;
if (failedChecks.length !== 0) {
context.log.info(`automerge not possible: failed check pr ${pr.id}`, {
checks: failedChecks.map((check) => check.name),
});
return true;
}

const statuses = await context.github.repos.listStatusesForRef(
context.repo({
Expand All @@ -30,11 +35,18 @@ const hasFailedStatusOrChecks = async (
}),
);

const hasFailedStatuses = statuses.data.some(
const failedStatuses = statuses.data.filter(
(status) => status.state === 'failure',
);

return hasFailedStatuses;
if (failedStatuses.length !== 0) {
context.log.info(`automerge not possible: failed status pr ${pr.id}`, {
statuses: failedStatuses.map((status) => status.context),
});
return true;
}

return false;
};

export const autoMergeIfPossible = async (
Expand Down Expand Up @@ -132,9 +144,6 @@ export const autoMergeIfPossible = async (
}

if (await hasFailedStatusOrChecks(context, repoContext, pr)) {
context.log.info(
`automerge not possible: renovate with failed status pr ${pr.id}`,
);
repoContext.removeMergeLockedPr(context, createMergeLockPrFromPr());
return false;
} else if (pr.mergeable_state === 'blocked') {
Expand All @@ -152,7 +161,6 @@ export const autoMergeIfPossible = async (

if (pr.mergeable_state === 'blocked') {
if (await hasFailedStatusOrChecks(context, repoContext, pr)) {
context.log.info(`automerge not possible: failed status pr ${pr.id}`);
repoContext.removeMergeLockedPr(context, createMergeLockPrFromPr());
return false;
} else {
Expand Down

0 comments on commit 2020480

Please sign in to comment.