-
Notifications
You must be signed in to change notification settings - Fork 236
/
circleci_config.feature
321 lines (287 loc) · 8.5 KB
/
circleci_config.feature
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
# Aruba reference
# https://gist.github.com/bdunn313/4199906
Feature: Config checking
Scenario: Checking a valid config file
Given a file named "config.yml" with:
"""
jobs:
build:
machine: true
steps: [checkout]
"""
When I run `circleci config validate --skip-update-check -c config.yml`
Then the exit status should be 0
And the output should contain "Config file at config.yml is valid."
Scenario: Checking a valid config file with an orb
Given a file named "config.yml" with:
"""
version: 2.1
orbs:
node: circleci/node@5.0.3
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci config validate --skip-update-check -c config.yml`
Then the exit status should be 0
And the output should contain "Config file at config.yml is valid"
Scenario: Checking a valid config against the k9s server
Given a file named "config.yml" with:
"""
version: 2.1
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci --host https://k9s.sphereci.com config validate --skip-update-check -c config.yml`
Then the exit status should be 0
And the output should contain "Config file at config.yml is valid"
Scenario: Checking a valid config file with an orb
Given a file named "config.yml" with:
"""
version: 2.1
orbs:
node: circleci/node@5.0.3
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci config validate --skip-update-check -c config.yml`
Then the exit status should be 0
And the output should contain "Config file at config.yml is valid"
Scenario: Checking a valid config file with a private org
Given a file named "config.yml" with:
"""
version: 2.1
orbs:
node: circleci/node@5.0.3
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci config validate --skip-update-check --org-id bb604b45-b6b0-4b81-ad80-796f15eddf87 -c config.yml`
Then the output should contain "Config file at config.yml is valid"
And the exit status should be 0
Scenario: Checking a valid config file with a non-existant orb
Given a file named "config.yml" with:
"""
version: 2.1
orbs:
node: circleci/doesnt-exist@5.0.3
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci config validate --skip-update-check -c config.yml`
Then the exit status should be 255
And the output should contain "config compilation contains errors"
Scenario: Checking a valid config file with pipeline-parameters
Given a file named "config.yml" with:
"""
version: 2.1
parameters:
foo:
type: string
default: "bar"
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
echo << pipeline.parameters.foo >>
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci config process config.yml --pipeline-parameters "foo: fighters"`
Then the output should contain "fighters"
And the exit status should be 0
Scenario: Testing new type casting works as expected
Given a file named "config.yml" with:
"""
version: 2.1
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
parameters:
an-integer:
description: a test case to ensure parameters are passed correctly
type: integer
default: -1
steps:
- unless:
condition:
equal: [<< parameters.an-integer >>, -1]
steps:
- run: echo "<< parameters.an-integer >> - test"
workflows:
main-workflow:
jobs:
- datadog-hello-world:
an-integer: << pipeline.number >>
"""
When I run `circleci config process config.yml`
Then the output should contain "1 - test"
And the exit status should be 0
Scenario: Checking a valid config file with default pipeline params
Given a file named "config.yml" with:
"""
version: 2.1
parameters:
foo:
type: string
default: "bar"
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
echo << pipeline.parameters.foo >>
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
When I run `circleci config process config.yml`
Then the output should contain "bar"
And the exit status should be 0
Scenario: Checking a valid config file with file pipeline-parameters
Given a file named "config.yml" with:
"""
version: 2.1
parameters:
foo:
type: string
default: "bar"
jobs:
datadog-hello-world:
docker:
- image: cimg/base:stable
steps:
- run: |
echo "doing something really cool"
echo << pipeline.parameters.foo >>
workflows:
datadog-hello-world:
jobs:
- datadog-hello-world
"""
And I write to "params.yml" with:
"""
foo: "totallyawesome"
"""
When I run `circleci config process config.yml --pipeline-parameters params.yml`
Then the output should contain "totallyawesome"
And the exit status should be 0
Scenario: Checking an invalid config file
Given a file named "config.yml" with:
"""
version: 2.1
jobs:
build:
steps: [checkout]
"""
When I run `circleci config validate --skip-update-check -c config.yml`
Then the exit status should not be 0
And the output should contain "A job must have one of `docker`, `machine`, `macos` or `executor`"
Scenario: Checking a valid config file
Given a file named "config.yml" with:
"""
version: 2
jobs:
build:
machine: true
steps: [checkout]
"""
When I run `circleci config process --skip-update-check config.yml`
Then the output should match:
"""
version: 2
jobs:
build:
machine: true
steps:
- checkout
environment:
- CIRCLE_COMPARE_URL: .*
workflows:
version: 2
workflow:
jobs:
- build
"""
Scenario: Checking an invalid config file
Given a file named "config.yml" with:
"""
version: 2.1
jobs:
build:
steps: [checkout]
"""
When I run `circleci config process --skip-update-check config.yml`
Then the output should contain "A job must have one of `docker`, `machine`, `macos` or `executor`"
Scenario: Processing a config that has special characters
Given I use a fixture named "config_files"
When I run `circleci config process --skip-update-check with_percent.yml`
Then the exit status should be 0
And the output should contain "command: date '+%Y-%m-%dT%T%z'"
Scenario: Running validate in a directory that is not a git repo
When I cd to "/tmp"
And I write to "config.yml" with:
"""
jobs:
build:
machine: true
steps: [checkout]
"""
Then I run `git status`
And the output should contain "fatal: not a git repository (or any of the parent directories): .git"
And I run `circleci config validate --skip-update-check -c config.yml`
And the output should contain "Config file at config.yml is valid."
And the exit status should be 0