Skip to content

Commit 86b3bac

Browse files
Download Terraform CLI outside of tests (#635)
This should fix this kind of random failures: https://drone.grafana.net/grafana/terraform-provider-grafana/1608/5/3 `cannot run Terraform provider tests: failed to find or install Terraform CLI from [0xc002db6640 0xc001106480]: Unknown status: 502`
1 parent e99ee1f commit 86b3bac

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

.drone/drone.jsonnet

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ local images = {
33
go: 'golang:1.18',
44
python: 'python:3.9-alpine',
55
lint: 'golangci/golangci-lint:v1.49',
6+
terraform: 'hashicorp/terraform',
67
grafana(version): 'grafana/grafana:' + version,
78
};
89

10+
local terraformPath = '/drone/terraform-provider-grafana/terraform';
11+
local installTerraformStep = {
12+
name: 'download-terraform',
13+
image: images.terraform,
14+
commands: [
15+
'cp /bin/terraform ' + terraformPath,
16+
'chmod a+x ' + terraformPath,
17+
],
18+
};
19+
920
local secret(name, vaultPath, vaultKey) = {
1021
kind: 'secret',
1122
name: name,
@@ -84,19 +95,24 @@ local pipeline(name, steps, services=[]) = {
8495
pipeline(
8596
'unit tests',
8697
steps=[
98+
installTerraformStep,
8799
{
88100
name: 'tests',
89101
image: images.go,
90102
commands: [
91103
'go test ./...',
92104
],
105+
environment: {
106+
TF_ACC_TERRAFORM_PATH: terraformPath,
107+
},
93108
},
94109
]
95110
),
96111

97112
pipeline(
98113
'cloud api tests',
99114
steps=[
115+
installTerraformStep,
100116
{
101117
name: 'tests',
102118
image: images.go,
@@ -106,6 +122,7 @@ local pipeline(name, steps, services=[]) = {
106122
environment: {
107123
GRAFANA_CLOUD_API_KEY: cloudApiKey.fromSecret,
108124
GRAFANA_CLOUD_ORG: 'terraformprovidergrafana',
125+
TF_ACC_TERRAFORM_PATH: terraformPath,
109126
},
110127
},
111128
]
@@ -117,6 +134,7 @@ local pipeline(name, steps, services=[]) = {
117134
pipeline(
118135
'cloud instance tests',
119136
steps=[
137+
installTerraformStep,
120138
{
121139
name: 'wait for instance',
122140
image: images.go,
@@ -132,6 +150,7 @@ local pipeline(name, steps, services=[]) = {
132150
GRAFANA_SM_ACCESS_TOKEN: smToken.fromSecret,
133151
GRAFANA_ORG_ID: 1,
134152
GRAFANA_ONCALL_ACCESS_TOKEN: onCallToken.fromSecret,
153+
TF_ACC_TERRAFORM_PATH: terraformPath,
135154
},
136155
},
137156
]
@@ -148,6 +167,7 @@ local pipeline(name, steps, services=[]) = {
148167
pipeline(
149168
'oss tests: %s' % version,
150169
steps=[
170+
installTerraformStep,
151171
{
152172
name: 'tests',
153173
image: images.go,
@@ -160,6 +180,7 @@ local pipeline(name, steps, services=[]) = {
160180
GRAFANA_AUTH: 'admin:admin',
161181
GRAFANA_VERSION: version,
162182
GRAFANA_ORG_ID: 1,
183+
TF_ACC_TERRAFORM_PATH: terraformPath,
163184
},
164185
},
165186
],

.drone/drone.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,15 @@ platform:
6161
os: linux
6262
services: []
6363
steps:
64+
- commands:
65+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
66+
- chmod a+x /drone/terraform-provider-grafana/terraform
67+
image: hashicorp/terraform
68+
name: download-terraform
6469
- commands:
6570
- go test ./...
71+
environment:
72+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
6673
image: golang:1.18
6774
name: tests
6875
trigger:
@@ -84,12 +91,18 @@ platform:
8491
os: linux
8592
services: []
8693
steps:
94+
- commands:
95+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
96+
- chmod a+x /drone/terraform-provider-grafana/terraform
97+
image: hashicorp/terraform
98+
name: download-terraform
8799
- commands:
88100
- make testacc-cloud-api
89101
environment:
90102
GRAFANA_CLOUD_API_KEY:
91103
from_secret: grafana-cloud-api-key
92104
GRAFANA_CLOUD_ORG: terraformprovidergrafana
105+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
93106
image: golang:1.18
94107
name: tests
95108
trigger:
@@ -111,6 +124,11 @@ platform:
111124
os: linux
112125
services: []
113126
steps:
127+
- commands:
128+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
129+
- chmod a+x /drone/terraform-provider-grafana/terraform
130+
image: hashicorp/terraform
131+
name: download-terraform
114132
- commands:
115133
- .drone/wait-for-instance.sh https://terraformprovidergrafana.grafana.net/
116134
image: golang:1.18
@@ -126,6 +144,7 @@ steps:
126144
GRAFANA_SM_ACCESS_TOKEN:
127145
from_secret: grafana-sm-token
128146
GRAFANA_URL: https://terraformprovidergrafana.grafana.net/
147+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
129148
image: golang:1.18
130149
name: tests
131150
trigger:
@@ -173,6 +192,11 @@ services:
173192
image: grafana/grafana:9.1.0
174193
name: grafana
175194
steps:
195+
- commands:
196+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
197+
- chmod a+x /drone/terraform-provider-grafana/terraform
198+
image: hashicorp/terraform
199+
name: download-terraform
176200
- commands:
177201
- sleep 5
178202
- make testacc-oss
@@ -181,6 +205,7 @@ steps:
181205
GRAFANA_ORG_ID: 1
182206
GRAFANA_URL: http://grafana:3000
183207
GRAFANA_VERSION: 9.1.0
208+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
184209
image: golang:1.18
185210
name: tests
186211
trigger:
@@ -204,6 +229,11 @@ services:
204229
image: grafana/grafana:9.0.7
205230
name: grafana
206231
steps:
232+
- commands:
233+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
234+
- chmod a+x /drone/terraform-provider-grafana/terraform
235+
image: hashicorp/terraform
236+
name: download-terraform
207237
- commands:
208238
- sleep 5
209239
- make testacc-oss
@@ -212,6 +242,7 @@ steps:
212242
GRAFANA_ORG_ID: 1
213243
GRAFANA_URL: http://grafana:3000
214244
GRAFANA_VERSION: 9.0.7
245+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
215246
image: golang:1.18
216247
name: tests
217248
trigger:
@@ -235,6 +266,11 @@ services:
235266
image: grafana/grafana:8.5.5
236267
name: grafana
237268
steps:
269+
- commands:
270+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
271+
- chmod a+x /drone/terraform-provider-grafana/terraform
272+
image: hashicorp/terraform
273+
name: download-terraform
238274
- commands:
239275
- sleep 5
240276
- make testacc-oss
@@ -243,6 +279,7 @@ steps:
243279
GRAFANA_ORG_ID: 1
244280
GRAFANA_URL: http://grafana:3000
245281
GRAFANA_VERSION: 8.5.5
282+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
246283
image: golang:1.18
247284
name: tests
248285
trigger:
@@ -266,6 +303,11 @@ services:
266303
image: grafana/grafana:8.4.7
267304
name: grafana
268305
steps:
306+
- commands:
307+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
308+
- chmod a+x /drone/terraform-provider-grafana/terraform
309+
image: hashicorp/terraform
310+
name: download-terraform
269311
- commands:
270312
- sleep 5
271313
- make testacc-oss
@@ -274,6 +316,7 @@ steps:
274316
GRAFANA_ORG_ID: 1
275317
GRAFANA_URL: http://grafana:3000
276318
GRAFANA_VERSION: 8.4.7
319+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
277320
image: golang:1.18
278321
name: tests
279322
trigger:
@@ -297,6 +340,11 @@ services:
297340
image: grafana/grafana:8.3.7
298341
name: grafana
299342
steps:
343+
- commands:
344+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
345+
- chmod a+x /drone/terraform-provider-grafana/terraform
346+
image: hashicorp/terraform
347+
name: download-terraform
300348
- commands:
301349
- sleep 5
302350
- make testacc-oss
@@ -305,6 +353,7 @@ steps:
305353
GRAFANA_ORG_ID: 1
306354
GRAFANA_URL: http://grafana:3000
307355
GRAFANA_VERSION: 8.3.7
356+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
308357
image: golang:1.18
309358
name: tests
310359
trigger:
@@ -328,6 +377,11 @@ services:
328377
image: grafana/grafana:7.5.15
329378
name: grafana
330379
steps:
380+
- commands:
381+
- cp /bin/terraform /drone/terraform-provider-grafana/terraform
382+
- chmod a+x /drone/terraform-provider-grafana/terraform
383+
image: hashicorp/terraform
384+
name: download-terraform
331385
- commands:
332386
- sleep 5
333387
- make testacc-oss
@@ -336,6 +390,7 @@ steps:
336390
GRAFANA_ORG_ID: 1
337391
GRAFANA_URL: http://grafana:3000
338392
GRAFANA_VERSION: 7.5.15
393+
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
339394
image: golang:1.18
340395
name: tests
341396
trigger:
@@ -349,6 +404,6 @@ workspace:
349404
path: /drone/terraform-provider-grafana
350405
---
351406
kind: signature
352-
hmac: 5305c32d78ea4fd8751e54de562674e698f9b4d415934d03568881933a7921f9
407+
hmac: 8c44f9980e078778581b1c708a316480b4d6636cb4389b091c057f94ed3afaa7
353408

354409
...

0 commit comments

Comments
 (0)