Skip to content

Commit eb2f1dd

Browse files
committed
ci: improve tf testing
1 parent a661719 commit eb2f1dd

1 file changed

Lines changed: 61 additions & 11 deletions

File tree

.github/workflows/test.yml

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,70 @@ name: test
22

33
on:
44
pull_request:
5-
branches:
6-
- main
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
env:
14+
TF_IN_AUTOMATION: true
715

816
jobs:
9-
test:
17+
lint:
18+
name: lint
1019
runs-on: ubuntu-latest
20+
1121
steps:
12-
- name: Checkout Code
13-
uses: actions/checkout@v3
14-
- name: Terraform Setup
15-
run: |
16-
terraform init
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: setup terraform
26+
uses: hashicorp/setup-terraform@v3
27+
28+
- name: Cache Terraform Plugins
29+
uses: actions/cache@v4
30+
with:
31+
path: ${{ runner.temp }}/.terraform.d/plugin-cache
32+
key: tf-plugins-${{ runner.os }}-${{ hashFiles('**/.terraform.lock.hcl') }}
33+
34+
- name: Initialize Terraform
35+
run: terraform init
36+
37+
- name: Suggest Terraform Format
38+
if: github.event_name == 'pull_request'
39+
uses: reviewdog/action-suggester@v1
40+
with:
41+
tool_name: terraform-fmt
42+
level: warning
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
fail_level: error
45+
46+
- name: Check Terraform Format
47+
if: github.event_name == 'push'
48+
run: terraform fmt -recursive -check
49+
50+
- name: Validate Terraform
51+
uses: reviewdog/action-terraform-validate@v1
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
reporter: github-pr-review
55+
level: warning
56+
fail_level: error
57+
1758
- name: Lint Terraform
18-
uses: reviewdog/action-tflint@master
59+
uses: reviewdog/action-tflint@v1
60+
with:
61+
reporter: github-pr-review
62+
filter_mode: nofilter
63+
fail_level: error
64+
65+
- name: Lint GitHub Actions
66+
uses: reviewdog/action-actionlint@v1
1967
with:
20-
github_token: ${{ secrets.github_token }}
21-
filter_mode: "nofilter"
68+
reporter: github-pr-check
69+
fail_level: error
70+
filter_mode: nofilter
71+

0 commit comments

Comments
 (0)