@@ -172,6 +172,46 @@ describe("retry-bot", () => {
172
172
handleScope ( scope ) ;
173
173
} ) ;
174
174
175
+ test ( "rerun known flaky jobs" , async ( ) => {
176
+ const event = requireDeepCopy ( "./fixtures/workflow_run.completed.json" ) ;
177
+ event . payload . workflow_run . name = "pull" ;
178
+ const workflow_jobs = requireDeepCopy ( "./fixtures/workflow_jobs.json" ) ;
179
+ workflow_jobs . jobs [ 4 ] . name = `${ workflow_jobs . jobs [ 0 ] . name } (pr_time_benchmarks)` ;
180
+ workflow_jobs . jobs [ 4 ] . conclusion = "failure" ;
181
+ workflow_jobs . jobs [ 4 ] . steps [ 0 ] . conclusion = "failure" ;
182
+
183
+ const owner = event . payload . repository . owner . login ;
184
+ const repo = event . payload . repository . name ;
185
+ const attempt_number = event . payload . workflow_run . run_attempt ;
186
+ const run_id = event . payload . workflow_run . id ;
187
+
188
+ const scope = nock ( "https://api.github.com" )
189
+ . get (
190
+ `/repos/${ owner } /${ repo } /actions/runs/${ run_id } /attempts/${ attempt_number } /jobs?page=1&per_page=100`
191
+ )
192
+ . reply ( 200 , workflow_jobs )
193
+ . get (
194
+ `/repos/${ owner } /${ repo } /contents/${ encodeURIComponent (
195
+ ".github/pytorch-probot.yml"
196
+ ) } `
197
+ )
198
+ . reply (
199
+ 200 ,
200
+ '{retryable_workflows: ["pull", "trunk", "linux-binary", "windows-binary"]}'
201
+ )
202
+ . post (
203
+ `/repos/${ owner } /${ repo } /actions/jobs/${ workflow_jobs . jobs [ 4 ] . id } /rerun`
204
+ )
205
+ . reply ( 200 ) ;
206
+
207
+ const mock = jest . spyOn ( clickhouse , "queryClickhouseSaved" ) ;
208
+ mock . mockImplementation ( ( ) => Promise . resolve ( [ ] ) ) ;
209
+
210
+ await probot . receive ( event ) ;
211
+
212
+ handleScope ( scope ) ;
213
+ } ) ;
214
+
175
215
test ( "rerun previous workflow if it has more than one flaky jobs in trunk" , async ( ) => {
176
216
const event = requireDeepCopy ( "./fixtures/workflow_run.completed.json" ) ;
177
217
event . payload . workflow_run . name = "pull" ;
0 commit comments