Skip to content

Commit

Permalink
add code formatting and linting checks
Browse files Browse the repository at this point in the history
  • Loading branch information
strebitz committed Aug 30, 2024
1 parent c438559 commit 4d31a35
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/terraform-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ on:
- main

jobs:
formatting:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Check Terraform code is formatted
uses: docker://hashicorp/terraform:latest
with:
entrypoint: terraform
args: fmt -check -diff -recursive

validate:
name: Validate
runs-on: ubuntu-latest
Expand All @@ -25,3 +38,31 @@ jobs:
with:
entrypoint: terraform
args: validate

tflint:
name: TFLint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v4
name: Checkout source code

- uses: actions/cache@v4
name: Cache plugin dir
with:
path: ~/.tflint.d/plugins
key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }}

- uses: terraform-linters/setup-tflint@v4
name: Setup TFLint

- name: Init TFLint
run: tflint --init
env:
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
GITHUB_TOKEN: ${{ github.token }}

- name: Run TFLint
run: tflint -f compact
4 changes: 4 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}

0 comments on commit 4d31a35

Please sign in to comment.