litellm/.github/e2e-stack/secrets_to_env.py
Yuneng Jiang 4a646dd9a0
ci(e2e): run a PR's changed e2e tests three times behind a human-approved environment
Adds a required-check candidate that selects the tests/e2e test files a PR added or
modified, boots a stage-mirror stack on the runner (migrations, backend, two gateway
processes behind nginx, Postgres, Jaeger, TLS cluster Valkey), and runs those files
three times with retries off. The run job sits behind the e2e-changed GitHub
environment, so a reviewer approves each run before the OIDC token that reads the
provider keys from AWS Secrets Manager exists. Supersedes #34981
2026-09-02 14:53:40 -07:00

28 lines
887 B
Python

import sys
from pathlib import Path
from pydantic import TypeAdapter
secrets_adapter: TypeAdapter[dict[str, str]] = TypeAdapter(dict[str, str])
def main() -> int:
env_path = Path(sys.argv[1])
secrets = secrets_adapter.validate_json(sys.stdin.read())
unwritable = tuple(
key for key, value in secrets.items() if "'" in value or "\n" in value or "\r" in value
)
if unwritable:
_ = sys.stderr.write(f"values contain characters unsafe for both bash and dotenv: {', '.join(unwritable)}\n")
return 1
lines = tuple(f"{key}='{value}'" for key, value in secrets.items() if value)
with env_path.open("a") as handle:
_ = handle.write("\n".join(lines) + "\n")
for value in secrets.values():
if value:
_ = sys.stdout.write(f"::add-mask::{value}\n")
return 0
if __name__ == "__main__":
sys.exit(main())