-
Notifications
You must be signed in to change notification settings - Fork 25
/
config.yml
302 lines (290 loc) · 8.97 KB
/
config.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
version: 2.1
orbs:
win: circleci/windows@2.3.0
windows-param: &windows-param
windows:
description: Whether this is running on Windows
type: boolean
default: false
executors:
mac:
macos:
xcode: 14.2.0
resource_class: macos.x86.medium.gen2
linux:
docker:
- image: cimg/go:1.17.1-node
windows: win/default
commands:
install_go_darwin:
description: "Install Go on Darwin"
steps:
- run:
name: Install go
command: |
curl -L https://golang.org/dl/go1.17.1.darwin-amd64.tar.gz | tar zxf -
echo "export PATH=$PATH:`pwd`/go/bin" >> $BASH_ENV
source $BASH_ENV
go version
go_build:
description: "go build, and output cli version"
parameters:
<<: *windows-param
steps:
- run:
name: Build
command: go build -ldflags "-X main.build=$CIRCLE_SHA1" -o build/rainforest<<# parameters.windows >>.exe<</ parameters.windows >>
- when:
condition: << parameters.windows >>
steps:
- run:
name: Move executable
command: |
Move-Item rainforest rainforest-dir
Move-Item build\./rainforest.exe .
- run:
name: Show CLI version
command: ./rainforest.exe -v --skip-update
- unless:
condition: << parameters.windows >>
steps:
- run:
name: Move executable
command: |
mv rainforest rainforest-dir
mv build/rainforest .
- run:
name: Show CLI version
command: ./rainforest -v --skip-update
pass:
parameters:
<<: *windows-param
description: Start a run that will pass
steps:
- run:
name: Start a run that will pass
command: |
./rainforest<<# parameters.windows >>.exe<</ parameters.windows >> --skip-update run --run-group 9502
pass_junit:
parameters:
<<: *windows-param
description: Start a run that will pass, with junit
steps:
- run:
name: Start a run that will pass, with junit
command: |
./rainforest<<# parameters.windows >>.exe<</ parameters.windows >> --skip-update run --run-group 9502 --junit-file junit-pass.xml
- store_test_results:
path: junit-pass.xml
pass_save_run_id:
parameters:
<<: *windows-param
description: Start a run that will pass, saving the run ID
steps:
- when:
condition: << parameters.windows >>
steps:
- run:
name: Start a run that will pass, saving the run ID
command: |
./rainforest.exe --skip-update run --run-group 9502 --save-run-id rf_run_id
Get-Content rf_run_id | Select-String -Pattern "^\d+$"
- unless:
condition: << parameters.windows >>
steps:
- run:
name: Start a run that will pass, saving the run ID
command: |
./rainforest --skip-update run --run-group 9502 --save-run-id rf_run_id
cat rf_run_id | grep -E "^[0-9]+$"
- store_artifacts:
path: rf_run_id
fail:
parameters:
<<: *windows-param
description: Start a run that will fail
steps:
- when:
condition: << parameters.windows >>
steps:
- run:
name: Start a run that will fail
command: |
./rainforest.exe --skip-update run --run-group 9503
if ($LastExitCode -gt 0) {
echo "TESTING ::: Got the expected non-zero exit code."
exit 0
} else {
echo "TESTING ::: Got UNEXPECTED zero exit code."
exit 1
}
- unless:
condition: << parameters.windows >>
steps:
- run:
name: Start a run that will fail
command: |
set +e
./rainforest --skip-update run --run-group 9503
if [[ $? != 0 ]]; then
echo "TESTING ::: Got the expected non-zero exit code. ✅"
echo 0
else
echo "TESTING ::: Got UNEXPECTED zero exit code. 🚨"
echo 1
fi
fail_junit:
parameters:
<<: *windows-param
description: Start a run that will fail
steps:
- when:
condition: << parameters.windows >>
steps:
- run:
name: Start a run that will fail
command: |
./rainforest.exe --skip-update run --run-group 9503 --junit-file junit-fail.xml
if ($LastExitCode -gt 0) {
echo "TESTING ::: Got the expected non-zero exit code."
exit 0
} else {
echo "TESTING ::: Got UNEXPECTED zero exit code."
exit 1
}
- unless:
condition: << parameters.windows >>
steps:
- run:
name: Start a run that will fail, with junit
command: |
set +e
./rainforest --skip-update run --run-group 9503 --junit-file junit-fail.xml
if [[ $? != 0 ]]; then
echo "TESTING ::: Got the expected non-zero exit code. ✅"
echo 0
else
echo "TESTING ::: Got UNEXPECTED zero exit code. 🚨"
echo 1
fi
- store_test_results:
path: junit-fail.xml
jobs:
validate_goreleaser_config:
executor: linux
steps:
- checkout
- run:
name: Install GoReleaser
command: go install github.com/goreleaser/goreleaser@v1.6.3
- run:
name: Check GoReleaser Config
command: goreleaser check
validate_formatting:
executor: linux
steps:
- checkout
- run:
name: Validate code formatting
command: ./script/validate_formatting
test:
executor: linux
steps:
- checkout
- run:
name: Get Junit Reporter
command: go install github.com/jstemmer/go-junit-report@latest
- run:
name: Run Unit Tests
command: go test -v -race ./... 2>&1 | go-junit-report > report.xml
- store_test_results:
path: report.xml
integration_test:
parameters:
platform:
# type: string rather than executor; otherwise the conditions used below won't work
# See https://discuss.circleci.com/t/condition-on-executor-type/39711
type: string
test:
type: steps
executor: << parameters.platform >>
steps:
- checkout
- when:
condition:
equal: [ << parameters.platform >>, mac ]
steps:
- install_go_darwin
- when:
condition:
equal: [ << parameters.platform >>, windows ]
steps:
- go_build:
windows: true
- unless:
condition:
equal: [ << parameters.platform >>, windows ]
steps:
- go_build
- steps: << parameters.test >>
release:
executor: linux
steps:
- checkout
- run:
name: Release via GoReleaser
command: |
export GITHUB_TOKEN=$GITHUB_ACCESS_TOKEN
curl -sfL https://goreleaser.com/static/run | VERSION=v1.6.3 bash
- run:
name: Show checksums
command: cat dist/checksums.txt
- store_artifacts:
path: dist/checksums.txt
workflows:
version: 2
test_and_deploy:
jobs:
- validate_formatting
- test
- validate_goreleaser_config
- integration_test:
context:
- RainforestQA
requires:
- validate_formatting
- test
- validate_goreleaser_config
matrix:
parameters:
platform: [linux, mac]
test:
- [pass]
- [pass_junit]
- [pass_save_run_id]
- [fail]
- [fail_junit]
- integration_test:
context:
- RainforestQA
requires:
- validate_formatting
- test
- validate_goreleaser_config
matrix:
parameters:
platform: [windows]
test:
- [pass: { windows: true }]
- [pass_junit: { windows: true }]
- [pass_save_run_id: { windows: true }]
- [fail: { windows: true }]
- [fail_junit: { windows: true }]
- release:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
context:
- circlemator