consumerfinance.gov
consumerfinance.gov copied to clipboard
Use environment variables in tox.ini
For example, can https://github.com/cfpb/consumerfinance.gov/blob/main/tox.ini#L87 use https://github.com/cfpb/consumerfinance.gov/blob/main/.env_SAMPLE#L66 ? For that and the other settings that appear in the environment (ES_PORT and ES_HOST).
Hey bewds, just looking through old issues. Seems like this would be a quick one? @richaagarwal @willbarton @chosak
Sorry for neglecting this one. Yes, you can totally do that.
Updated example is https://github.com/cfpb/consumerfinance.gov/blob/main/tox.ini#L86 (WAGTAIL_SHARING_HOSTNAME=content.localhost), which is set in https://github.com/cfpb/consumerfinance.gov/blob/master/.env_SAMPLE#L27 (export WAGTAIL_SHARING_HOSTNAME=content.localhost).
@anselmbradford can this ancient issue be closed? The list of environment variables that tox passes in can be found here.
I'm not sure. My original inquiry was about why we duplicated the variable and value of, for example, WAGTAIL_SHARING_HOSTNAME=content.localhost in both tox.ini (here) and in .env_SAMPLE (here).
Is there a reason we'd create those envvars in .env and then recreate them in tox.ini without using the existing one? Or could it be deleted from .env_SAMPLE?
@anselmbradford we don't always have a .env file when running tox, for example when it runs as part of automated testing on GitHub Actions. So tox.ini needs to define all the environment variables that it needs to run its tests. Separately, .env (and its template .env_SAMPLE) are intended to help devs configure their local environment even in ways that might differ from what we test.
As it happens though, and somewhat surprisingly to me, none of our Python tests actually make use of the value of either WAGTAIL_SHARING_HOSTNAME or GOVDELIVERY_ACCOUNT_CODE. So these can be removed from tox.ini: https://github.com/cfpb/consumerfinance.gov/pull/8165