Skip to content

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 15 commits into from
Feb 1, 2022

Conversation

juliusgeo
Copy link
Contributor

This is the merged and improved version of resync_specs.sh. I added a help message for basic usage, in addition to the ability to specify a commit or branch for the specs repo, a blocklist feature to ignore files that match regex patterns, and also helpful diagnostic messages that print the specific files ignored by your usage of the blocklist.

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 " Utilizes ."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete thought?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry. I realized there are a few errors like that. I will push a commit soon with fixes.

@blink1073
Copy link
Member

Should this script be in the tools folder? Is it meant to be run locally?

@blink1073
Copy link
Member

If it is meant to be used locally, we should add a section to the contributing guide.

@ShaneHarvey
Copy link
Member

Should this script be in the tools folder?

I'm not sure it fits in the tools folder. Those tools are things we ship to pypi whereas this is an internal dev script. Perhaps we should just shove it in the test/ folder?

@blink1073
Copy link
Member

I've used a scripts folder for this type of thing in the past

@juliusgeo
Copy link
Contributor Author

I've used a scripts folder for this type of thing in the past

That sounds good to me. Though I also think it works fine in .evergreen too.

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding a note in the contributing guide for how/when to use this?

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with putting this in .evergreen/ too.

#!/bin/bash
# exit when any command fails
set -e
PYMONGO=$(dirname $PWD)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PWD is the current working directory which isn't necessarily the repo root. Instead we should use the path to this file itself:

PYMONGO=$(dirname $(dirname $0))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run it inside the .evergreen folder as ./resync-specs.sh then it fails because $(dirname $(dirname $0)) resolves to ..

#!/bin/bash
# exit when any command fails
set -ex
PYMONGO=$(dirname $(dirname $0))
echo "$PYMONGO"
...
+ PYMONGO=.
+ echo .

Copy link
Member

@ShaneHarvey ShaneHarvey Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this should work:

PYMONGO=$(dirname $(cd $(dirname $0); pwd))

cd $SPECS/source
make
cd -
# cpjson2 unified-test-format/tests/invalid unified-test-format/invalid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpjson2 -> cpjson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

CONTRIBUTING.rst Outdated
folders will be copied from and to. It supports
filtering using regex patterns, and it will show you which files it ignored
when using this feature so you can ensure you are not leaving any important
tests behind.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more helpful to document how to setup and use the script. Like this (but fixed up so it actually works):

git clone specs repo
export MDB_SPECS=path/to/specs
cd mongodb-python-driver
.evergreen/resync-specs.sh crud bson-corpus

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#!/bin/bash
# exit when any command fails
set -e
PYMONGO=$(dirname $PWD)
Copy link
Member

@ShaneHarvey ShaneHarvey Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this should work:

PYMONGO=$(dirname $(cd $(dirname $0); pwd))

@juliusgeo juliusgeo requested a review from ShaneHarvey February 1, 2022 19:45
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran shellcheck on this file and it showed 3 warnings:

In test.sh line 4:
PYMONGO=$(dirname $(cd $(dirname $0); pwd))
                  ^----------------------^ SC2046 (warning): Quote this to prevent word splitting.
                       ^-----------^ SC2046 (warning): Quote this to prevent word splitting.
                                 ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean:
PYMONGO=$(dirname $(cd $(dirname "$0"); pwd))


In test.sh line 30:
    b) BLOCKLIST+="|"$OPTARG""
                     ^-----^ SC2027 (warning): The surrounding quotes actually unquote this. Remove or escape them.

@juliusgeo juliusgeo requested a review from blink1073 February 1, 2022 20:21
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@juliusgeo juliusgeo merged commit aa60c2a into mongodb:master Feb 1, 2022
juliusgeo added a commit to juliusgeo/mongo-python-driver that referenced this pull request Apr 5, 2022
juliusgeo added a commit to juliusgeo/mongo-python-driver that referenced this pull request Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants