Skip to content

feat(terraform.test): add composite action for Terraform tests - #44

Open
posquit0 wants to merge 1 commit into
mainfrom
feat/terraform-test
Open

posquit0 wants to merge 1 commit into
mainfrom
feat/terraform-test

Conversation

@posquit0

Copy link
Copy Markdown
Member

👋 Background

Terraform integration has reusable format, validation, and lint actions, but no standalone action for executing .tftest.hcl and .tftest.json tests.

⚙️ Description

Add .github/actions/terraform.test following the existing Terraform composite action conventions: caller-managed CLI installation, snake_case inputs, shell.run outputs, failure annotations, and github.step-summary failure details.

  • Expose target_dir, workspace, test_directory, filters, var_files, vars, format, verbose, parallelism, junit_xml, cloud_run, and annotations_enabled.
  • Preserve each line of repeated options as a single argument, including spaces and HCL expressions. Load variable files before explicit variable assignments.
  • Initialize local runs without a backend and pass the selected test directory to both init and test, so modules referenced by custom test directories are installed. Skip local init for HCP Terraform execution.
  • Return skipped, stdout, stderr, and exitcode; report init failures without running tests. Read captured diagnostics for annotations without executing tests again.
  • Document defaults, path semantics, version requirements, and report handling. Existing integration workflows are unchanged.

Validation:

  • Terraform 1.16.5: all 12 regression tests passed against temporary provider-free fixtures, including failure summaries, JSON diagnostics, repeated options, JUnit success/failure reports, and custom test modules.
  • Terraform 1.6.2: 10 passed; 2 skipped for newer CLI features.
  • YAML lint, GitHub Actions metadata schema validation, Bash syntax checks, ShellCheck for all action scripts, and git diff --check passed.

🚨 To Reviewers

The default invocation supports Terraform 1.6+. JUnit requires 1.11+; parallelism and initialization of test-only configurations require 1.12+. junit_xml and cloud_run are mutually exclusive. Remote argument forwarding is covered by a stub; authenticated HCP Terraform execution was not exercised.

@github-actions github-actions Bot added 💾 actions This issue or pull request is related to actions. size/L Large size issue or PR. labels Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💾 actions This issue or pull request is related to actions. size/L Large size issue or PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant