-
Notifications
You must be signed in to change notification settings - Fork 14
Pass environment to docker container for local-test
#409
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import sys | ||
| from typing import List | ||
|
|
||
| from ..auth import get_dotenv_values | ||
| from .utils import _build_entry_point, _discover_and_select_tests | ||
|
|
||
|
|
||
|
|
@@ -71,6 +72,12 @@ def _run_pytest_in_docker( | |
| workdir, | ||
| ] | ||
|
|
||
| # Forward environment variables from .env file to the container | ||
| dotenv_vars = get_dotenv_values(project_root) | ||
| for key, value in dotenv_vars.items(): | ||
| if value is not None: | ||
| cmd += ["-e", f"{key}={value}"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dotenv variables may override critical container settingsMedium Severity Environment variables from the |
||
|
|
||
| # If EP_SUMMARY_JSON is set on the host, mirror it into the container so that | ||
| # pytest evaluation tests can write summary artifacts that are visible to the | ||
| # host. We map paths under the host logs directory (~/.eval_protocol) into the | ||
|
|
||
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.
Inconsistent dotenv search behavior between host and Docker
Medium Severity
The
find_dotenv_pathfunction behaves differently depending on whethersearch_pathis provided. Without an argument, it searches up the directory tree usingfind_dotenv(). With a path, it only looks in that exact directory. The module-level load uses the former (finding parent.envfiles), whileget_dotenv_values(project_root)uses the latter. This means environment variables from a parent directory's.envfile are loaded into the host but not forwarded to Docker, causing tests to pass locally but fail in the container.Additional Locations (1)
eval_protocol/cli_commands/local_test.py#L75-L76