generated from hashicorp/terraform-provider-scaffolding-framework
-
-
Notifications
You must be signed in to change notification settings - Fork 1
297 lines (286 loc) · 10 KB
/
test.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# Terraform Provider testing workflow.
name: Tests
# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
pull_request:
paths-ignore:
- 'README.md'
push:
paths-ignore:
- 'README.md'
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
with:
version: latest
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# Allow goreleaser to access older tag information.
fetch-depth: 0
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
args: check
env:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# Run acceptance tests in a matrix with Terraform CLI versions
test-tofu:
name: Opentofu Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever tofu versions here you would like to support
tofu:
- '1.6.*'
- '1.7.*'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ matrix.tofu }}
tofu_wrapper: false
- name: Setup kind
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config.yaml
- run: go mod download
- env:
TF_ACC: "1"
run: go test -v -cover ./cilium
timeout-minutes: 10
test:
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.5.*'
- '1.6.*'
- '1.7.*'
- '1.8.*'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3.1.1
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: Setup kind
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config.yaml
- run: go mod download
- env:
TF_ACC: "1"
run: go test -v -cover ./cilium
timeout-minutes: 10
test-cluster-mesh:
name: "Functionnal test: Clustermesh"
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever tofu versions here you would like to support
tofu:
- '1.6.*'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ matrix.tofu }}
tofu_wrapper: true
- name: Setup kind test1
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config.yaml
cluster_name: "test1"
- name: Setup kind test2
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config2.yaml
cluster_name: "test2"
- run: make
- run: cp .github/tf/versions.tf .github/tf/clustermesh
- run: tofu init
working-directory: .github/tf/clustermesh
- run: tofu apply -auto-approve
working-directory: .github/tf/clustermesh
- run: tofu destroy -auto-approve
working-directory: .github/tf/clustermesh
test-kubeproxy-free:
name: "Functionnal test: kubeproxy-free"
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever tofu versions here you would like to support
tofu:
- '1.6.*'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ matrix.tofu }}
tofu_wrapper: true
- name: Setup kind test1
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config.yaml
cluster_name: "test1"
- run: make
- run: cp .github/tf/versions.tf .github/tf/kubeproxy-free
- run: tofu init
working-directory: .github/tf/kubeproxy-free
- run: tofu apply -auto-approve
working-directory: .github/tf/kubeproxy-free
- run: kubectl get ds/kube-proxy -n kube-system -o jsonpath='{.status.currentNumberScheduled}' | grep -q 0
- run: tofu destroy -auto-approve
working-directory: .github/tf/kubeproxy-free
test-cilium-install:
name: "Functionnal test: cilium-install"
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever tofu versions here you would like to support
tofu:
- '1.6.*'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ matrix.tofu }}
tofu_wrapper: true
- name: Setup kind test1
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config.yaml
cluster_name: "test1"
- run: make
- run: cp .github/tf/versions.tf .github/tf/cilium/
- run: kubectl create namespace cilium
- run: tofu init
working-directory: .github/tf/cilium
- run: tofu apply -auto-approve
working-directory: .github/tf/cilium
- run: kubectl get pod -n cilium
- run: tofu destroy -auto-approve
working-directory: .github/tf/cilium
- run: kubectl get pod -n cilium
test-content-provider:
name: "Functionnal test: attribute config_content"
runs-on: ubuntu-latest
env:
dir: .github/tf/provider-config-content/
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever tofu versions here you would like to support
tofu:
- '1.6.*'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ matrix.tofu }}
tofu_wrapper: true
- name: Setup kind test1
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
wait: 0
config: .github/config/acceptance_tests_kind_config.yaml
cluster_name: "test1"
- run: make
- run: cp .github/tf/versions.tf $dir
- run: echo "config_content = \"$(cat ${HOME}/.kube/config | base64 -w 0)\"" > $dir/tofu.auto.tfvars
- run: cat $dir/tofu.auto.tfvars
- run: tofu init
working-directory: ${{ env.dir }}
- run: tofu plan
working-directory: ${{ env.dir }}
- run: ls 2>/dev/null -l /tmp/kubeconfig* | wc -l
- run: tofu apply -auto-approve
working-directory: ${{ env.dir }}
- run: ls 2>/dev/null -l /tmp/kubeconfig* | wc -l
- run: tofu destroy -auto-approve
working-directory: ${{ env.dir }}
- run: ls 2>/dev/null -l /tmp/kubeconfig* | wc -l