-
Notifications
You must be signed in to change notification settings - Fork 8
388 lines (385 loc) · 12 KB
/
ci.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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
permissions:
# Permission for checking out code
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- name: Run linters
uses: golangci/golangci-lint-action@v3
with:
args: --verbose
- name: Generate docs
run: go generate
- name: Check generated files
run: |
status=$(git status --porcelain)
if [ -n "$status" ]; then
echo "you need to run 'go generate' and commit the changes"
echo "$status"
exit 1
fi
acceptance:
name: Acceptance Tests (Terraform ${{ matrix.terraform-version }})
runs-on: ubuntu-latest
services:
mysql8prod:
image: mysql:8
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql8dev:
image: mysql:8
env:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: pass
ports:
- 3307:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.5.*'
- '1.6.*'
- '1.7.*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Install Atlas CLI
run: |
curl -sSf https://atlasgo.sh | sh
env:
ATLAS_DEBUG: "true"
ATLAS_FLAVOR: enterprise
- run: go test -v -cover ./...
env:
TF_ACC: '1'
build-dev:
name: Build provider bundles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean --skip=validate,publish,sign
env:
GORELEASER_CURRENT_TAG: v0.0.0-pre.0
- uses: actions/upload-artifact@v3
with:
name: atlas-provider
path: ./dist/terraform-provider-atlas_0.0.0-pre.0_linux_amd64.zip
retention-days: 5
if-no-files-found: error
integration:
name: Integration SQLite (Terraform ${{ matrix.terraform-version }})
runs-on: ubuntu-latest
needs: [build-dev]
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.5.*'
- '1.6.*'
- '1.7.*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/download-artifact@v3
with:
name: atlas-provider
path: ./dist
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Install Atlas CLI
run: |
curl -sSf https://atlasgo.sh | sh
env:
ATLAS_DEBUG: "true"
ATLAS_FLAVOR: enterprise
- name: Terraform (sqlite)
working-directory: integration-tests/sqlite
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init
echo "Apply terraform plan"
terraform apply -no-color --auto-approve > stdout.txt
cat stdout.txt | grep --silent "Apply complete! Resources: 1 added, 0 changed, 0 destroyed."
echo "Ensure that there is no diff"
terraform plan -no-color > stdout.txt
cat stdout.txt | grep --silent "No changes. Your infrastructure matches the configuration."
- name: Terraform (no-dev-url)
working-directory: integration-tests/no-dev-url
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init > /dev/null
terraform plan -no-color | grep --silent "Warning: dev_url is unset"
- name: Terraform (no-version)
working-directory: integration-tests/no-version
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init > /dev/null
terraform plan -no-color | grep --silent "Warning: version is unset"
- name: Terraform (remote_dir)
working-directory: integration-tests/remote-dir
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init > /dev/null
terraform plan -no-color > stdout.txt
cat stdout.txt | grep --silent "Plan: 1 to add, 0 to change, 0 to destroy."
! cat stdout.txt | grep --silent "Warning: dev_url is unset"
! cat stdout.txt | grep --silent "Warning: version is unset"
env:
TF_VAR_atlas_token: ${{ secrets.ATLAS_TOKEN }}
integration-mysql:
name: Integration MySQL (Terraform ${{ matrix.terraform-version }})
runs-on: ubuntu-latest
needs: [build-dev]
services:
mysql8prod:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: pass
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
mysql8dev:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: pass
ports:
- 3307:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.5.*'
- '1.6.*'
- '1.7.*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/download-artifact@v3
with:
name: atlas-provider
path: ./dist
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Install Atlas CLI
run: |
curl -sSf https://atlasgo.sh | sh
env:
ATLAS_DEBUG: "true"
ATLAS_FLAVOR: enterprise
- name: Terraform (skip-policy)
working-directory: integration-tests/skip-policy
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init > /dev/null
terraform apply --auto-approve
terraform plan -no-color -var schema="schema-t2" > stdout.txt
cat stdout.txt | grep --silent "Plan: 0 to add, 1 to change, 0 to destroy."
cat stdout.txt | grep --silent "DROP TABLE \`test\`.\`t2\`"
terraform plan -no-color -var schema="schema-t2" \
-var "skip_drop_table=true" > stdout.txt
cat stdout.txt | grep --silent "Plan: 0 to add, 1 to change, 0 to destroy."
# Expect no drop table statement in the plan
! cat stdout.txt | grep --silent "DROP TABLE \`test\`.\`t2\`"
terraform apply --auto-approve -no-color -var="schema=schema-t2" -var="skip_drop_table=true"
# Confirm that the table was not dropped
atlas schema inspect \
-u "mysql://root:pass@localhost:3306/" > actual.hcl
cmp -s "expected.hcl" "actual.hcl"
integration-postgres:
name: Integration PostgreSQL (Terraform ${{ matrix.terraform-version }})
runs-on: ubuntu-latest
needs: [build-dev]
services:
postgres15:
image: postgres:15
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres15-dev:
image: postgres:15
env:
POSTGRES_DB: test
POSTGRES_PASSWORD: pass
ports:
- 5433:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.5.*'
- '1.6.*'
- '1.7.*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/download-artifact@v3
with:
name: atlas-provider
path: ./dist
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Install Atlas CLI
run: |
curl -sSf https://atlasgo.sh | sh
env:
ATLAS_DEBUG: "true"
ATLAS_FLAVOR: enterprise
- name: Terraform (concurrent_index-policy)
working-directory: integration-tests/concurrent_index-policy
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init > /dev/null
terraform apply --auto-approve
terraform apply --auto-approve -var="schema=schema-2.hcl"
integration-sqlserver:
name: Integration SQL Server (Terraform ${{ matrix.terraform-version }})
runs-on: ubuntu-latest
needs: [build-dev]
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
MSSQL_PID: Developer
MSSQL_SA_PASSWORD: P@ssw0rd0995
ports:
- 1433:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -U sa -P \"${MSSQL_SA_PASSWORD}\" -Q \"SELECT 1\""
--health-interval 10s
--health-timeout 5s
--health-retries 5
sqlserver-dev:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: Y
MSSQL_PID: Developer
MSSQL_SA_PASSWORD: P@ssw0rd0995
ports:
- 1434:1433
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -U sa -P \"${MSSQL_SA_PASSWORD}\" -Q \"SELECT 1\""
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.5.*'
- '1.6.*'
- '1.7.*'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: './go.mod'
- uses: actions/download-artifact@v3
with:
name: atlas-provider
path: ./dist
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform-version }}
terraform_wrapper: false
- name: Install Atlas CLI
run: |
curl -sSf https://atlasgo.sh | sh
env:
ATLAS_DEBUG: "true"
ATLAS_FLAVOR: enterprise
- name: Terraform (login-feature)
working-directory: integration-tests/login-feature
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init > /dev/null
terraform apply --auto-approve
env:
ATLAS_TOKEN: ${{ secrets.ATLAS_TOKEN }}