Skip to content

Commit 32ca163

Browse files
committed
add github actions to lint dashboards
1 parent 31f8f47 commit 32ca163

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Automatic CI for TFE Modules
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
jobs:
13+
terraform_format:
14+
15+
name: Run terraform fmt
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
persist-credentials: false
25+
26+
- name: Setup Terraform
27+
uses: hashicorp/setup-terraform@v1
28+
with:
29+
terraform_version: 1.0.11
30+
31+
- name: Format all .tf files recursively
32+
run: |
33+
terraform fmt -check -diff -recursive ${{ github.workspace }}
34+
terraform_lint:
35+
36+
name: Run terraform-lint
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: read
40+
41+
steps:
42+
- uses: actions/checkout@v2
43+
with:
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
persist-credentials: false
46+
47+
- name: Setup Terraform Lint
48+
uses: terraform-linters/setup-tflint@v1
49+
with:
50+
tflint_version: v0.34.1
51+
52+
- name: Terraform Init
53+
id: init
54+
run: |
55+
terraform init
56+
57+
- name: Lint root module
58+
run: |
59+
tflint --config ${{ github.workspace }}/.tflint.hcl ${{ github.workspace }}
60+
- name: Lint collector-dashboards directory in a loop
61+
run: |
62+
for m in $(ls -1d collector-dashboards/*/)
63+
do
64+
tflint \
65+
--config ${{ github.workspace }}/.tflint.hcl \
66+
${{ github.workspace }}/${m}
67+
done
68+
- name: Lint examples directory in a loop
69+
run: |
70+
for m in $(ls -1d examples/*/)
71+
do
72+
tflint \
73+
--config ${{ github.workspace }}/.tflint.hcl \
74+
${{ github.workspace }}/${m}
75+
done

.tflint.hcl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
config {
2+
module = true
3+
}
4+
5+
rule "terraform_deprecated_index" {
6+
enabled = true
7+
}
8+
9+
rule "terraform_unused_declarations" {
10+
enabled = true
11+
}
12+
13+
rule "terraform_comment_syntax" {
14+
enabled = true
15+
}
16+
17+
rule "terraform_documented_outputs" {
18+
enabled = true
19+
}
20+
21+
rule "terraform_documented_variables" {
22+
enabled = true
23+
}
24+
25+
rule "terraform_typed_variables" {
26+
enabled = true
27+
}
28+
29+
rule "terraform_naming_convention" {
30+
enabled = true
31+
}
32+
33+
rule "terraform_required_version" {
34+
enabled = true
35+
}
36+
37+
rule "terraform_required_providers" {
38+
enabled = true
39+
}
40+
41+
rule "terraform_unused_required_providers" {
42+
enabled = true
43+
}
44+
45+
rule "terraform_standard_module_structure" {
46+
enabled = true
47+
}

0 commit comments

Comments
 (0)