Skip to content

Commit 6662032

Browse files
author
Cloud User
committed
resyncing specs test?
1 parent 87c015f commit 6662032

File tree

49 files changed

+10930
-1011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10930
-1011
lines changed

.evergreen/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,22 @@ 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+
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN]
53+
args:
54+
- .evergreen/scripts/resync-all-specs.sh
55+
working_dir: src
56+
57+
buildvariants:
58+
- name: resync_specs
59+
display_name: "Resync Specs"
60+
run_on: rhel80-small
61+
patchable: true
62+
tasks:
63+
- name: resync_specs

.evergreen/resync-specs.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@ then
4545
fi
4646

4747
# Ensure the JSON files are up to date.
48-
cd $SPECS/source
49-
make
50-
cd -
48+
if ! [ -n "${CI:-}" ]
49+
then
50+
cd $SPECS/source
51+
make
52+
cd -
53+
fi
5154
# cpjson unified-test-format/tests/invalid unified-test-format/invalid
5255
# * param1: Path to spec tests dir in specifications repo
5356
# * param2: Path to where the corresponding tests live in Python.

.evergreen/scripts/create-pr.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
3+
tools="../drivers-evergreen-tools"
4+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $tools
5+
body="$(cat "$1")"
6+
7+
pushd $tools/.evergreen/github_app
8+
9+
owner="mongodb"
10+
repo="mongo-python-driver"
11+
12+
# Bootstrap the app.
13+
echo "bootstrapping"
14+
source utils.sh
15+
bootstrap drivers/comment-bot
16+
17+
# Run the app.
18+
source ./secrets-export.sh
19+
20+
# Get a github access token for the git checkout.
21+
echo "Getting github token..."
22+
23+
token=$(bash ./get-access-token.sh $repo $owner)
24+
if [ -z "${token}" ]; then
25+
echo "Failed to get github access token!"
26+
popd
27+
exit 1
28+
fi
29+
echo "Getting github token... done."
30+
popd
31+
32+
# Make the git checkout and create a new branch.
33+
echo "Creating the git checkout..."
34+
branch="spec-resync-"$(date '+%m-%d-%Y')
35+
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]"
38+
git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git
39+
git checkout -b $branch "origin/master"
40+
git add ./test
41+
git commit -am "resyncing specs test?"
42+
echo "Creating the git checkout... done."
43+
44+
git push origin $branch
45+
resp=$(curl -L \
46+
-X POST \
47+
-H "Accept: application/vnd.github+json" \
48+
-H "Authorization: Bearer $token" \
49+
-H "X-GitHub-Api-Version: 2022-11-28" \
50+
-d "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"${body}\",\"head\":\"${branch}\",\"base\":\"master\"}" \
51+
--url https://api.github.com/repos/$owner/$repo/pulls)
52+
echo "this is the curl request"
53+
echo "$resp"
54+
echo $resp | jq '.html_url'
55+
echo "Creating the PR... done."
56+
57+
rm -rf $dirname
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env bash
2+
# Run spec syncing script and create PR
3+
4+
SPEC_DEST="$(realpath -s "./test")"
5+
SRC_URL="https://github.com/mongodb/specifications.git"
6+
# needs to be set for resunc-specs.sh
7+
SPEC_SRC="$(realpath -s "../specifications")"
8+
SCRIPT="$(realpath -s "./.evergreen/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+
32+
# Check that resync script exists and is executable
33+
if [[ ! -x $SCRIPT ]]; then
34+
echo "Error: $SCRIPT not found or is not executable."
35+
exit 1
36+
fi
37+
38+
# List to store names of specs that were changed or errored during change
39+
changed_specs=()
40+
errored_specs=()
41+
42+
# Create branch and switch to it
43+
#git checkout -b $BRANCH_NAME 2>/dev/null || git checkout $BRANCH_NAME
44+
45+
for item in "$SPEC_DEST"/*; do
46+
item_name=$(basename "$item")
47+
if [[ " ${SKIP_DIRECTORIES[*]} " =~ ${item_name} ]]; then
48+
continue
49+
fi
50+
51+
# Check that item is not a python file
52+
if [[ $item != *.py ]]; then
53+
echo " doing $item_name"
54+
# output=$(./$SCRIPT "$item_name" 2>&1)
55+
$SCRIPT "$item_name"
56+
# Check if the script ran successfully
57+
if [[ $? -ne 0 ]]; then
58+
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
66+
fi
67+
fi
68+
done
69+
70+
pr_body="Spec sync results:\n\n"
71+
# 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"
79+
fi
80+
81+
# Output the list of errored specs
82+
if [[ ${#errored_specs[@]} -gt 0 ]]; then
83+
pr_body+="\nThe following spec syncs encountered errors:\n"
84+
for spec in "${errored_specs[@]}"; do
85+
pr_body+=" - $spec\n"
86+
done
87+
else
88+
pr_body+="\nNo errors were encountered in any specs syncs.\n"
89+
fi
90+
91+
# Output the PR body (optional step for verification)
92+
echo -e "$pr_body"
93+
echo "$pr_body" >> spec_sync.txt
94+
95+
git diff
96+
97+
# call scrypt to create PR for us
98+
.evergreen/scripts/create-pr.sh spec_sync.txt
99+
100+
rm spec_sync.txt
101+
#git add $SPEC_DEST
102+
#git commit -m $BRANCH_NAME
103+
#git push -u origin $BRANCH_NAME
104+
#gh pr create --title "[Spec Resync] $(date '+%m-%d-%Y')" --body "Resyncing specs for review" --base main --head $BRANCH_NAME --draft

test/bson_corpus/datetime.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
{
2525
"description" : "Y10K",
2626
"canonical_bson" : "1000000009610000DC1FD277E6000000",
27+
"relaxed_extjson" : "{\"a\":{\"$date\":{\"$numberLong\":\"253402300800000\"}}}",
2728
"canonical_extjson" : "{\"a\":{\"$date\":{\"$numberLong\":\"253402300800000\"}}}"
2829
},
2930
{

test/bson_corpus/decimal128-1.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,30 @@
312312
"canonical_bson": "18000000136400000000000a5bc138938d44c64d31cc3700",
313313
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"}}",
314314
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"1.000000000000000000000000000000000E+999\"}}"
315+
},
316+
{
317+
"description": "Clamped zeros with a large positive exponent",
318+
"canonical_bson": "180000001364000000000000000000000000000000FE5F00",
319+
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+2147483647\"}}",
320+
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E+6111\"}}"
321+
},
322+
{
323+
"description": "Clamped zeros with a large negative exponent",
324+
"canonical_bson": "180000001364000000000000000000000000000000000000",
325+
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-2147483647\"}}",
326+
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"0E-6176\"}}"
327+
},
328+
{
329+
"description": "Clamped negative zeros with a large positive exponent",
330+
"canonical_bson": "180000001364000000000000000000000000000000FEDF00",
331+
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+2147483647\"}}",
332+
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E+6111\"}}"
333+
},
334+
{
335+
"description": "Clamped negative zeros with a large negative exponent",
336+
"canonical_bson": "180000001364000000000000000000000000000000008000",
337+
"degenerate_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-2147483647\"}}",
338+
"canonical_extjson": "{\"d\" : {\"$numberDecimal\" : \"-0E-6176\"}}"
315339
}
316340
]
317341
}

0 commit comments

Comments
 (0)