Skip to content

Commit d967ee2

Browse files
committed
Fix GH action failures
1 parent 50f8c1d commit d967ee2

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

.github/scripts/list_modified_scripts_with_secrets.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import json
44
import os
55

6+
TRIGGER_FILES = ['meta.yaml', 'customize.py', 'run.sh']
7+
68

79
def get_file_info(filepath):
810
with open(filepath, 'r') as file:
@@ -17,29 +19,45 @@ def get_file_info(filepath):
1719
return uid, num_tests
1820

1921

20-
def process_files(files):
22+
def get_trigger_directories(filenames):
23+
"""Return unique directories that contain a changed trigger file (meta.yaml, customize.py, run.sh)."""
24+
dirs = set()
25+
for file in filenames:
26+
if os.path.basename(file) in TRIGGER_FILES:
27+
dirs.add(os.path.dirname(file))
28+
return dirs
29+
30+
31+
def get_meta_paths(files):
32+
"""Return deduplicated meta.yaml paths for directories with any trigger file changed."""
2133
filenames = files.split(",")
34+
dirs = get_trigger_directories(filenames)
35+
return [os.path.join(d, 'meta.yaml') for d in dirs if os.path.exists(os.path.join(d, 'meta.yaml'))]
36+
37+
38+
def process_files(files):
39+
meta_paths = get_meta_paths(files)
2240
return [
2341
{
24-
"file": file,
42+
"file": meta,
2543
"uid": uid,
2644
"num_run": i
2745
}
28-
for file in filenames if os.path.basename(file) == 'meta.yaml'
29-
for uid, num_tests in [get_file_info(file)]
46+
for meta in meta_paths
47+
for uid, num_tests in [get_file_info(meta)]
3048
for i in range(1, num_tests + 1)
3149
]
3250

3351

3452
def get_modified_metas(files):
35-
filenames = files.split(",")
53+
meta_paths = get_meta_paths(files)
3654
return [
3755
{
38-
"file": file,
56+
"file": meta,
3957
"uid": uid,
4058
}
41-
for file in filenames if os.path.basename(file) == 'meta.yaml'
42-
for uid, num_tests in [get_file_info(file)]
59+
for meta in meta_paths
60+
for uid, num_tests in [get_file_info(meta)]
4361
]
4462

4563

0 commit comments

Comments
 (0)