1
1
#! /usr/bin/env bash
2
2
# Run spec syncing script and create PR
3
+
4
+ # SETUP
3
5
SPEC_DEST=" $( realpath -s " ./test" ) "
4
6
SRC_URL=" https://github.com/mongodb/specifications.git"
5
7
# needs to be set for resunc-specs.sh
6
8
SPEC_SRC=" $( realpath -s " ../specifications" ) "
7
9
SCRIPT=" $( realpath -s " ./.evergreen/resync-specs.sh" ) "
8
10
BRANCH_NAME=" spec-resync-" $( date ' +%m-%d-%Y' )
9
11
10
- # List of directories to skip
11
- SKIP_DIRECTORIES=(" asynchronous" " __pycache__" )
12
- # we have a list of specs that we manually override *if the git diff is that specific line, then don't change it
13
- # *ask in python channel
14
- SKIP_FILES=()
15
- # ask steve for how to create PR from evergreen account(?)
16
- # for now, treat it like a command line thing and git add *, git commit, git push
17
-
18
- # Clone the repo if the directory does not exist
12
+ # Clone the spec repo if the directory does not exist
19
13
if [[ ! -d $SPEC_SRC ]]; then
20
14
git clone $SRC_URL $SPEC_SRC
21
15
if [[ $? -ne 0 ]]; then
@@ -24,76 +18,23 @@ if [[ ! -d $SPEC_SRC ]]; then
24
18
fi
25
19
fi
26
20
27
- # Set environment variable to the cloned repo for resync-specs.sh
21
+ # Set environment variable to the cloned spec repo for resync-specs.sh
28
22
export MDB_SPECS=" $SPEC_SRC "
29
23
30
- # Check that resync script exists and is executable
24
+ # Check that resync-specs.sh exists and is executable
31
25
if [[ ! -x $SCRIPT ]]; then
32
26
echo " Error: $SCRIPT not found or is not executable."
33
27
exit 1
34
28
fi
35
29
36
- # List to store names of specs that were changed or errored during change
37
- changed_specs=()
38
- errored_specs=()
30
+ PR_DESC=" spec_sync.txt"
39
31
40
- # Create branch and switch to it
41
- # git checkout -b $BRANCH_NAME 2>/dev/null || git checkout $BRANCH_NAME
42
-
43
- for item in " $SPEC_DEST " /* ; do
44
- item_name=$( basename " $item " )
45
- if [[ " ${SKIP_DIRECTORIES[*]} " =~ ${item_name} ]]; then
46
- continue
47
- fi
32
+ # run python script that actually does all the resyncing
33
+ /opt/devtools/bin/python3.11 ./.evergreen/scripts/resync-all-specs.py " $PR_DESC "
48
34
49
- # Check that item is not a python file
50
- if [[ $item != * .py ]]; then
51
- echo " doing $item_name "
52
- output=$( $SCRIPT " $item_name " 2>&1 )
53
- # Check if the script ran successfully
54
- if [[ $? -ne 0 ]]; then
55
- echo " an error occurred"
56
- errored_specs+=($" $item_name \n\`\`\` $output \`\`\` \n\n" )
57
- fi
58
- fi
59
- done
60
-
61
- # Output the list of changed specs
62
- if git diff --quiet && [[ ${# errored_specs[@]} -eq 0 ]]; then
63
- # no changes made and no errors
64
- exit 0
65
- fi
66
35
67
- pr_body= $' Spec sync results: \n\n '
68
- if ! git diff --quiet ; then
69
- pr_body+= $' The following specs were changed: \n '
70
- pr_body+= " $( git diff --name-only | awk -F ' / ' ' {print $2} ' | sort | uniq ) "
36
+ if [[ -f $PR_DESC ]] ; then
37
+ # changes were made -> call scrypt to create PR for us
38
+ .evergreen/scripts/create-pr.sh " $PR_DESC "
39
+ rm " $PR_DESC "
71
40
fi
72
-
73
- # Output the list of errored specs
74
- if [[ ${# errored_specs[@]} -gt 0 ]]; then
75
- pr_body+=$" \n\nThe following spec syncs encountered errors:\n"
76
- for spec in " ${errored_specs[@]} " ; do
77
- pr_body+=" - $spec \n"
78
- done
79
- else
80
- pr_body+=$" \nNo errors were encountered in any specs syncs.\n"
81
- fi
82
-
83
- # Output the PR body (optional step for verification)
84
- echo " PR body"
85
- echo " $pr_body "
86
- echo " $pr_body " >> spec_sync.txt
87
-
88
- echo " BEGINNING OF DIFF"
89
- git diff
90
- echo " END OF DIFF"
91
-
92
- # call scrypt to create PR for us
93
- .evergreen/scripts/create-pr.sh spec_sync.txt
94
-
95
- rm spec_sync.txt
96
- # git add $SPEC_DEST
97
- # git commit -m $BRANCH_NAME
98
- # git push -u origin $BRANCH_NAME
99
- # gh pr create --title "[Spec Resync] $(date '+%m-%d-%Y')" --body "Resyncing specs for review" --base main --head $BRANCH_NAME --draft
0 commit comments