-
Notifications
You must be signed in to change notification settings - Fork 8
215 lines (185 loc) · 6.74 KB
/
tests.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
# 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:
push:
branches: [ main ]
paths-ignore:
- 'README.md'
- '.gitignore'
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
paths-ignore:
- 'README.md'
- '.gitignore'
# Testing only needs permissions to read the repository contents.
permissions:
contents: read
# Default values to simplify job configurations below.
env:
# Go language version to use for building. This value should also be updated
# in the release workflow if changed.
GO_VERSION: 1.23
TASK_VERSION: 3.x
jobs:
# Setup matrix for current branch.
# If we are on main, run tests with all terraform version
# Otherwise, run tests only on latest
matrix_prep:
name: Prepare Test Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Branch name
uses: nelonoel/[email protected]
- name: Conditional build matrix
id: set-matrix
uses: JoshuaTheMiller/[email protected]
with:
# The simple branch name can be used in the filter now!
filter: '[?runOnBranch==`${{ env.BRANCH_NAME }}` || runOnBranch==`always`]'
# Ensure project builds before running testing matrix
build:
name: Build Terraform Provider
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Task
uses: arduino/setup-task@v1
with:
version: ${{ env.TASK_VERSION }}
- name: Check out source code
uses: actions/checkout@v3
- name: Build
run: task build
lint:
name: Lint Terraform Provider
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Task
uses: arduino/setup-task@v1
with:
version: ${{ env.TASK_VERSION }}
- name: Check out source code
uses: actions/checkout@v3
- name: Lint
run: task lint
generate:
name: Generate Documentation
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: Set up Task
uses: arduino/setup-task@v1
with:
version: ${{ env.TASK_VERSION }}
- name: Check out source code
uses: actions/checkout@v3
- name: Generate documentation
env:
QOVERY_API_TOKEN: ${{ secrets.QOVERY_API_TOKEN }}
run: task docs
- name: Check git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'task docs' command and commit."; exit 1)
mocks:
name: Generate Mocks
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Task
uses: arduino/setup-task@v1
with:
version: ${{ env.TASK_VERSION }}
- name: Check out source code
uses: actions/checkout@v3
- name: Generate mocks
run: task mocks
- name: Check git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'task mocks' command and commit."; exit 1)
# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Terraform Provider Acceptance Tests
needs:
- matrix_prep
- build
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
max-parallel: 1
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: Set up Task
uses: arduino/setup-task@v1
with:
version: ${{ env.TASK_VERSION }}
- name: Check out source code
uses: actions/checkout@v3
- name: Run acceptance tests
timeout-minutes: 120
env:
TF_ACC: "1"
QOVERY_API_TOKEN: ${{ secrets.QOVERY_API_TOKEN }}
TEST_ORGANIZATION_ID: ${{ secrets.TEST_ORGANIZATION_ID }}
TEST_AWS_CREDENTIALS_ID: ${{ secrets.TEST_AWS_CREDENTIALS_ID }}
TEST_AWS_CREDENTIALS_ACCESS_KEY_ID: ${{ secrets.TEST_AWS_CREDENTIALS_ACCESS_KEY_ID }}
TEST_AWS_CREDENTIALS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_CREDENTIALS_SECRET_ACCESS_KEY }}
TEST_SCALEWAY_CREDENTIALS_ID: ${{ secrets.TEST_SCALEWAY_CREDENTIALS_ID }}
TEST_SCALEWAY_CREDENTIALS_PROJECT_ID: ${{ secrets.TEST_SCALEWAY_CREDENTIALS_PROJECT_ID }}
TEST_SCALEWAY_CREDENTIALS_ORGANIZATION_ID: ${{ secrets.TEST_SCALEWAY_CREDENTIALS_ORGANIZATION_ID }}
TEST_SCALEWAY_CREDENTIALS_ACCESS_KEY: ${{ secrets.TEST_SCALEWAY_CREDENTIALS_ACCESS_KEY }}
TEST_SCALEWAY_CREDENTIALS_SECRET_KEY: ${{ secrets.TEST_SCALEWAY_CREDENTIALS_SECRET_KEY }}
TEST_CLUSTER_ID: ${{ secrets.TEST_CLUSTER_ID }}
TEST_PROJECT_ID: ${{ secrets.TEST_PROJECT_ID }}
TEST_ENVIRONMENT_ID: ${{ secrets.TEST_ENVIRONMENT_ID }}
TEST_APPLICATION_ID: ${{ secrets.TEST_APPLICATION_ID }}
TEST_DATABASE_ID: ${{ secrets.TEST_DATABASE_ID }}
TEST_CONTAINER_REGISTRY_ID: ${{ secrets.TEST_CONTAINER_REGISTRY_ID }}
TEST_CONTAINER_ID: ${{ secrets.TEST_CONTAINER_ID }}
TEST_JOB_ID: ${{ secrets.TEST_JOB_ID }}
TEST_HELM_ID: ${{ secrets.TEST_HELM_ID }}
TEST_HELM_REPOSITORY_ID: ${{ secrets.TEST_HELM_REPOSITORY_ID }}
TEST_AWS_ECR_URL: ${{ secrets.TEST_AWS_ECR_URL }}
TEST_QOVERY_HOST: ${{ secrets.TEST_QOVERY_HOST }}
TEST_QOVERY_SANDBOX_GIT_TOKEN_ID: ${{ secrets.TEST_QOVERY_SANDBOX_GIT_TOKEN_ID }}
TEST_ANNOTATIONS_GROUP_ID: ${{ secrets.TEST_ANNOTATIONS_GROUP_ID }}
TEST_LABELS_GROUP_ID: ${{ secrets.TEST_LABELS_GROUP_ID }}
run: task testacc