Skip to content

Commit edfc507

Browse files
committed
check test suites too
1 parent 92cdc2d commit edfc507

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ module.exports = async robot => {
8282
],
8383
wrapPaymentCheck(pullLabeled(queue))
8484
)
85+
// TODO rerun pull labeled job on `check_suite.completed`
8586

8687
robot.on(['issue_comment.created', 'issue_comment.edited'], wrapPaymentCheck(commentCreated()))
8788

src/pull/labeled.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,26 @@ module.exports.process = robot => async ({
111111
} = await github.repos.getCombinedStatusForRef({ owner, repo, ref })
112112

113113
// If no CI is set up, state is pending but statuses === []
114-
if (!(state === STATE.SUCCESS || (state === STATE.PENDING && statuses.length === 0))) {
114+
const okStatus = state === STATE.SUCCESS || (state === STATE.PENDING && statuses.length === 0)
115+
if (!okStatus) {
116+
throw new Error('Retry job')
117+
}
118+
119+
const {
120+
data: { total_count, check_suites }
121+
} = await github.checks.listSuitesForRef({
122+
owner,
123+
repo,
124+
ref,
125+
headers: {
126+
Accept: 'application/vnd.github.antiope-preview+json'
127+
}
128+
})
129+
130+
if (
131+
total_count > 0 &&
132+
check_suites.find(s => s.conclusion !== 'success' && s.conclusion !== 'neutral')
133+
) {
115134
throw new Error('Retry job')
116135
}
117136

test/index.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ describe('Bot', () => {
210210
deleteRef: jest.fn().mockResolvedValue(),
211211
createRef: jest.fn().mockResolvedValue(),
212212
createTag: jest.fn().mockResolvedValue()
213+
},
214+
checks: {
215+
listSuitesForRef: jest
216+
.fn()
217+
.mockResolvedValue({ data: { total_count: 0, check_suites: [] } })
213218
}
214219
}
215220
robot.auth = () => Promise.resolve(github)

0 commit comments

Comments
 (0)