feat(tra-1062): pin OpenTofu version in CI and bound required_version - #162
Conversation
All four setup-opentofu steps ran unpinned, so CI silently tracked whatever `latest` was on the day the job ran. A green run today and a red run next week could differ only by an upstream OpenTofu release, with nothing in the repo changed to explain it. Pin via a repo-root `.opentofu-version` read by setup-opentofu's native `tofu_version_file` input, so the version lives in exactly one place and a bump is a one-line diff. Pinned to 1.12.5, which is what CI was already resolving `latest` to and what the workstation now runs. Also bound `required_version` from `>= 1.0.0` to `~> 1.12` across all five roots so an unintended major/minor jump fails loudly at `init` instead of silently applying. Verified: 1.11.6 now exits 1 with "Unsupported OpenTofu Core version" rather than proceeding. Verified on 1.12.5: `tofu fmt -check -recursive` clean, and `init -backend=false` + `validate` pass on all five roots. No lock-file churn and no state rewritten. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Terraform Plan (terraform/azure)Plan output unavailable (likely a job failure before plan completed). See the workflow logs for details. Error: |
1 similar comment
Terraform Plan (terraform/azure)Plan output unavailable (likely a job failure before plan completed). See the workflow logs for details. Error: |
c7319e1 to
22ec03c
Compare
Terraform Plan (terraform/azure)Plan output unavailable (likely a job failure before plan completed). See the workflow logs for details. Error: |
Verified the pin is actually load-bearingThe initial green run didn't prove much on its own: the step logs Proved it with a temporary commit setting That confirms two things at once: Current run on The failing
|
Closes TRA-1062.
Problem
All four
opentofu/setup-opentofu@v1steps ran withouttofu_version, so CI silently tracked whateverlatestwas on the day the job ran. A green run today and a red run next week could differ only by an upstream OpenTofu release, with nothing in the repo changed to explain it.Change
.opentofu-versionat the repo root, read by setup-opentofu's nativetofu_version_fileinput. Version lives in exactly one place; a bump is a one-line diff.latestto, and what the workstation now runs. This codifies the current state rather than moving anything.required_versionbounded from>= 1.0.0to~> 1.12across all five roots, so an unintended major/minor jump fails loudly atinitinstead of silently applying.Verification
Run locally on 1.12.5:
tofu fmt -check -recursive terraform/init -backend=false+validate, all 5 rootsThe guard was verified to actually bite, not just assumed. Against the new constraint, 1.11.6 exits 1:
Notes
Two things worth flagging for review:
~> 1.12meansinitrefuses to run on 1.11.6. Chosen deliberately over leaving>= 1.0.0, on the grounds that catching an unintended jump is worth more than preserving a downgrade we have no current reason to make. Rollback within 1.12.x is unaffected.initaddh1:hashes, but only when re-resolving from scratch. With.terraform/caches present it is a no-op, which is why this PR carries no lock diff. Expect the churn on the next fresh clone or new worktree; it is additive and backward-compatible.The
terraform-azureplan job runs on this PR (the workflow file is in the touched paths), which exercises the new pin end-to-end on a job that actually reaches a backend.🤖 Generated with Claude Code