Skip to content

Commit 1dc4e26

Browse files
committed
move patching logic into python script
1 parent d6347e0 commit 1dc4e26

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

.evergreen/scripts/create-pr.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ branch="spec-resync-"$(date '+%m-%d-%Y')
3535
git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git
3636
git checkout -b $branch "origin/master"
3737
git add ./test
38-
git apply -R --allow-empty .evergreen/patch/*
3938
git commit -am "resyncing specs $(date '+%m-%d-%Y')"
4039
echo "Creating the git checkout... done."
4140

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from subprocess import CalledProcessError
88

99

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:
1111
"""Actually sync the specs"""
1212
for spec in os.scandir(directory):
1313
if not spec.is_dir():
@@ -25,15 +25,10 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> list[str]:
2525
except CalledProcessError as exc:
2626
errored[spec.name] = exc.stderr
2727

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
3732

3833

3934
def check_new_spec_directories(directory: pathlib.Path) -> list[str]:
@@ -66,23 +61,30 @@ def check_new_spec_directories(directory: pathlib.Path) -> list[str]:
6661
return list(spec_set - test_set)
6762

6863

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:
7065
"""Generate the PR description"""
7166
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]
7275
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)
7578
pr_body += "\n"
7679
if len(errored) > 0:
77-
pr_body += "\n\nThe following spec syncs encountered errors:"
80+
pr_body += "\n\nThe following spec syncs encountered errors:\n -"
7881
for k, v in errored.items():
79-
pr_body += f"\n- {k}\n```{v}\n```"
82+
pr_body += f"\n -{k}\n```{v}\n```"
8083
pr_body += "\n"
8184
if len(new) > 0:
82-
pr_body += "\n\nThe following directories are in the specification repository and not in our test directory:"
85+
pr_body += "\n\nThe following directories are in the specification repository and not in our test directory:\n -"
8386
pr_body += "\n -".join(new)
8487
pr_body += "\n"
85-
8688
if pr_body != "":
8789
with open("spec_sync.txt", "w") as f:
8890
# replacements made for proper json
@@ -92,9 +94,10 @@ def write_summary(succeeded: list[str], errored: dict[str, str], new: list[str])
9294
def main():
9395
directory = pathlib.Path("./test")
9496
errored: dict[str, str] = {}
95-
succeeded = resync_specs(directory, errored)
97+
resync_specs(directory, errored)
98+
apply_patches()
9699
new = check_new_spec_directories(directory)
97-
write_summary(succeeded, errored, new)
100+
write_summary(errored, new)
98101

99102

100103
if __name__ == "__main__":

0 commit comments

Comments
 (0)