-
Notifications
You must be signed in to change notification settings - Fork 35
Set up for dot-env. #655
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
Open
JoeZiminski
wants to merge
13
commits into
main
Choose a base branch
from
try-dotenv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Set up for dot-env. #655
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ce57022
Set up for dot-env.
JoeZiminski 026db76
Fix docs.
JoeZiminski 196f07b
Add python-dotenv to project dependencies
JoeZiminski a053443
temp comment CI for quicker testing.
JoeZiminski 95a6c66
Merge branch 'try-dotenv' of github.com:neuroinformatics-unit/datashu…
JoeZiminski ddae096
Revert CI change.
JoeZiminski 88e8a1a
Refactor, remove duplication.
JoeZiminski b10b1f1
Update tests/tests_transfers/gdrive/gdrive_test_utils.py
JoeZiminski 61a8e4f
Update tests/tests_transfers/transfer_test_utils.py
JoeZiminski b91ccab
Update tests/tests_transfers/transfer_test_utils.py
JoeZiminski 827ffb3
Update tests/tests_transfers/transfer_test_utils.py
JoeZiminski 34e5e24
Fix.
JoeZiminski 844adbf
Reduce if statements.
JoeZiminski 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
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 |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ dev = [ | |
| "types-setuptools", | ||
| "pytest-asyncio", | ||
| "validators", | ||
| "python-dotenv", | ||
| ] | ||
|
|
||
| [build-system] | ||
|
|
||
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
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
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,40 @@ | ||
| import os | ||
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
|
|
||
| def check_if_env_vars_are_loaded(required_variables): | ||
| """Check if environment variables required to run tests are loaded. | ||
|
|
||
| If we are on GitHub, these should be loaded in the | ||
| workflow `.yaml` files. Otherwise, these can be set manually | ||
| or (more conveniently) added to a `.env` file in the project root. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| required_variables : | ||
| A list of required variables to check for. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| True if all required environment variables are loaded, False otherwise. | ||
| """ | ||
| # Outside of GitHub actions, if env vars are not | ||
| # loaded try and load using dotenv. | ||
| if ( | ||
| not os.getenv("GITHUB_ACTIONS") | ||
| and not all(var in os.environ for var in required_variables) | ||
| and not load_dotenv() | ||
| ): | ||
| return False | ||
|
|
||
| for var in required_variables: | ||
| if var not in os.environ: | ||
| return False | ||
|
|
||
| # On CI triggered by forked repositories, secrets are empty | ||
| if os.environ[var].strip() == "": | ||
| return False | ||
|
|
||
| return True | ||
Oops, something went wrong.
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.