Skip to content

Enhancement | Modernize the ref-arch integration test (integration_tests_cli_refarch) #330

Closed

Description

@diego-ojeda-binbash

For team discussion at the next meeting. Companion to binbashar/le-tf-infra-aws#1292, which proposes deleting the ref-arch copy of this test and leaving this job as the only place the Leverage CLI is tested against the reference architecture.

Describe the Feature

Modernize the integration_tests_cli_refarch job in .github/workflows/tests-integration.yaml. This job tests the CLI end to end against the reference architecture. In order, it runs:

  • project init + project create on an empty project
  • leverage aws sts get-caller-identity
  • a clone of le-tf-infra-aws (master), then init → plan → apply → plan -detailed-exitcode → destroy on apps-devstg/global/cli-test-layer.

It is the right place for this test: the PR that changes the CLI is the thing under test. It also works. The 2026-09-18 run reached Apply complete! Resources: 3 added → No changes → Destroy complete! Resources: 3 destroyed. But it still assumes the Docker toolbox era.

Current problems

Problem Detail
Obsolete matrix 5 Python versions × 3 Docker toolbox tags = 15 real apply/destroy runs in apps-devstg per PR (max-parallel: 1). Since #328 the CLI no longer uses Docker, so the toolbox-image-tag axis tests nothing.
Last run is red The 2026-10-01 run (on the #328 branch) fails with Terraform binary not found on system at the leverage terraform init step of the freshly created project. Cause not yet investigated.
Stale toolchain OpenTofu 1.9.1 (the ref arch runs 1.13.2). It uses leverage terraform rather than leverage tofu, plus actions/checkout@v3 and actions/setup-python@v2.
Convergence check never fails [[ $? -eq 2 ]] && printf "[WARN] ..." followed by [[ $? -eq 0 ]]. Drift after apply only prints a warning, and the second check tests the previous [[ instead of the plan. destroy is in the same step, so a failed apply skips cleanup.
Static credentials Long-lived DeployMaster keys, with MFA and SSO disabled. The SSO path, which is what users actually run, is not covered.
Fork PRs Runs from external contributors sit in action_required until a maintainer approves them (e.g. the 2026-10-23 runs).

Expected Behavior

  • One ref-arch round-trip per PR (or a minimal Python matrix), on the current CLI with OpenTofu 1.13.2.
  • The job fails when any leverage tofu command fails, or when the post-apply plan is not empty.
  • destroy always runs, even when apply fails.

Use Case

Today this is the only CI anywhere that runs the Leverage CLI against the reference architecture. The ref arch's own tofu-plan/tofu-apply CI calls native tofu and never runs Leverage. The ref-arch copy of this test (leverage-cli-test.yml) has reported a false green for weeks (binbashar/le-tf-infra-aws#1292). It is also misplaced there: a ref-arch PR does not change the CLI.

Describe Ideal Solution

  1. Matrix: drop the toolbox-image-tag axis. Run the ref-arch job on the oldest and newest supported Python only. The full Python matrix already belongs to the unit tests.
  2. Toolchain: opentofu/setup-opentofu at 1.13.2, leverage tofu instead of leverage terraform, and bump the actions.
  3. Fail correctly:
    set -euo pipefail
    leverage tofu init --layers cli-test-layer
    leverage tofu apply -auto-approve --layers cli-test-layer
    rc=0; leverage tofu plan -detailed-exitcode --layers cli-test-layer || rc=$?
    [[ $rc -eq 0 ]] || { echo "::error::post-apply plan not empty (rc=$rc)"; exit 1; }
    Put destroy in its own step with if: always().
  4. Diagnose and fix the Terraform binary not found failure.
  5. (Optional) Use OIDC role assumption instead of static DeployMaster keys.

Estimated effort: half a day to one day.

Alternatives Considered

  • Keep the test only in the ref arch: rejected. A ref-arch PR does not change the CLI, so it never tests what changed. See Fix | Leverage CLI test workflow reports success while every tofu command fails le-tf-infra-aws#1292.
  • Emulate AWS with Floci instead of a real account. A local feasibility analysis (2026-09-06) found it viable for the bootstrap flow (project init/create, BOOTSTRAP credentials, backend, organizations, security-base, base-network), but blocked for SSO. Floci does not implement sso, sso-oidc or identitystore yet. Suggested as a 2–3 day spike after this modernization, not instead of it.

Additional Context

Metadata

Metadata

Labels

enhancementtest

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions