7
7
from subprocess import CalledProcessError
8
8
9
9
10
- def resync_specs (directory : pathlib .Path , errored : dict [str , str ]) -> list [ str ] :
10
+ def resync_specs (directory : pathlib .Path , errored : dict [str , str ]) -> None :
11
11
"""Actually sync the specs"""
12
12
for spec in os .scandir (directory ):
13
13
if not spec .is_dir ():
@@ -25,15 +25,10 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> list[str]:
25
25
except CalledProcessError as exc :
26
26
errored [spec .name ] = exc .stderr
27
27
28
- process = subprocess .run (
29
- ["git diff --name-only | awk -F'/' '{print $2}' | sort | uniq" ], # noqa: S607
30
- shell = True , # noqa: S602
31
- capture_output = True ,
32
- text = True ,
33
- check = True ,
34
- )
35
- # return successfully synced specs
36
- return process .stdout .strip ().split ()
28
+
29
+ def apply_patches ():
30
+ subprocess .run (["bash" , "./.evergreen/remove-unimplemented-tests.sh" ], check = True ) # noqa: S603, S607
31
+ subprocess .run (["git apply -R --allow-empty ./.evergreen/patch/*" ], shell = True , check = True ) # noqa: S602, S607
37
32
38
33
39
34
def check_new_spec_directories (directory : pathlib .Path ) -> list [str ]:
@@ -66,23 +61,30 @@ def check_new_spec_directories(directory: pathlib.Path) -> list[str]:
66
61
return list (spec_set - test_set )
67
62
68
63
69
- def write_summary (succeeded : list [ str ], errored : dict [str , str ], new : list [str ]) -> None :
64
+ def write_summary (errored : dict [str , str ], new : list [str ]) -> None :
70
65
"""Generate the PR description"""
71
66
pr_body = ""
67
+ process = subprocess .run (
68
+ ["git diff --name-only | awk -F'/' '{print $2}' | sort | uniq" ], # noqa: S607
69
+ shell = True , # noqa: S602
70
+ capture_output = True ,
71
+ text = True ,
72
+ check = True ,
73
+ )
74
+ succeeded = [i for i in process .stdout .strip ().split () if "data/mci/" not in i ]
72
75
if len (succeeded ) > 0 :
73
- pr_body += "The following specs were changed:\n - "
74
- pr_body += "\n -" .join (new )
76
+ pr_body += "The following specs were changed:\n - "
77
+ pr_body += "\n -" .join (succeeded )
75
78
pr_body += "\n "
76
79
if len (errored ) > 0 :
77
- pr_body += "\n \n The following spec syncs encountered errors:"
80
+ pr_body += "\n \n The following spec syncs encountered errors:\n - "
78
81
for k , v in errored .items ():
79
- pr_body += f"\n - { k } \n ```{ v } \n ```"
82
+ pr_body += f"\n - { k } \n ```{ v } \n ```"
80
83
pr_body += "\n "
81
84
if len (new ) > 0 :
82
- pr_body += "\n \n The following directories are in the specification repository and not in our test directory:"
85
+ pr_body += "\n \n The following directories are in the specification repository and not in our test directory:\n - "
83
86
pr_body += "\n -" .join (new )
84
87
pr_body += "\n "
85
-
86
88
if pr_body != "" :
87
89
with open ("spec_sync.txt" , "w" ) as f :
88
90
# replacements made for proper json
@@ -92,9 +94,10 @@ def write_summary(succeeded: list[str], errored: dict[str, str], new: list[str])
92
94
def main ():
93
95
directory = pathlib .Path ("./test" )
94
96
errored : dict [str , str ] = {}
95
- succeeded = resync_specs (directory , errored )
97
+ resync_specs (directory , errored )
98
+ apply_patches ()
96
99
new = check_new_spec_directories (directory )
97
- write_summary (succeeded , errored , new )
100
+ write_summary (errored , new )
98
101
99
102
100
103
if __name__ == "__main__" :
0 commit comments