Files
acdl/tests/test_pipeline.py
T
Jon Chery 1598c54a8b feat(P18): testing + CI/CD pipelines - pytest suite, check-only mode, Gitea + GitHub workflows (v1.3.2)
90 offline tests covering adapter, confidence_signal, checkov_adapter,
outbox_writer, and pipeline integration. Identical CI/CD workflows for
Gitea Actions (dev) and GitHub Actions (production). New --check-only
mode for run_platform.sh (offline, no AWS).

---ci---
project: acdl
phase: 18
milestone: v1.3
status: verify
---/ci---
2026-07-22 14:26:11 +00:00

67 lines
2.5 KiB
Python

import json
import os
import subprocess
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parent.parent
class TestPipelineIntegration:
def test_load_ir_and_adapt_offline(self, tmp_path):
ir = json.load(open(ROOT / "modules-ir/l1/l1-s3/spike_instance.json"))
assert ir["stack"]["name"] == "l1-s3"
sys.path.insert(0, str(ROOT))
from adapters.terraform.adapter import adapt
out_dir = str(tmp_path / "tf")
adapt(ir, out_dir)
assert os.path.isfile(os.path.join(out_dir, "main.tf"))
assert os.path.isfile(os.path.join(out_dir, "terraform.tf"))
assert os.path.isfile(os.path.join(out_dir, "providers.tf"))
main_tf = open(os.path.join(out_dir, "main.tf")).read()
assert "aws_s3_bucket" in main_tf
assert "acdl-spike-bucket" in main_tf
def test_confidence_signal_with_adapted_tf(self):
sys.path.insert(0, str(ROOT))
from acdl_platform.confidence_signal import compute
inputs = {
"policy": [{"result": "pass"}],
"validation": {"schema": True, "ir_resolved": True,
"tf_validated": True, "tf_planned": True},
"freshness": {"age_days": 0, "max_age_days": 7},
"source": {"submitter": "test", "commit_sha": "test-sha"},
"history": {"prior_rollbacks": 0, "prior_policy_fails": 0},
"nfrs": {"conformance": None},
}
sig = compute("integration-test", "dev", inputs)
assert sig.band == "pass"
assert sig.score >= 0.50
def test_run_platform_check_only(self):
result = subprocess.run(
["bash", str(ROOT / "scripts/run_platform.sh"), "--check-only"],
capture_output=True, text=True, cwd=str(ROOT),
timeout=30,
)
assert result.returncode == 0, f"stdout: {result.stdout}\nstderr: {result.stderr}"
assert "PLATFORM CHECK OK" in result.stdout
def test_run_platform_check_only_no_aws_creds(self):
env = os.environ.copy()
env.pop("AWS_ACCESS_KEY_ID", None)
env.pop("AWS_SECRET_ACCESS_KEY", None)
env.pop("AWS_DEFAULT_REGION", None)
result = subprocess.run(
["bash", str(ROOT / "scripts/run_platform.sh"), "--check-only"],
capture_output=True, text=True, cwd=str(ROOT), env=env,
timeout=30,
)
assert result.returncode == 0
assert "PLATFORM CHECK OK" in result.stdout