Skip to content

Simplify CI by skipping terraform_docs - rely on local pre-commit #51

@lgallard

Description

@lgallard

Summary

Simplify the CI pipeline by skipping terraform_docs in GitHub Actions and relying on local pre-commit hooks for documentation generation.

Problem

The terraform_docs hook in CI causes frequent failures due to:

  • Environment parity issues: macOS (local) vs Linux (CI) produce different outputs
  • Version mismatches: Different terraform-docs versions between local and CI environments
  • Unnecessary CI complexity: Installing and maintaining terraform-docs in CI adds overhead
  • Blocking releases: Documentation generation differences block merges and releases

Proposed Solution

Implement the same approach successfully deployed in terraform-aws-ecrpublic:

CI Workflow Changes

  1. Add SKIP: terraform_docs environment variable to pre-commit step
  2. Remove terraform-docs installation from CI
  3. Remove .md files from paths filter (docs changes don't need CI validation)
  4. Update cache key to bust stale caches

Strategy

Layer Checks
CI terraform_fmt, terraform_validate, tflint, file formatting
Local Full pre-commit including terraform_docs
AI Review Documentation accuracy and quality gate

Benefits

  • Faster CI: No terraform-docs installation or execution
  • Fewer false failures: Eliminates environment parity issues
  • Focus on shipping: Developers can focus on features and fixes
  • Maintained quality: Local pre-commit ensures docs are updated before commit

Implementation

# In pre-commit workflow
- name: Run pre-commit checks
  env:
    SKIP: terraform_docs
  run: |
    pre-commit run --all-files

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions