Skip to content

add support for linting IaC#48

Merged
ms280690 merged 3 commits into
mainfrom
issue-9-lint-iac
Jun 23, 2026
Merged

add support for linting IaC#48
ms280690 merged 3 commits into
mainfrom
issue-9-lint-iac

Conversation

@ms280690

@ms280690 ms280690 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Closes #9. Infrastructure-as-Code lint stage of parent #12. Reuses the shared
lint-precommit.yml from #10; adds the tflint PR gate.

What

File Purpose
.github/actions/tflint/action.yml Composite — installs a pinned, checksum-verified tflint v0.63.1 binary; runs --init (plugins) then --recursive --format compact --minimum-failure-severity.
.github/actions/tflint/tflint-matcher.json Problem matcher — turns tflint compact output into inline PR annotations (native, no reviewdog/SARIF).
.github/workflows/lint-iac.yml Reusable PR gate. Inputs: directory, minimum-failure-severity, actions-ref. Caches tflint plugins via actions/cache.
.github/workflows/ci.yml Dogfood tflint job (smoke test — no .tf in this repo).
examples/iac.pre-commit-config.yaml Reference local config (pre-commit-terraform, SHA-pinned): terraform_fmt / terraform_validate / terraform_tflint.
README.md, docs/approved-actions.md Usage (AWS/GCP/Azure .tflint.hcl), tooling tracking.

Acceptance criteria (#9)

  • lint-iac.yml: installs tflint with plugin support; tflint --recursive from directory; PR annotations; blocks on error-level findings
  • directory input (non-root IaC dirs)
  • minimum-failure-severity input (default error)
  • Plugin caching (actions/cache, keyed on any .tflint.hcl)
  • Provider-agnostic — rule sets via consuming-repo .tflint.hcl
  • README documents baseline .tflint.hcl for AWS, GCP, Azure

Design notes

  • Checksum-verified binary, not setup-tflint — one verified download, no new org-allowlist publisher, zizmor-clean (no GITHUB_PATH write). Consistent with the gitleaks/trufflehog/megalinter pattern.
  • PR annotations via a problem matcher (rung 3, native) — not SARIF. Works on private repos with no GitHub Code Security license; SARIF upload would be rejected there.
  • Reusable workflow omits harden-runner (caller context / private-repo telemetry) and uses the immutable actions-ref self-reference pattern.
  • Cache key hashFiles('**/.tflint.hcl') — invalidates on any config change regardless of directory.

Verified

  • Checksum verification passes (caught + fixed a download-name mismatch: tflint.zip vs the checksum's tflint_linux_amd64.zip).
  • tflint compact output matches the problem-matcher regex; --minimum-failure-severity error passes on warning-only findings.

Not included

  • SARIF upload — annotations cover PR review; private repos can't upload third-party SARIF anyway.
  • Real .tf dogfood — none in this repo; the CI job is an install smoke test.

🤖 Generated with Claude Code

Signed-off-by: ms280690 <mehul@sparkgeo.com>
@github-actions

Copy link
Copy Markdown

🤖 Hi @ms280690, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@ms280690 ms280690 linked an issue Jun 23, 2026 that may be closed by this pull request
6 tasks
@ms280690
ms280690 requested a review from Copilot June 23, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class Infrastructure-as-Code linting support to this repo by introducing a pinned, checksum-verified TFLint composite action and a reusable Lint IaC workflow intended for Terraform/OpenTofu repos, plus documentation and a CI smoke-test to dogfood it.

Changes:

  • Add a reusable workflow (lint-iac.yml) that runs TFLint recursively with plugin caching and PR annotations.
  • Add a composite action (.github/actions/tflint) that installs and runs a checksum-verified TFLint binary with a problem matcher.
  • Update docs/README and approved-actions allowlist docs; add an IaC-focused pre-commit example config and CI smoke test.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Documents the new Lint IaC reusable workflow and TFLint composite action usage.
examples/iac.pre-commit-config.yaml Provides a reference pre-commit configuration for Terraform/OpenTofu repos.
docs/approved-actions.md Adds tflint to the approved actions/binaries list with version and verification notes.
.github/workflows/lint-iac.yml Introduces the reusable IaC lint workflow (checkout, cache, run TFLint composite).
.github/workflows/ci.yml Adds a CI smoke-test job to verify the TFLint composite installs and runs.
.github/actions/tflint/tflint-matcher.json Defines a problem matcher for TFLint compact output to produce PR annotations.
.github/actions/tflint/action.yml Implements the TFLint composite action (download+checksum verify, init, lint).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/lint-iac.yml Outdated
Signed-off-by: ms280690 <mehul@sparkgeo.com>
@ms280690
ms280690 requested a review from michaelconnor00 June 23, 2026 19:46

@michaelconnor00 michaelconnor00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. Some questions though:

  • How is this going to interact with terramate?
  • Will it work with OpenTofu? I am guess there will be no issue until they diverge...

@michaelconnor00

Copy link
Copy Markdown
Contributor

Also, please create better PR descriptions. Not even a link to the issue? I have a claude skill for this if you like.

@ms280690

Copy link
Copy Markdown
Collaborator Author

Also, please create better PR descriptions. Not even a link to the issue? I have a claude skill for this if you like.

image the issue is attached to the PR

…enerated-file linting

tflint reads only .tf (not .tofu) and does not understand OpenTofu-only syntax
like the encryption block. tflint --recursive also lints committed
terramate-generated .tf files, which trip rules the team can't hand-fix; the
default error severity floor keeps these Warning-level findings non-blocking.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ms280690
ms280690 merged commit 349a429 into main Jun 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: linting and formatting — infrastructure as code

3 participants