Files
awoooi/ops/runner/test_cd_controlled_runtime_profile.py
2026-06-29 13:51:38 +08:00

79 lines
3.1 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
CD_WORKFLOW = ROOT / ".gitea" / "workflows" / "cd.yaml"
def _workflow_text() -> str:
return CD_WORKFLOW.read_text(encoding="utf-8")
def test_web_changes_stay_on_controlled_runtime_profile() -> None:
text = _workflow_text()
assert "apps/web/*)" in text
assert "UI-only changes are verified by the" in text
def test_product_manifest_changes_stay_on_controlled_runtime_profile() -> None:
text = _workflow_text()
assert "product.awoooi.yaml)" in text
assert "apps/api/Dockerfile)" in text
assert "docs/schemas/product_awoooi_manifest_v1.schema.json)" in text
assert "apps/api/src/services/product_awoooi_manifest_standard.py)" in text
assert "tests/test_product_awoooi_manifest_standard_api.py" in text
def test_credential_escrow_intake_stays_on_controlled_runtime_profile() -> None:
text = _workflow_text()
assert "apps/api/src/services/credential_escrow_evidence_intake_readiness.py)" in text
assert "src/services/credential_escrow_evidence_intake_readiness.py" in text
assert "tests/test_credential_escrow_evidence_intake_readiness_api.py" in text
def test_p0_onboarding_readiness_sources_stay_on_controlled_runtime_profile() -> None:
text = _workflow_text()
expected_sources = [
"awoooi_gitea_onboarding_warning_step_dashboard.py",
"awoooi_gitea_onboarding_warning_step_owner_package.py",
"awoooi_gitea_onboarding_warning_step_owner_response_preflight.py",
"awoooi_gitea_onboarding_warning_step_template_copy_apply_gate.py",
"awoooi_gitea_onboarding_warning_step_template_copy_execution_plan.py",
"awoooi_new_product_onboarding_page_model.py",
"awoooi_onboarding_reminder_contract.py",
"awoooi_onboarding_source_contracts.py",
"awoooi_product_onboarding_guard.py",
]
for source in expected_sources:
assert f"apps/api/src/services/{source})" in text
assert f"src/services/{source}" in text
def test_iwooos_security_operation_api_stays_on_controlled_runtime_profile() -> None:
text = _workflow_text()
expected_sources = [
"apps/api/src/api/v1/iwooos.py)",
"apps/api/src/services/iwooos_security_operating_system.py)",
"apps/api/tests/test_iwooos_security_operating_system.py)",
"src/api/v1/iwooos.py",
"src/services/iwooos_security_operating_system.py",
"tests/test_iwooos_security_operating_system.py",
]
for source in expected_sources:
assert source in text
def test_controlled_runtime_skips_b5_before_docker_socket_use() -> None:
text = _workflow_text()
b5_start = text.index("- name: Integration Tests (B5")
docker_socket = text.index("-v /var/run/docker.sock:/var/run/docker.sock", b5_start)
controlled_gate = text.index(
'if [ "${AWOOOI_CD_TEST_PROFILE:-full}" = "controlled-runtime" ]; then',
b5_start,
)
exit_zero = text.index("exit 0", controlled_gate)
assert controlled_gate < exit_zero < docker_socket