-
Notifications
You must be signed in to change notification settings - Fork 8
176 lines (174 loc) · 5.26 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
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@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21'
- 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.2.*'
- '1.3.*'
- '1.4.*'
- '1.5.*'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21'
- 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 -s -A "Terraform-Provider-CI" -o /usr/local/bin/atlas \
https://release.ariga.io/atlas/atlas-linux-amd64-latest?test=1
chmod +x /usr/local/bin/atlas
- run: go test -v -cover ./...
env:
TF_ACC: '1'
build-dev:
name: Build provider bundles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21'
- 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/[email protected]
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 (Terraform ${{ matrix.terraform-version }})
runs-on: ubuntu-latest
needs: [build-dev]
strategy:
fail-fast: false
matrix:
terraform-version:
- '1.2.*'
- '1.3.*'
- '1.4.*'
- '1.5.*'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.21'
- 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: Terraform (sqlite)
working-directory: integration-tests/sqlite
run: |
../../scripts/local.sh ../../dist 0.0.0-pre.0
terraform init
terraform apply --auto-approve
- 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 }}