Skip to content

Commit 16a485c

Browse files
committed
catch patch errors and show them in the PR
1 parent 9603a85 commit 16a485c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

.evergreen/scripts/resync-all-specs.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None:
3030
print("Done syncing specs")
3131

3232

33-
def apply_patches():
33+
def apply_patches(errored):
3434
print("Beginning to apply patches")
3535
subprocess.run(["bash", "./.evergreen/remove-unimplemented-tests.sh"], check=True) # noqa: S603, S607
36-
subprocess.run(
37-
["git apply -R --allow-empty --whitespace=fix ./.evergreen/spec-patch/*"], # noqa: S607
38-
shell=True, # noqa: S602
39-
check=True,
40-
)
36+
try:
37+
subprocess.run(
38+
["git apply -R --allow-empty --whitespace=fix ./.evergreen/spec-patch/*"], # noqa: S607
39+
shell=True, # noqa: S602
40+
check=True,
41+
stderr=subprocess.PIPE,
42+
)
43+
except CalledProcessError as exc:
44+
errored["applying patches"] = exc.stderr
4145

4246

4347
def check_new_spec_directories(directory: pathlib.Path) -> list[str]:
@@ -85,7 +89,7 @@ def write_summary(errored: dict[str, str], new: list[str], filename: Optional[st
8589
pr_body += "\n -".join(succeeded)
8690
pr_body += "\n"
8791
if len(errored) > 0:
88-
pr_body += "\n\nThe following spec syncs encountered errors:\n -"
92+
pr_body += "\n\nThe following spec syncs encountered errors:"
8993
for k, v in errored.items():
9094
pr_body += f"\n -{k}\n```{v}\n```"
9195
pr_body += "\n"
@@ -106,7 +110,7 @@ def main(args: Namespace):
106110
directory = pathlib.Path("./test")
107111
errored: dict[str, str] = {}
108112
resync_specs(directory, errored)
109-
apply_patches()
113+
apply_patches(errored)
110114
new = check_new_spec_directories(directory)
111115
write_summary(errored, new, args.filename)
112116

0 commit comments

Comments
 (0)