@@ -366,17 +366,21 @@ def parse_args():
366366 f"Will create a snapshot at URL: https://github.com/{ args .github_repository } /blob/gh-pages/{ snapshot_location } " ,
367367 )
368368
369- # Delete oldest snapshots
370-
371- snapshot_dirs_length = len (os .listdir (SOAK_TESTS_SNAPSHOTS_COMMITS_DIR ))
372-
373- if snapshot_dirs_length > args .max_benchmarks_to_keep :
374- oldest_snapshot_dirs = nsmallest (
375- snapshot_dirs_length - args .max_benchmarks_to_keep ,
376- Path (SOAK_TESTS_SNAPSHOTS_COMMITS_DIR ).iterdir (),
377- key = os .path .getmtime ,
378- )
379- for old_snapshots_dir in oldest_snapshot_dirs :
380- shutil .rmtree (old_snapshots_dir , ignore_errors = True )
369+ # Delete oldest run folders in most recent commit and oldest commit folders
370+
371+ for snapshots_dir in [
372+ SOAK_TESTS_SNAPSHOTS_COMMITS_DIR ,
373+ f"{ SOAK_TESTS_SNAPSHOTS_COMMITS_DIR } /{ args .target_sha } /runs" ,
374+ ]:
375+ snapshot_dirs_length = len (os .listdir (snapshots_dir ))
376+
377+ if snapshot_dirs_length > args .max_benchmarks_to_keep :
378+ oldest_snapshot_dirs = nsmallest (
379+ snapshot_dirs_length - args .max_benchmarks_to_keep ,
380+ Path (snapshots_dir ).iterdir (),
381+ key = os .path .getmtime ,
382+ )
383+ for old_snapshots_dir in oldest_snapshot_dirs :
384+ shutil .rmtree (old_snapshots_dir , ignore_errors = True )
381385
382386 logger .info ("Done creating metric widget images." )
0 commit comments