Skip to content

Commit 23f9b13

Browse files
authored
Merge pull request #3866 from alphagov/samsimpson1/tfvars-lint
Lint tfvars files
2 parents d051c1b + 2d83aac commit 23f9b13

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

.github/workflows/ci-terraform.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,19 @@ jobs:
2929
- name: Determine Terraform version to use
3030
uses: dflook/terraform-version@8ee89d962417ed259f9d75e7529e262637c7e5a8
3131
id: terraform-version
32-
if: steps.changed-deployments.outputs.any_changed == 'true'
3332
with:
3433
path: terraform
3534

3635
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
37-
if: steps.changed-deployments.outputs.any_changed == 'true'
3836
with:
3937
terraform_version: ${{ steps.terraform-version.outputs.terraform }}
4038
terraform_wrapper: false
4139

4240
- name: Create Terraform plugin cache dir
4341
run: mkdir -p "$TF_PLUGIN_CACHE_DIR"
44-
if: steps.changed-deployments.outputs.any_changed == 'true'
4542

4643
- name: Cache Terraform plugins
4744
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
48-
if: steps.changed-deployments.outputs.any_changed == 'true'
4945
with:
5046
path: ${{ env.TF_PLUGIN_CACHE_DIR }}
5147
key:
@@ -64,7 +60,7 @@ jobs:
6460
with:
6561
tflint_version: v0.55.0
6662

67-
- name: terraform fmt
63+
- name: terraform fmt roots
6864
working-directory: terraform/deployments
6965
env:
7066
DEPLOYMENTS: ${{ steps.changed-deployments.outputs.all_changed_files }}
@@ -80,6 +76,15 @@ jobs:
8076
cd "$OLDPWD"
8177
done
8278
79+
- name: terraform fmt variables
80+
working-directory: terraform/variables
81+
run: |
82+
if ! terraform fmt -recursive -check -diff -list=true .; then
83+
>&2 echo "Some tfvars files weren't formatted correctly. Run 'terraform fmt' to fix them."
84+
exit 1
85+
fi
86+
echo "Variables ok"
87+
8388
- name: terraform init
8489
working-directory: terraform/deployments
8590
env:

0 commit comments

Comments
 (0)