Skip to content
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

Add ability to dump test env vars to file #266

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion builder/actions/setup_cross_ci_crt_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,11 @@ def _common_setup(self, env):
pass

def run(self, env):
# A special environment variable indicating that we want to dump test environment variables to a specified file.
env_dump_file = env.shell.getenv("AWS_SETUP_CRT_TEST_ENVIRONMENT_DUMP_FILE")

# Bail if not running tests
if not env.project.needs_tests(env):
if not env.project.needs_tests(env) and not env_dump_file:
print('Tests not needed for project. Skipping setting test environment variables')
return

Expand Down Expand Up @@ -475,3 +478,10 @@ def run(self, env):
print(f"Detected whether on Codebuild: {self.is_codebuild}")

self._common_setup(env)

# Create a temporary file with all environment variables.
# Useful for running tests locally.
if env_dump_file:
with open(file=env_dump_file, mode='w+') as file:
for env_name, env_value in env.project.config['test_env'].items():
file.write(f"export {env_name}={env_value}\n")
Loading