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