Skip to content

Commit

Permalink
fix: Simplify pre-commit CI workflow to work with cSpell excludes
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs committed Feb 5, 2024
1 parent b805240 commit b6984f8
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pre-commit
name: Pre-commit

on:
pull_request:
Expand All @@ -10,41 +10,19 @@ on:
- '**.yaml'

env:
TERRAFORM_VERSION: 1.3.10
TERRAFORM_DOCS_VERSION: v0.16.0
TFSEC_VERSION: v1.22.0
TF_PLUGIN_CACHE_DIR: ${{ github.workspace }}/.terraform.d/plugin-cache
TFLINT_VERSION: v0.42.1
TFLINT_VERSION: v0.50.2

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
collectInputs:
name: Collect workflow inputs
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.dirs.outputs.directories }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/[email protected]

preCommitMinVersions:
pre-commit:
name: Min TF pre-commit
needs: collectInputs
runs-on: ubuntu-latest
strategy:
matrix:
directory: ${{ fromJson(needs.collectInputs.outputs.directories) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
Expand All @@ -62,7 +40,7 @@ jobs:
with:
filters: |
src:
- '${{ matrix.directory }}/*.tf'
- '*.tf'
- name: Config Terraform plugin cache
if: steps.changes.outputs.src== 'true'
Expand All @@ -76,18 +54,10 @@ jobs:
key: ${{ runner.os }}-terraform-${{ hashFiles('**/.terraform.lock.hcl') }}
restore-keys: ${{ runner.os }}-terraform-

- name: Terraform min/max versions
uses: clowdhaus/[email protected]
if: steps.changes.outputs.src== 'true'
id: minMax
with:
directory: ${{ matrix.directory }}

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
uses: clowdhaus/terraform-composite-actions/[email protected]
if: steps.changes.outputs.src== 'true'
with:
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
terraform-version: ${{ env.TERRAFORM_VERSION }}
terraform-docs-version: ${{ env.TERRAFORM_DOCS_VERSION }}
tflint-version: ${{ env.TFLINT_VERSION }}
args: '--files ${{ matrix.directory }}/*'

0 comments on commit b6984f8

Please sign in to comment.