fix(github): fix github status check (#5905)

This commit is contained in:
Michael Kriese 2020-04-07 17:45:55 +02:00 committed by GitHub
parent b45101b753
commit 5a3359462c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -640,7 +640,7 @@ describe('platform/github', () => {
() =>
({
body: {
state: 'failed',
state: 'failure',
},
} as any)
);
@ -690,7 +690,7 @@ describe('platform/github', () => {
{
id: 23950195,
status: 'completed',
conclusion: 'failed',
conclusion: 'failure',
name: 'Travis CI - Branch',
},
],
@ -796,7 +796,7 @@ describe('platform/github', () => {
},
{
context: 'context-3',
state: 'failed',
state: 'failure',
},
],
} as any)
@ -825,7 +825,7 @@ describe('platform/github', () => {
},
{
context: 'context-3',
state: 'failed',
state: 'error',
},
],
} as any)

View file

@ -1057,11 +1057,13 @@ export async function getBranchPr(branchName: string): Promise<Pr | null> {
return existingPr ? getPr(existingPr.number) : null;
}
// https://developer.github.com/v3/repos/statuses
// https://developer.github.com/v3/checks/runs/
type BranchState = 'failure' | 'pending' | 'success';
interface GhBranchStatus {
context: string;
state: BranchState;
state: BranchState | 'error';
}
interface CombinedBranchStatus {
@ -1156,14 +1158,14 @@ export async function getBranchStatus(
if (commitStatus.state === 'success') {
return BranchStatus.green;
}
if (commitStatus.state === 'failed') {
if (commitStatus.state === 'failure') {
return BranchStatus.red;
}
return BranchStatus.yellow;
}
if (
commitStatus.state === 'failed' ||
checkRuns.some(run => run.conclusion === 'failed')
commitStatus.state === 'failure' ||
checkRuns.some(run => run.conclusion === 'failure')
) {
return BranchStatus.red;
}
@ -1189,7 +1191,8 @@ async function getStatusCheck(
const githubToRenovateStatusMapping = {
success: BranchStatus.green,
failed: BranchStatus.red,
error: BranchStatus.red,
failure: BranchStatus.red,
pending: BranchStatus.yellow,
};