e048acd4dd
VERIFY: structural — dead export + stale comments + prefixes gone; behavioral — 616 tests + CI PASS; quality — env-override test updated. ---ci--- project: acdl phase: 3 milestone: v1.16 status: complete phase_role: execution requirements: covered: [REQ-167] partial: [] ---/ci---
84 lines
3.1 KiB
Python
84 lines
3.1 KiB
Python
"""REQ-106: deploy workflow environment input + run_platform.sh --environment.
|
|
Both deploy workflows (Gitea + GitHub) declare the environment input,
|
|
are byte-identical, and the resolver supports environment_override.
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from core.contract_resolver import resolve
|
|
|
|
GITHUB = ROOT / ".github" / "workflows" / "deploy.yml"
|
|
GITEA = ROOT / ".gitea" / "workflows" / "deploy.yml"
|
|
|
|
|
|
def test_both_deploy_workflows_exist():
|
|
assert GITHUB.is_file()
|
|
assert GITEA.is_file()
|
|
|
|
|
|
def test_deploy_workflows_byte_identical():
|
|
assert GITHUB.read_text() == GITEA.read_text(), "deploy workflows must be byte-identical"
|
|
|
|
|
|
def test_deploy_workflow_has_environment_input():
|
|
text = GITHUB.read_text()
|
|
assert "environment:" in text
|
|
assert "Target environment override" in text
|
|
# The input is declared in the workflow_call inputs section.
|
|
assert 'default: ""' in text
|
|
|
|
|
|
def test_deploy_workflow_passes_env_flag_to_run_platform():
|
|
text = GITHUB.read_text()
|
|
assert "--environment" in text
|
|
assert "ENV_FLAG" in text
|
|
assert "inputs.environment" in text
|
|
|
|
|
|
def test_resolver_environment_override_changes_env():
|
|
"""D-088: environment_override changes the resolved environment."""
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"),
|
|
environment_override="qa")
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
assert "qa" in s3["inputs"]["bucket_name"]
|
|
|
|
|
|
def test_resolver_environment_override_prod():
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"),
|
|
environment_override="prod")
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
assert "prod" in s3["inputs"]["bucket_name"]
|
|
|
|
|
|
def test_resolver_environment_override_dr():
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"),
|
|
environment_override="dr")
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
assert "dr" in s3["inputs"]["bucket_name"]
|
|
|
|
|
|
def test_resolver_no_override_uses_contract_env():
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"))
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
assert "dev" in s3["inputs"]["bucket_name"]
|
|
|
|
|
|
def test_resolver_override_none_uses_contract_env():
|
|
"""Passing environment_override=None uses the contract's environment."""
|
|
stack = resolve(str(ROOT / "contracts" / "static-assets.yml"),
|
|
environment_override=None)
|
|
s3 = [r for r in stack["resources"] if r["type"] == "aws:s3:bucket"][0]
|
|
assert "dev" in s3["inputs"]["bucket_name"]
|
|
|
|
|
|
def test_run_platform_sh_has_environment_flag():
|
|
text = (ROOT / "scripts" / "run_platform.sh").read_text()
|
|
assert "--environment" in text
|
|
assert "ENVIRONMENT_OVERRIDE" in text
|
|
# P3 (REQ-167): NOVA_* only; the dead ACDL_ENVIRONMENT_OVERRIDE export
|
|
# (comment said "removed in P5" but the line was present) is gone.
|
|
assert "NOVA_ENVIRONMENT_OVERRIDE" in text
|
|
assert "ACDL_ENVIRONMENT_OVERRIDE" not in text |