-
Notifications
You must be signed in to change notification settings - Fork 14
Create tox environment for running tests #144
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
base: main
Are you sure you want to change the base?
Conversation
| deps = | ||
| absl-py | ||
| google-api-core | ||
| google-cloud-spanner >= 1.17.1 | ||
| frozendict | ||
| portpicker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to keep this in sync with other places? E.g. could we put this in a requirements.txt or something, and reference that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While these can be put in a requirements.txt file, I don't think setup.py should be referencing that file, so there still would be duplication
https://stackoverflow.com/a/33685899
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up adding the below in a different PR because of the same issue with setup.py not referencing requirements.txt. Would it make sense to add requirements.txt here, and use it both for tox and the github workflow? Or would the github workflow use tox and not need to reference the dependencies explicitly anymore?
tox.ini
Outdated
| wget https://storage.googleapis.com/cloud-spanner-emulator/releases/{env:VERSION}/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -P /tmp/spanner_emulator/ | ||
| tar zxvf /tmp/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -C /tmp/spanner_emulator/ | ||
| chmod u+x /tmp/spanner_emulator/gateway_main /tmp/spanner_emulator/emulator_main | ||
| python setup.py test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description mentions a warning about doing this. Should this be something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing that in a tox env is still OK, but just to be safe, I switched to pytest. It has a cleaner test output too!
tox.ini
Outdated
| wget https://storage.googleapis.com/cloud-spanner-emulator/releases/{env:VERSION}/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -P /tmp/spanner_emulator/ | ||
| tar zxvf /tmp/cloud-spanner-emulator_linux_amd64-{env:VERSION}.tar.gz -C /tmp/spanner_emulator/ | ||
| chmod u+x /tmp/spanner_emulator/gateway_main /tmp/spanner_emulator/emulator_main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this going to run every time we run tests? Is there any way to cache it? (Feel free to push this off to another PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm inclined to push this off for now. In practice (on my admittedly fast internet connection) this steps only takes a couple of seconds.
| cloud-spanner-emulator* | ||
| emulator_main | ||
| gateway_main | ||
| .spanner_emulator/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) add / at the beginning of the line, so it only matches in this directory.
dseomn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind updating https://github.com/google/python-spanner-orm/blob/main/.github/workflows/test.yaml to use tox too?
| deps = | ||
| absl-py | ||
| google-api-core | ||
| google-cloud-spanner >= 1.17.1 | ||
| frozendict | ||
| portpicker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up adding the below in a different PR because of the same issue with setup.py not referencing requirements.txt. Would it make sense to add requirements.txt here, and use it both for tox and the github workflow? Or would the github workflow use tox and not need to reference the dependencies explicitly anymore?
| absl-py | ||
| google-api-core | ||
| google-cloud-spanner >= 1.17.1 | ||
| frozendict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) This is out of date.
| deps = | ||
| absl-py | ||
| google-api-core | ||
| google-cloud-spanner >= 1.17.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) This doesn't match the other places, but I don't know what it should be.
| # and then run "tox" from this directory. | ||
|
|
||
| [tox] | ||
| envlist = py36, py37, py38 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) Remove 3.6, add 3.9.
When running
python setup.py testin the past, we've gotten the following messageWARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.. This PR listens to that advice and creates a tox environment for running tests :)The nice thing about using tox for tests is we can integrate the setup of Spanner emulator into the tox command.
After a couple people confirm that tox runs for them successfully (i.e. by running
tox -e py38), I will update theREADMEto point users to run tests with tox.Tested: ran tests successfully.