-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-3071 [DevOps] Merge and improve resync_specs.sh #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a125591
add blocklist and git checkout features, along with usage guide in co…
juliusgeo 9d5ce61
latest iteration, mainly trying to get the ignore warnings working
juliusgeo b5ea8d3
fixed up a bunch of issues, got filtering printing working correctly …
juliusgeo 6d13fd9
clean up some small formatting issues
juliusgeo d93e021
a bunch of fixes, use a differrent blocklist now
juliusgeo 612f091
update help
juliusgeo c0680da
various refactortings, fix indentation, make pymongo directory from c…
juliusgeo df8bda1
add to help to note environment variable
juliusgeo 70a5c63
add note to contributing .rst
juliusgeo 83b784b
add more info to contributing.rst
juliusgeo 316d051
fix missing period and extra flag arg
juliusgeo c7e291e
minor fixes, add better usage example
juliusgeo 0ded415
change it to use dirname /bin/zsh of /Users/julius/Work/mongo-python-…
juliusgeo 31e60cf
remove extra print
juliusgeo f050e4d
fix shellcheck errors
juliusgeo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash | ||
# exit when any command fails | ||
set -e | ||
PYMONGO=~/Work/mongo-python-driver | ||
SPECS=~/Work/specifications | ||
|
||
help (){ | ||
echo "Usage: resync_specs.sh [-bcsp] spec" | ||
echo "Required arguments:" | ||
echo " spec determines which folder the spec tests will be copied from." | ||
echo "Optional flags:" | ||
echo " -b is used to add a string to the blocklist for that next run. Can be used" | ||
echo " any number of times on a single command to block multiple patterns." | ||
echo " You can use any regex pattern (it is passed to 'grep -Ev')." | ||
echo " -c is used to set a branch or commit that will be checked out in the" | ||
echo " specifications repo before copying." | ||
echo " -s is used to set a unique path to the specs repo for that specific" | ||
echo " run." | ||
echo " -p does the same thing but for the pymongo repo." | ||
ShaneHarvey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
# Parse flag args | ||
BRANCH="" | ||
BLOCKLIST='.*\.yml' | ||
while getopts 'b:c:s:p:' flag; do | ||
case "${flag}" in | ||
b) BLOCKLIST+="|"$OPTARG"" | ||
;; | ||
c) BRANCH="${OPTARG}" | ||
;; | ||
s) SPECS="${OPTARG}" | ||
;; | ||
p) PYMONGO="${OPTARG}" | ||
;; | ||
*) help; exit 0 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND-1)) | ||
|
||
if [ -z $BRANCH ] | ||
then | ||
git -C $SPECS checkout $BRANCH | ||
ShaneHarvey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
|
||
# Ensure the JSON files are up to date. | ||
cd $SPECS/source | ||
make | ||
cd - | ||
# cpjson2 unified-test-format/tests/invalid unified-test-format/invalid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cpjson2 -> cpjson There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
# * param1: Path to spec tests dir in specifications repo | ||
# * param2: Path to where the corresponding tests live in Python. | ||
cpjson2 () { | ||
ShaneHarvey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
find "$PYMONGO"/test/$2 -type f -delete | ||
cd "$SPECS"/source/$1 | ||
find . -name '*.json' | grep -Ev "${BLOCKLIST}" | cpio -pdm \ | ||
$PYMONGO/test/$2 | ||
printf "\nIgnored files for ${PWD}" | ||
printf "\n%s\n" "$(diff <(find . -name '*.json' | sort) \ | ||
<(find . -name '*.json' | grep -Ev "${BLOCKLIST}" | sort))" | \ | ||
sed -e '/^[0-9]/d' | sed -e 's|< ./||g' | ||
} | ||
|
||
for spec in "$@" | ||
do | ||
case "$spec" in | ||
bson*corpus) | ||
cpjson2 bson-corpus/tests/ bson_corpus/ | ||
;; | ||
max*staleness) | ||
cpjson2 max-staleness/tests/ max_staleness/ | ||
;; | ||
connection*string) | ||
cpjson2 connection-string/tests/ connection_string/test | ||
;; | ||
change*streams) | ||
cpjson2 change-streams/tests/ change_streams/ | ||
;; | ||
cmap|CMAP) | ||
cpjson2 connection-monitoring-and-pooling/tests cmap | ||
;; | ||
command*monitoring) | ||
cpjson2 command-monitoring/tests command_monitoring/ | ||
;; | ||
crud|CRUD) | ||
cpjson2 crud/tests/ crud/ | ||
;; | ||
load*balancer) | ||
cpjson2 load-balancers/tests load_balancer/ | ||
;; | ||
initial-dns-seedlist-discovery|srv_seedlist) | ||
cpjson2 initial-dns-seedlist-discovery/tests/ srv_seedlist/ | ||
;; | ||
old_srv_seedlist) | ||
cpjson2 initial-dns-seedlist-discovery/tests srv_seedlist | ||
;; | ||
retryable*reads) | ||
cpjson2 retryable-reads/tests/ retryable_reads | ||
;; | ||
retryable*writes) | ||
cpjson2 retryable-writes/tests/ retryable_writes | ||
;; | ||
sdam|SDAM) | ||
cpjson2 server-discovery-and-monitoring/tests/errors \ | ||
discovery_and_monitoring/errors | ||
cpjson2 server-discovery-and-monitoring/tests/rs \ | ||
discovery_and_monitoring/rs | ||
cpjson2 server-discovery-and-monitoring/tests/sharded \ | ||
discovery_and_monitoring/sharded | ||
cpjson2 server-discovery-and-monitoring/tests/single \ | ||
discovery_and_monitoring/single | ||
cpjson2 server-discovery-and-monitoring/tests/integration \ | ||
discovery_and_monitoring_integration | ||
cpjson2 server-discovery-and-monitoring/tests/load-balanced \ | ||
discovery_and_monitoring/load-balanced | ||
;; | ||
sdam*monitoring) | ||
cpjson2 server-discovery-and-monitoring/tests/monitoring sdam_monitoring | ||
;; | ||
server*selection) | ||
cpjson2 server-selection/tests/ server_selection/ | ||
;; | ||
sessions) | ||
cpjson2 sessions/tests/ sessions/ | ||
;; | ||
transactions|transactions-convenient-api) | ||
cpjson2 transactions/tests/ transactions/ | ||
cpjson2 transactions-convenient-api/tests/ transactions-convenient-api | ||
;; | ||
unified) | ||
cpjson2 unified-test-format/tests/ unified-test-format/ | ||
;; | ||
uri|uri*options) | ||
cpjson2 uri-options/tests uri_options | ||
;; | ||
versioned-api) | ||
cpjson2 versioned-api/tests versioned-api | ||
;; | ||
*) | ||
echo "Do not know how to resync spec tests for '${spec}'" | ||
help | ||
;; | ||
esac | ||
done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.