Skip to content

Commit f4b3ddc

Browse files
committed
add patch file, use comment bot, still a wip
1 parent 07ea1f6 commit f4b3ddc

File tree

4 files changed

+137
-39
lines changed

4 files changed

+137
-39
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ tasks:
4949
- command: subprocess.exec
5050
params:
5151
binary: bash
52+
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN]
5253
args:
5354
- .evergreen/scripts/resync-all-specs.sh
5455
working_dir: src

.evergreen/scripts/create-pr.sh

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,54 @@ pushd $tools/.evergreen/github_app
99
owner="mongodb"
1010
repo="mongo-python-driver"
1111

12-
echo "bootstrapping?"
1312
# Bootstrap the app.
13+
echo "bootstrapping"
1414
source utils.sh
15-
bootstrap drivers/release-bot
15+
bootstrap drivers/comment-bot
1616

1717
# Run the app.
18+
source ./secrets-export.sh
1819

1920
# Get a github access token for the git checkout.
2021
echo "Getting github token..."
22+
2123
token=$(bash ./get-access-token.sh $repo $owner)
2224
if [ -z "${token}" ]; then
2325
echo "Failed to get github access token!"
2426
popd
2527
exit 1
2628
fi
2729
echo "Getting github token... done."
30+
popd
2831

2932
# Make the git checkout and create a new branch.
3033
echo "Creating the git checkout..."
3134
branch="spec-resync-"$(date '+%m-%d-%Y')
3235

33-
git config user.email "167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com"
34-
git config user.name "mongodb-dbx-release-bot[bot]"
36+
#git config user.email "167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com"
37+
#git config user.name "mongodb-dbx-release-bot[bot]"
3538
git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git
3639
git checkout -b $branch "origin/master"
3740
git add ./test
41+
git apply -R .evergreen/specs.patch
42+
git commit -am "resyncing specs test?"
3843
echo "Creating the git checkout... done."
3944

40-
git push origin $branch
41-
resp=$(curl -L \
42-
-X POST \
43-
-H "Accept: application/vnd.github+json" \
44-
-H "Authorization: Bearer $token" \
45-
-H "X-GitHub-Api-Version: 2022-11-28" \
46-
-d "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"${body}\",\"head\":\"${branch}\",\"base\":\"main\"}" \
47-
--url https://api.github.com/repos/$owner/$repo/pulls)
48-
echo $resp | jq '.html_url'
49-
echo "Creating the PR... done."
50-
51-
rm -rf $dirname
45+
echo "THIS IS THE BODY"
46+
echo "$body"
47+
#git push origin $branch
48+
#resp=$(curl -L \
49+
# -X POST \
50+
# -H "Accept: application/vnd.github+json" \
51+
# -H "Authorization: Bearer $token" \
52+
# -H "X-GitHub-Api-Version: 2022-11-28" \
53+
# -d "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"${body}\",\"head\":\"${branch}\",\"base\":\"master\"}" \
54+
# --url https://api.github.com/repos/$owner/$repo/pulls)
55+
#echo $resp
56+
#echo $resp | jq '.html_url'
57+
#echo "Creating the PR... done."
58+
59+
rm -rf $tools
60+
61+
# use file names or reg-ex patterns
62+
# or automate which version of the spec we support (like schema version)

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

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env bash
22
# Run spec syncing script and create PR
3-
43
SPEC_DEST="$(realpath -s "./test")"
54
SRC_URL="https://github.com/mongodb/specifications.git"
65
# needs to be set for resunc-specs.sh
76
SPEC_SRC="$(realpath -s "../specifications")"
8-
SCRIPT="$(realpath -s ".evergreen/resync-specs.sh")"
7+
SCRIPT="$(realpath -s "./.evergreen/resync-specs.sh")"
98
BRANCH_NAME="spec-resync-"$(date '+%m-%d-%Y')
109

1110
# List of directories to skip
@@ -27,14 +26,16 @@ fi
2726

2827
# Set environment variable to the cloned repo for resync-specs.sh
2928
export MDB_SPECS="$SPEC_SRC"
30-
echo "$SPEC_SRC"
29+
3130

3231
# Check that resync script exists and is executable
3332
if [[ ! -x $SCRIPT ]]; then
3433
echo "Error: $SCRIPT not found or is not executable."
3534
exit 1
3635
fi
3736

37+
git pull
38+
3839
# List to store names of specs that were changed or errored during change
3940
changed_specs=()
4041
errored_specs=()
@@ -51,48 +52,45 @@ for item in "$SPEC_DEST"/*; do
5152
# Check that item is not a python file
5253
if [[ $item != *.py ]]; then
5354
echo " doing $item_name"
54-
# output=$(./$SCRIPT "$item_name" 2>&1)
55-
$SCRIPT "$item_name"
55+
output=$($SCRIPT "$item_name" 2>&1)
5656
# Check if the script ran successfully
5757
if [[ $? -ne 0 ]]; then
5858
echo "an error occurred"
59-
errored_specs+=("$item_name")
60-
else
61-
# if script had output, then changes were made
62-
if [[ -n "$output" ]]; then
63-
echo "success"
64-
changed_specs+=("$item_name")
65-
fi
59+
errored_specs+=($"$item_name\n\`\`\`$output\`\`\`\n\n")
6660
fi
6761
fi
6862
done
6963

70-
pr_body="Spec sync results:\n\n"
7164
# Output the list of changed specs
72-
if [[ ${#changed_specs[@]} -gt 0 ]]; then
73-
pr_body+="The following specs were changed:\n"
74-
for spec in "${changed_specs[@]}"; do
75-
pr_body+=" - $spec\n"
76-
done
77-
else
78-
pr_body+="No changes detected in any specs.\n"
65+
if git diff --quiet && [[ ${#errored_specs[@]} -eq 0 ]]; then
66+
# no changes made and no errors
67+
exit 0
68+
fi
69+
70+
pr_body=$'Spec sync results:\n\n'
71+
if ! git diff --quiet; then
72+
pr_body+=$'The following specs were changed:\n'
73+
pr_body+="$(git diff --name-only | awk -F'/' '{print $2}' | sort | uniq)"
7974
fi
8075

8176
# Output the list of errored specs
8277
if [[ ${#errored_specs[@]} -gt 0 ]]; then
83-
pr_body+="\nThe following spec syncs encountered errors:\n"
78+
pr_body+=$"\n\nThe following spec syncs encountered errors:\n"
8479
for spec in "${errored_specs[@]}"; do
8580
pr_body+=" - $spec\n"
8681
done
8782
else
88-
pr_body+="\nNo errors were encountered in any specs syncs.\n"
83+
pr_body+=$"\nNo errors were encountered in any specs syncs.\n"
8984
fi
9085

9186
# Output the PR body (optional step for verification)
92-
echo -e "$pr_body"
87+
echo "PR body"
88+
echo "$pr_body"
9389
echo "$pr_body" >> spec_sync.txt
9490

91+
echo "BEGINNING OF DIFF"
9592
git diff
93+
echo "END OF DIFF"
9694

9795
# call scrypt to create PR for us
9896
.evergreen/scripts/create-pr.sh spec_sync.txt

.evergreen/specs.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
diff --git a/test/load_balancer/cursors.json b/test/load_balancer/cursors.json
2+
index 27aaddd5..b11bf2c6 100644
3+
--- a/test/load_balancer/cursors.json
4+
+++ b/test/load_balancer/cursors.json
5+
@@ -385,7 +385,7 @@
6+
]
7+
},
8+
{
9+
- "description": "pinned connections are returned after an network error during getMore",
10+
+ "description": "pinned connections are not returned after an network error during getMore",
11+
"operations": [
12+
{
13+
"name": "failPoint",
14+
@@ -449,7 +449,7 @@
15+
"object": "testRunner",
16+
"arguments": {
17+
"client": "client0",
18+
- "connections": 0
19+
+ "connections": 1
20+
}
21+
},
22+
{
23+
@@ -677,7 +677,7 @@
24+
]
25+
},
26+
{
27+
- "description": "pinned connections are returned to the pool after a non-network error on getMore",
28+
+ "description": "pinned connections are not returned to the pool after a non-network error on getMore",
29+
"operations": [
30+
{
31+
"name": "failPoint",
32+
@@ -733,7 +733,7 @@
33+
"object": "testRunner",
34+
"arguments": {
35+
"client": "client0",
36+
- "connections": 0
37+
+ "connections": 1
38+
}
39+
},
40+
{
41+
diff --git a/test/server_selection_logging/operation-id.json b/test/server_selection_logging/operation-id.json
42+
index ccc26231..72ebff60 100644
43+
--- a/test/server_selection_logging/operation-id.json
44+
+++ b/test/server_selection_logging/operation-id.json
45+
@@ -197,7 +197,7 @@
46+
}
47+
},
48+
{
49+
- "level": "debug",
50+
+ "level": "info",
51+
"component": "serverSelection",
52+
"data": {
53+
"message": "Waiting for suitable server to become available",
54+
@@ -383,7 +383,7 @@
55+
}
56+
},
57+
{
58+
- "level": "debug",
59+
+ "level": "info",
60+
"component": "serverSelection",
61+
"data": {
62+
"message": "Waiting for suitable server to become available",
63+
diff --git a/test/server_selection_logging/replica-set.json b/test/server_selection_logging/replica-set.json
64+
index 830b1ea5..5eba784b 100644
65+
--- a/test/server_selection_logging/replica-set.json
66+
+++ b/test/server_selection_logging/replica-set.json
67+
@@ -184,7 +184,7 @@
68+
}
69+
},
70+
{
71+
- "level": "debug",
72+
+ "level": "info",
73+
"component": "serverSelection",
74+
"data": {
75+
"message": "Waiting for suitable server to become available",
76+
diff --git a/test/server_selection_logging/sharded.json b/test/server_selection_logging/sharded.json
77+
index 346c050f..d42fba91 100644
78+
--- a/test/server_selection_logging/sharded.json
79+
+++ b/test/server_selection_logging/sharded.json
80+
@@ -193,7 +193,7 @@
81+
}
82+
},
83+
{
84+
- "level": "debug",
85+
+ "level": "info",
86+
"component": "serverSelection",
87+
"data": {
88+
"message": "Waiting for suitable server to become available",

0 commit comments

Comments
 (0)