Pull Request - CI/CD Part 1 Dynamic Env - Digital Dreamers #100
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.
Summary
The .env file with the utility function configures environment variables during local development. This allows developers to customize their local environment without affecting the production settings.
Changes
Two files added:
env_manager.py
(Location: app/services/env_manager.py) andtest_env_manager.py
(Location: app/services/tests/test_env_manager.py)Changes made to the
./local-start.sh
to incorporate the utility function.gitignore
to ignore the folder keys/requirements.txt
, fastapi changed to fastapi[standard]Testing
The new feature was tested using the following unit tests and integration tests. Refer to the documentation for more details.
I) Unit Tests
Steps to run the unit tests:
Execute the test command:
pytest app/services/tests/test_env_manager.py
Review the test output: after running the command, you’ll see output indicating whether the tests passed or failed.
Expected Output: Upon successful execution, you should see the following output in terminal:
II) Integration Tests
Steps to run the integration test:
Run the Startup Script:
The script begins by setting up local environment variables required by the application.
It authenticates the Google Cloud project using the service account credentials specified in the ‘local-auth.json’ file.
The ‘get_env_variable’ function is called to fetch environment variables, ‘GOOGLE_API_KEY’, ‘ENV_TYPE’,and ‘PROJECT_ID’. These variables are either retrieved from the local ‘.env’ file or from Google Cloud Secret Manager if not found locally.
Expected Output: Upon successful execution, you should see the following output in terminal:
Results
The new feature passed the above-mentioned tests and performed its required function without breaking the existing codebase.
Notes
Screenshots
The utility function with relevant error handling performed.