fix(release): support environment validation in containers
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 12s
Deploy / Deploy Staging (push) Successful in 1m54s
Deploy / Deploy Production (push) Has been skipped

This commit is contained in:
Xiaoxia AI
2026-06-21 12:39:40 +08:00
parent e36347210c
commit 1708401bcd
2 changed files with 20 additions and 4 deletions
+18 -3
View File
@@ -108,7 +108,12 @@ def validate(values: dict[str, str], strict_external: bool) -> list[str]:
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("env_file", type=Path)
parser.add_argument("env_file", type=Path, nargs="?", help="Env file to validate. Omit with --from-environ.")
parser.add_argument(
"--from-environ",
action="store_true",
help="Validate the current process environment instead of reading an env file.",
)
parser.add_argument(
"--strict-external",
action="store_true",
@@ -116,14 +121,24 @@ def main() -> int:
)
args = parser.parse_args()
values = parse_env_file(args.env_file)
if args.from_environ:
import os
values = dict(os.environ)
source = "process environment"
else:
if args.env_file is None:
parser.error("env_file is required unless --from-environ is set")
values = parse_env_file(args.env_file)
source = str(args.env_file)
errors = validate(values, args.strict_external)
if errors:
for error in errors:
print(f"ERROR: {error}")
return 1
print(f"OK: {args.env_file} passed release env validation")
print(f"OK: {source} passed release env validation")
return 0