33
33
34
34
Note that `--extract` will overwrite files in `iai-home`.
35
35
36
- check-regressions [iai-home]
36
+ check-regressions [--home iai-home] [--allow-pr-override pr_number ]
37
37
Check `iai-home` (or `iai-home` if unspecified) for `summary.json`
38
38
files and see if there are any regressions. This is used as a workaround
39
39
for `iai-callgrind` not exiting with error status; see
40
40
<https://github.com/iai-callgrind/iai-callgrind/issues/337>.
41
+
42
+ If `--allow-pr-override` is specified, the regression check will not exit
43
+ with failure if any line in the PR starts with `allow-regressions`.
41
44
"""
42
45
)
43
46
46
49
DEFAULT_BRANCH = "master"
47
50
WORKFLOW_NAME = "CI" # Workflow that generates the benchmark artifacts
48
51
ARTIFACT_GLOB = "baseline-icount*"
52
+ # Place this in a PR body to skip regression checks (must be at the start of a line).
53
+ REGRESSION_DIRECTIVE = "ci: allow-regressions"
49
54
50
55
# Don't run exhaustive tests if these files change, even if they contaiin a function
51
56
# definition.
@@ -256,12 +261,26 @@ def locate_baseline(flags: list[str]) -> None:
256
261
eprint ("baseline extracted successfully" )
257
262
258
263
259
- def check_iai_regressions (iai_home : str | None | Path ):
264
+ def check_iai_regressions (args : list [ str ] ):
260
265
"""Find regressions in iai summary.json files, exit with failure if any are
261
266
found.
262
267
"""
263
- if iai_home is None :
264
- iai_home = "iai-home"
268
+
269
+ iai_home = "iai-home"
270
+ pr_number = False
271
+
272
+ while len (args ) > 0 :
273
+ match args :
274
+ case ["--home" , home , * rest ]:
275
+ iai_home = home
276
+ args = rest
277
+ case ["--allow-pr-override" , pr_num , * rest ]:
278
+ pr_number = pr_num
279
+ args = rest
280
+ case _:
281
+ eprint (USAGE )
282
+ exit (1 )
283
+
265
284
iai_home = Path (iai_home )
266
285
267
286
found_summaries = False
@@ -286,9 +305,33 @@ def check_iai_regressions(iai_home: str | None | Path):
286
305
eprint (f"did not find any summary.json files within { iai_home } " )
287
306
exit (1 )
288
307
289
- if len (regressions ) > 0 :
290
- eprint ("Found regressions:" , json .dumps (regressions , indent = 4 ))
291
- exit (1 )
308
+ if len (regressions ) == 0 :
309
+ eprint ("No regressions found" )
310
+ return
311
+
312
+ eprint ("Found regressions:" , json .dumps (regressions , indent = 4 ))
313
+
314
+ if pr_number is not None :
315
+ pr_info = sp .check_output (
316
+ [
317
+ "gh" ,
318
+ "pr" ,
319
+ "view" ,
320
+ str (pr_number ),
321
+ "--json=number,commits,body,createdAt" ,
322
+ "--jq=.commits |= map(.oid)" ,
323
+ ],
324
+ text = True ,
325
+ )
326
+ pr = json .loads (pr_info )
327
+ eprint ("PR info:" , json .dumps (pr , indent = 4 ))
328
+
329
+ lines = pr ["body" ].splitlines ()
330
+ if any (line .startswith (REGRESSION_DIRECTIVE ) for line in lines ):
331
+ eprint ("PR allows regressions, returning" )
332
+ return
333
+
334
+ exit (1 )
292
335
293
336
294
337
def main ():
@@ -299,10 +342,8 @@ def main():
299
342
print (f"matrix={ output } " )
300
343
case ["locate-baseline" , * flags ]:
301
344
locate_baseline (flags )
302
- case ["check-regressions" ]:
303
- check_iai_regressions (None )
304
- case ["check-regressions" , iai_home ]:
305
- check_iai_regressions (iai_home )
345
+ case ["check-regressions" , * args ]:
346
+ check_iai_regressions (args )
306
347
case ["--help" | "-h" ]:
307
348
print (USAGE )
308
349
exit ()
0 commit comments