-
Notifications
You must be signed in to change notification settings - Fork 627
182 lines (178 loc) · 6.72 KB
/
terraform.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: "Terraform checks"
on:
push:
branches:
- main
pull_request:
paths: ["**/*.tf", "**/*.hcl", ".github/workflows/terraform.yml"]
permissions:
contents: read
pull-requests: write
env:
AWS_REGION: eu-west-1
jobs:
verify_module:
name: Verify module
strategy:
matrix:
terraform: [1.5.6, "latest"]
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:${{ matrix.terraform }}
steps:
- name: "Checkout"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: "Fake zip files" # Validate will fail if it cannot find the zip files
run: |
touch lambdas/functions/webhook/webhook.zip
touch lambdas/functions/control-plane/runners.zip
touch lambdas/functions/gh-agent-syncer/runner-binaries-syncer.zip
touch lambdas/functions/ami-housekeeper/ami-housekeeper.zip
touch lambdas/functions/termination-watcher/termination-watcher.zip
- name: terraform init
run: terraform init -get -backend=false -input=false
- if: contains(matrix.terraform, '1.5.')
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
- if: contains(matrix.terraform, 'latest') # check formatting for the latest release but avoid failing the build
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
continue-on-error: true
- name: validate terraform
run: terraform validate
- if: contains(matrix.terraform, '1.5.')
name: Fix for actions/cache on alpine
run: apk add --no-cache tar
continue-on-error: true
- if: contains(matrix.terraform, '1.5.')
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1
name: Cache TFLint plugin dir
with:
path: ~/.tflint.d/plugins
key: tflint-${{ hashFiles('.tflint.hcl') }}
- if: contains(matrix.terraform, '1.5.')
name: Setup TFLint
uses: terraform-linters/setup-tflint@19a52fbac37dacb22a09518e4ef6ee234f2d4987 # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- if: contains(matrix.terraform, '1.5.')
name: Run TFLint
run: |
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl
tflint -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars
verify_modules:
name: Verify modules
strategy:
fail-fast: false
matrix:
terraform: [1.5.6, "latest"]
module:
[
"ami-housekeeper",
"download-lambda",
"lambda",
"multi-runner",
"runner-binaries-syncer",
"runners",
"setup-iam-permissions",
"ssm",
"termination-watcher",
"webhook",
]
defaults:
run:
working-directory: modules/${{ matrix.module }}
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:${{ matrix.terraform }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: terraform init
run: terraform init -get -backend=false -input=false
- if: contains(matrix.terraform, '1.3.')
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
- if: contains(matrix.terraform, 'latest') # check formatting for the latest release but avoid failing the build
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
continue-on-error: true
- name: validate terraform
run: terraform validate
- if: contains(matrix.terraform, '1.3.')
name: Fix for actions/cache on alpine
run: apk add --no-cache tar
continue-on-error: true
- if: contains(matrix.terraform, '1.3.')
uses: actions/cache@v4
name: Cache TFLint plugin dir
with:
path: ~/.tflint.d/plugins
key: tflint-${{ hashFiles('.tflint.hcl') }}
- if: contains(matrix.terraform, '1.3.')
name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- if: contains(matrix.terraform, '1.3.')
name: Run TFLint
working-directory: ${{ github.workspace }}
run: |
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl --chdir modules/${{ matrix.module }}
tflint -f compact -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars --chdir modules/${{ matrix.module }}
verify_examples:
name: Verify examples
strategy:
fail-fast: false
matrix:
terraform: [1.5.6, "latest"]
example:
[
"default",
"ubuntu",
"prebuilt",
"arm64",
"ephemeral",
"termination-watcher",
"windows",
"multi-runner",
]
defaults:
run:
working-directory: examples/${{ matrix.example }}
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:${{ matrix.terraform }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: terraform init
run: terraform init -get -backend=false -input=false
- if: contains(matrix.terraform, '1.5.')
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
- if: contains(matrix.terraform, 'latest') # check formatting for the latest release but avoid failing the build
name: check terraform formatting
run: terraform fmt -recursive -check=true -write=false
continue-on-error: true
- name: validate terraform
run: terraform validate
- if: contains(matrix.terraform, '1.5.')
name: Fix for actions/cache on alpine
run: apk add --no-cache tar
continue-on-error: true
- if: contains(matrix.terraform, '1.5.')
uses: actions/cache@v4
name: Cache TFLint plugin dir
with:
path: ~/.tflint.d/plugins
key: tflint-${{ hashFiles('.tflint.hcl') }}
- if: contains(matrix.terraform, '1.5.')
name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- if: contains(matrix.terraform, '1.5.')
name: Run TFLint
working-directory: ${{ github.workspace }}
run: |
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl --chdir modules/${{ matrix.module }}
tflint -f compact -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars --chdir examples/${{ matrix.example }}