chore(release): initialize separated production env
Deploy / Deploy Production (push) Failing after 2089h3m52s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 2089h6m25s
Deploy / Deploy Staging (push) Has been cancelled

This commit is contained in:
Xiaoxia AI
2026-06-21 14:24:23 +08:00
parent 1f89f8edfe
commit f22af7ee4c
7 changed files with 146 additions and 5 deletions
+13
View File
@@ -10,6 +10,19 @@ def test_restore_postgres_plan_is_non_destructive():
assert "pg_restore" not in executable_prefix
def test_init_production_env_is_non_deploying_and_separated():
script = Path("scripts/init_production_env.sh").read_text(encoding="utf-8")
assert "APP_ENV=production" in script
assert "ENVIRONMENT=production" in script
assert "xiaoxia-postgres-production" in script
assert "xiaoxia-redis-production" in script
assert "GENERATED_FILES_HOST_DIR=$GENERATED_DIR" in script
assert "ENABLE_EMAIL_DELIVERY=false" in script
assert "docker compose" not in script
assert "docker run" not in script
def test_backup_postgres_writes_manifest_and_version():
script = Path("scripts/backup_postgres.sh").read_text(encoding="utf-8")
+26
View File
@@ -35,6 +35,32 @@ def test_validate_release_env_accepts_strict_production(tmp_path: Path):
assert validate(parse_env_file(env_file), strict_external=True) == []
def test_validate_release_env_allows_disabled_smtp_with_strict_external(tmp_path: Path):
env_file = tmp_path / ".env.production"
env_file.write_text(
"\n".join(
[
"APP_ENV=production",
"DATABASE_URL=postgresql+psycopg://user:pass@db:5432/app",
"JWT_SECRET_KEY=abcdefghijklmnopqrstuvwxyz123456",
"REDIS_URL=redis://redis:6379/0",
"ENABLE_EMAIL_DELIVERY=false",
"ENABLE_REDIS_SESSIONS=true",
"OSS_ENDPOINT=oss-cn-hangzhou.aliyuncs.com",
"OSS_ACCESS_KEY_ID=ak-real",
"OSS_ACCESS_KEY_SECRET=sk-real-secret",
"OSS_BUCKET_NAME=xiaoxia-prod",
"GENERATED_FILES_HOST_DIR=/var/lib/xiaoxia-saas-production/generated",
"DEBUG=false",
"AUTO_CREATE_SCHEMA=false",
]
),
encoding="utf-8",
)
assert validate(parse_env_file(env_file), strict_external=True) == []
def test_validate_release_env_rejects_placeholders_and_staging_paths(tmp_path: Path):
env_file = tmp_path / ".env.production"
env_file.write_text(