Skip to content

Commit fe1b07d

Browse files
committed
WIP
1 parent cf9b68c commit fe1b07d

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

.evergreen/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ post:
4242
- func: "upload mo artifacts"
4343
- func: "upload test results"
4444
- func: "cleanup"
45+
46+
tasks:
47+
- name: resync_specs
48+
commands:
49+
- command: subprocess.exec
50+
params:
51+
binary: bash
52+
args:
53+
- .evergreen/scripts/resync_all_specs.sh
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
# Run spec syncing script and create PR
3+
4+
SPEC_DEST="../../test"
5+
SRC_URL="https://github.com/mongodb/specifications.git"
6+
# needs to be set for resunc-specs.sh
7+
SPEC_SRC="../../../specifications"
8+
SCRIPT="../resync-specs.sh"
9+
BRANCH_NAME="spec-resync-"$(date '+%m-%d-%Y')
10+
11+
# List of directories to skip
12+
SKIP_DIRECTORIES=("asynchronous" "__pycache__")
13+
# we have a list of specs that we manually override *if the git diff is that specific line, then don't change it
14+
# *ask in python channel
15+
SKIP_FILES=()
16+
# ask steve for how to create PR from evergreen account(?)
17+
# for now, treat it like a command line thing and git add *, git commit, git push
18+
19+
# Clone the repo if the directory does not exist
20+
if [[ ! -d $SPEC_SRC ]]; then
21+
git clone $SRC_URL $SPEC_SRC
22+
if [[ $? -ne 0 ]]; then
23+
echo "Error: Failed to clone repository."
24+
exit 1
25+
fi
26+
fi
27+
28+
# Set environment variable to the cloned repo for resync-specs.sh
29+
export MDB_SPECS="$SPEC_SRC"
30+
31+
# Check that resync script exists and is executable
32+
if [[ ! -x $SCRIPT ]]; then
33+
echo "Error: $SCRIPT not found or is not executable."
34+
exit 1
35+
fi
36+
37+
# List to store names of specs that were changed or errored during change
38+
changed_specs=()
39+
errored_specs=()
40+
41+
# Create branch and switch to it
42+
git checkout -b $BRANCH_NAME 2>/dev/null || git checkout $BRANCH_NAME
43+
44+
for item in "$SPEC_DEST"/*; do
45+
item_name=$(basename "$item")
46+
if [[ " ${SKIP_DIRECTORIES[*]} " =~ ${item_name} ]]; then
47+
continue
48+
fi
49+
50+
# Check that item is not a python file
51+
if [[ $item != *.py ]]; then
52+
53+
output=$(./$SCRIPT "$item_name" 2>&1)
54+
55+
# Check if the script ran successfully
56+
if [[ $? -ne 0 ]]; then
57+
errored_specs+=("$item_name")
58+
else
59+
# if script had output, then changes were made
60+
if [[ -n "$output" ]]; then
61+
changed_specs+=("$item_name")
62+
fi
63+
fi
64+
fi
65+
done
66+
67+
pr_body="Spec sync results:\n\n"
68+
# Output the list of changed specs
69+
if [[ ${#changed_specs[@]} -gt 0 ]]; then
70+
pr_body+="The following specs were changed:\n"
71+
for spec in "${changed_specs[@]}"; do
72+
pr_body+=" - $spec\n"
73+
done
74+
else
75+
pr_body+="No changes detected in any specs.\n"
76+
fi
77+
78+
# Output the list of errored specs
79+
if [[ ${#errored_specs[@]} -gt 0 ]]; then
80+
pr_body+="\nThe following spec syncs encountered errors:\n"
81+
for spec in "${errored_specs[@]}"; do
82+
pr_body+=" - $spec\n"
83+
done
84+
else
85+
pr_body+="\nNo errors were encountered in any specs syncs.\n"
86+
fi
87+
88+
# Output the PR body (optional step for verification)
89+
echo -e "$pr_body"
90+
91+
git add $SPEC_DEST
92+
git commit -m $BRANCH_NAME
93+
git push -u origin $BRANCH_NAME
94+
#gh pr create --title "[Spec Resync] $(date '+%m-%d-%Y')" --body "Resyncing specs for review" --base main --head $BRANCH_NAME --draft

0 commit comments

Comments
 (0)