File tree 3 files changed +26
-1
lines changed
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ module.exports = async robot => {
82
82
] ,
83
83
wrapPaymentCheck ( pullLabeled ( queue ) )
84
84
)
85
+ // TODO rerun pull labeled job on `check_suite.completed`
85
86
86
87
robot . on ( [ 'issue_comment.created' , 'issue_comment.edited' ] , wrapPaymentCheck ( commentCreated ( ) ) )
87
88
Original file line number Diff line number Diff line change @@ -111,7 +111,26 @@ module.exports.process = robot => async ({
111
111
} = await github . repos . getCombinedStatusForRef ( { owner, repo, ref } )
112
112
113
113
// 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
+ ) {
115
134
throw new Error ( 'Retry job' )
116
135
}
117
136
Original file line number Diff line number Diff line change @@ -210,6 +210,11 @@ describe('Bot', () => {
210
210
deleteRef : jest . fn ( ) . mockResolvedValue ( ) ,
211
211
createRef : jest . fn ( ) . mockResolvedValue ( ) ,
212
212
createTag : jest . fn ( ) . mockResolvedValue ( )
213
+ } ,
214
+ checks : {
215
+ listSuitesForRef : jest
216
+ . fn ( )
217
+ . mockResolvedValue ( { data : { total_count : 0 , check_suites : [ ] } } )
213
218
}
214
219
}
215
220
robot . auth = ( ) => Promise . resolve ( github )
You can’t perform that action at this time.
0 commit comments