From d30d1448f53595e6c3d31fcf565d1e30d6476200 Mon Sep 17 00:00:00 2001 From: Ehtisham Mubarik <40181801+ehtishammubarik@users.noreply.github.com> Date: Fri, 4 Sep 2026 13:37:55 +0000 Subject: [PATCH] fix(ci): stop the release workflow re-asserting HCL the test suite already owns The v0.1.1 release failed at test-wheel on all three Pythons, published nothing, and surfaced a workflow that had been broken for five weeks. release.yml asserted `publicly_accessible = false` with a single space. create_db_subnet_group is 22 characters and joined that block in #13, so terraform fmt realigned the attribute to four spaces and the assertion has been false since 2026-07-31. Nothing noticed because the workflow runs only on a tag push, and no tag was cut in that window. The generated output was correct throughout: the database is private, and prod deletion_protection is true. The assertions should not have been there. tests/test_stackmason.py already covers both properties, and covers them whitespace-tolerantly, and the step directly above runs that suite against the installed package with the source tree deleted. The workflow copy was strictly worse duplication: no feedback loop between releases, so it drifted silently while the copy next to the code was kept correct. - release.yml: drop the HCL content assertions. What remains is what the suite genuinely cannot see, because it is about the artifact rather than the source: the entry point resolves from the wheel, a real `stackmason new` writes real files, the published build still refuses an 0.0.0.0/0 database and writes nothing when it blocks, and the output carries no literal credential. Added outputs.tf to the file list, since #29 made it part of every environment. - A comment states why there are no content assertions there, with the #13 alignment story, so the next person does not add one back. - tests: made the deletion_protection assertion whitespace-tolerant, matching the regex style already used two functions below it for publicly_accessible. Demonstrated both directions rather than assuming: realigned the attribute to one space -> test passes set prod deletion_protection = false -> test fails Verified: pytest 91 passed, coverage 90.90% against the 88% floor, ruff clean. Closes #33 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_012fMM2HhoJ2XzDkfMR2HwSa --- .github/workflows/release.yml | 19 ++++++++++++++----- tests/test_stackmason.py | 11 +++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8e5dce..c236699 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -159,17 +159,26 @@ jobs: JSON stackmason new acme --answers /tmp/answers.json --yes -o /tmp/gen + # Assert only what the installed artifact can be wrong about that the + # suite above cannot see: that the entry point resolves from the wheel + # and that a real `stackmason new` writes real files to a real disk. + # + # Deliberately NO assertions about the CONTENT of the generated HCL. + # tests/test_stackmason.py already owns those, whitespace-tolerantly, + # and the step above runs that suite against the installed package + # with the source tree deleted. A duplicate here is strictly worse: it + # only runs on a tag push, so it has no feedback loop between releases. + # One did exactly that, asserting `publicly_accessible = false` with a + # single space. #13 added `create_db_subnet_group` to the same block, + # terraform fmt realigned it to four, and the workflow was red for five + # weeks because nothing ran it. See #33. Do not add one back. python - <<'PY' import pathlib root = pathlib.Path("/tmp/gen") for f in ("environments/dev/main.tf", "environments/prod/main.tf", + "environments/dev/outputs.tf", "environments/prod/outputs.tf", "ARCHITECTURE.md", "DECISIONS.md", ".gitignore"): assert (root / f).exists(), f - prod = (root / "environments/prod/main.tf").read_text() - assert "deletion_protection = true" in prod - assert "publicly_accessible = false" in prod - assert "cluster_name" in prod - assert (root / "environments/dev/main.tf").read_text().count("deletion_protection = false") == 1 print("generated repository verified") PY diff --git a/tests/test_stackmason.py b/tests/test_stackmason.py index a4d19d1..458bc45 100644 --- a/tests/test_stackmason.py +++ b/tests/test_stackmason.py @@ -245,8 +245,15 @@ def test_database_password_variable_has_no_default(tmp_path): def test_production_gets_deletion_protection_and_dev_does_not(tmp_path): plan = build_plan(tmp_path, "acme", ["rds"], ["dev", "prod"], BASE) - assert "deletion_protection = true" in plan.files["environments/prod/main.tf"] - assert "deletion_protection = false" in plan.files["environments/dev/main.tf"] + # Whitespace-tolerant on purpose. terraform fmt realigns a block whenever a + # longer attribute name joins it, and an exact-alignment assertion turns + # every such edit into an unrelated failure. See #33. + assert re.search( + r"^\s+deletion_protection\s+= true$", plan.files["environments/prod/main.tf"], re.M + ) + assert re.search( + r"^\s+deletion_protection\s+= false$", plan.files["environments/dev/main.tf"], re.M + ) def test_database_is_never_publicly_accessible(tmp_path):