-
Notifications
You must be signed in to change notification settings - Fork 131
/
bitrise.yml
377 lines (327 loc) · 12 KB
/
bitrise.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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
---
format_version: "17"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
app:
status_report_name: Run <target_id> pipeline
trigger_map:
- push_branch: master
pipeline: ci
- pull_request_source_branch: "*"
pipeline: ci
- tag: "*.*.*"
workflow: release
pipelines:
ci:
stages:
- run_tests: { }
stages:
run_tests:
workflows:
- run_lint: { }
- run_unit_tests_macos: { }
- run_unit_tests_linux: { }
- run_integration_tests_macos: { }
- run_integration_tests_linux: { }
- run_docker_integration_tests_linux: { }
- test_binary_build_macos: { }
- test_binary_build_linux: { }
workflows:
run_lint:
steps:
- bundle::setup_repo: { }
- bundle::run_lint: { }
run_unit_tests_macos:
steps:
- bundle::setup_repo: { }
- bundle::setup_go_junit_report: { }
- bundle::run_unit_tests: { }
meta:
bitrise.io:
stack: osx-xcode-edge
machine_type_id: g2.mac.large
run_unit_tests_linux:
steps:
- bundle::setup_repo: { }
- bundle::setup_go_junit_report: { }
- bundle::run_unit_tests: { }
run_integration_tests_macos:
steps:
- bundle::setup_repo: { }
- bundle::setup_go_junit_report: { }
- bundle::run_integration_tests: { }
meta:
bitrise.io:
stack: osx-xcode-edge
machine_type_id: g2.mac.large
run_integration_tests_linux:
steps:
- bundle::setup_repo: { }
- bundle::setup_go_junit_report: { }
- bundle::run_integration_tests: { }
run_docker_integration_tests_linux:
steps:
- bundle::setup_repo: { }
- bundle::setup_go_junit_report: { }
- bundle::run_docker_integration_tests:
envs:
- SRC_DIR_IN_GOPATH: $BITRISE_SOURCE_DIR
meta:
bitrise.io:
machine_type_id: g2.linux.x-large
stack: linux-docker-android-20.04 # TODO: Docker tests are failing on Ubuntu 22.04
test_binary_build_macos:
steps:
- bundle::setup_repo: { }
- bundle::setup_goreleaser: { }
- bundle::test_binary_build: { }
meta:
bitrise.io:
stack: osx-xcode-edge
machine_type_id: g2.mac.large
test_binary_build_linux:
steps:
- bundle::setup_repo: { }
- bundle::setup_goreleaser: { }
- bundle::test_binary_build: { }
release:
steps:
- trigger-bitrise-workflow@0:
inputs:
- api_token: $CONTROL_CENTER_TRIGGER_KEY
- workflow_id: binary-tool-release
- exported_environment_variable_names: GIT_REPOSITORY_URL
- app_slug: $CONTROL_CENTER_APP_SLUG
create-release:
description: Creates Linux and Darwin binaries, then publishes a GitHub release
envs:
- GITHUB_TOKEN: $GIT_BOT_USER_ACCESS_TOKEN # Goreleaser expects this env var
# R2 bucket connection params
- AWS_ENDPOINT_URL: $AWS_ENDPOINT_PROD
- AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID_PROD
- AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY_PROD
steps:
- script@1:
title: Fetch GCS bucket credentials
inputs:
- content: |-
#!/bin/bash
set -ex
echo "$GCS_BITRISE_CLI_BUCKET_CREDENTIALS" > /tmp/gcs_service_account.json
# Goreleaser expects this env var:
envman add --key GOOGLE_APPLICATION_CREDENTIALS --value /tmp/gcs_service_account.json
- script@1:
title: Goreleaser (create binaries + publish to GH)
deps:
brew:
- name: goreleaser
inputs:
- content: |
#!/usr/bin/env bash
set -ex
goreleaser release
noop:
title: Noop
description: Empty workflow for quick testing
fail-test:
title: Fails
description: Workflow will fail
steps:
- script:
title: Success
inputs:
- content: |-
set -ex
exit 0
- script:
title: Fail wit exit code 2
inputs:
- content: |-
set -ex
exit 2
- script:
title: Skippable fail with exit code 2
is_always_run: true
is_skippable: true
inputs:
- content: |-
set -ex
exit 2
- script:
title: Skipping success
is_always_run: false
inputs:
- content: |-
set -ex
exit 0
step_bundles:
run_lint:
steps:
- git::https://github.com/bitrise-steplib/steps-check.git:
inputs:
- workflow: lint
- skip_step_yml_validation: "yes"
- deploy-to-bitrise-io@2: { }
run_unit_tests:
steps:
- script@1:
title: Run unit tests
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# Here we save the original test results and deploy directories and later on we recreate them,
# because during the tests these directories are removed.
ORIG_BITRISE_TEST_RESULT_DIR="${BITRISE_TEST_RESULT_DIR}"
ORIG_BITRISE_DEPLOY_DIR="${BITRISE_DEPLOY_DIR}"
# Setup per OS test name and log file name
if [ "$(uname)" = "Linux" ]; then
test_name_json='{"test-name":"Unit tests on Linux"}'
test_log_file_name="unit_tests_linux"
else
test_name_json='{"test-name":"Unit tests on macOS"}'
test_log_file_name="unit_tests_macos"
fi
# Run tests and generate report
go test -v -p 1 ./... 2>&1 | tee "./${test_log_file_name}.log"
mkdir -p "${ORIG_BITRISE_DEPLOY_DIR}"
cp "./${test_log_file_name}.log" "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.log"
go-junit-report -in "./${test_log_file_name}.log" -out "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml"
# Export the junit test results
test_results_dir="${ORIG_BITRISE_TEST_RESULT_DIR}/unit_test_results"
mkdir -p "${test_results_dir}"
cp "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml" "${test_results_dir}/${test_log_file_name}.xml"
echo "${test_name_json}" > "${test_results_dir}/test-info.json"
- deploy-to-bitrise-io@2: { }
run_integration_tests:
steps:
- script@1:
title: Run integration tests
inputs:
- content: |-
#!/usr/bin/env bash
set -exo pipefail
# Here we save the original test results and deploy directories and later on we recreate them,
# because during the tests these directories are removed.
ORIG_BITRISE_TEST_RESULT_DIR="${BITRISE_TEST_RESULT_DIR}"
ORIG_BITRISE_DEPLOY_DIR="${BITRISE_DEPLOY_DIR}"
# Build and setup the current binary
current_bitrise="$(pwd)/_tmp/test_bitrise"
export CGO_ENABLED=0
go build -o "$current_bitrise"
export PR="" PULL_REQUEST_ID=""
export INTEGRATION_TEST_BINARY_PATH="$current_bitrise"
$current_bitrise setup
# Setup per OS test name and log file name
if [ "$(uname)" = "Linux" ]; then
test_name_json='{"test-name":"Integration tests on Linux"}'
test_log_file_name="integration_tests_linux"
else
test_name_json='{"test-name":"Integration tests on macOS"}'
test_log_file_name="integration_tests_macos"
fi
# Run tests and generate report
go test -v --tags linux_and_mac ./_tests/integration/... 2>&1 | tee "./${test_log_file_name}.log"
mkdir -p "${ORIG_BITRISE_DEPLOY_DIR}"
cp "./${test_log_file_name}.log" "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.log"
go-junit-report -in "./${test_log_file_name}.log" -out "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml"
# Export the junit test results
test_results_dir="${ORIG_BITRISE_TEST_RESULT_DIR}/integration_test_results"
mkdir -p "${test_results_dir}"
cp "${ORIG_BITRISE_DEPLOY_DIR}/${test_log_file_name}.xml" "${test_results_dir}/${test_log_file_name}.xml"
echo "${test_name_json}" > "${test_results_dir}/test-info.json"
- deploy-to-bitrise-io@2: { }
run_docker_integration_tests:
steps:
- script@1:
title: Run integration tests
inputs:
- content: |-
#!/usr/bin/env bash
set -exo pipefail
# Here we save the original test results and deploy directories and later on we recreate them,
# because during the tests these directories are removed.
ORIG_BITRISE_TEST_RESULT_DIR="${BITRISE_TEST_RESULT_DIR}"
ORIG_BITRISE_DEPLOY_DIR="${BITRISE_DEPLOY_DIR}"
# Build and setup the current binary
current_bitrise="$(pwd)/_tmp/test_bitrise"
export CGO_ENABLED=0
go build -o "$current_bitrise"
export PR="" PULL_REQUEST_ID=""
export INTEGRATION_TEST_BINARY_PATH="$current_bitrise"
$current_bitrise setup
# Setup per OS test name and log file name
linux_only_test_name_json='{"test-name":"Linux only integration tests"}'
linux_only_test_log_file_name="linux_only_integration_tests"
# Run tests and generate report
go test -v --tags linux_only ./_tests/integration/... 2>&1 | tee "./${linux_only_test_log_file_name}.log"
mkdir -p "${ORIG_BITRISE_DEPLOY_DIR}"
cp "./${linux_only_test_log_file_name}.log" "${ORIG_BITRISE_DEPLOY_DIR}/${linux_only_test_log_file_name}.log"
go-junit-report -in "./${linux_only_test_log_file_name}.log" -out "${ORIG_BITRISE_DEPLOY_DIR}/${linux_only_test_log_file_name}.xml"
# Export the junit test results
test_results_dir="${ORIG_BITRISE_TEST_RESULT_DIR}/linux_only_integration_test_results"
mkdir -p "${test_results_dir}"
cp "${ORIG_BITRISE_DEPLOY_DIR}/${linux_only_test_log_file_name}.xml" "${test_results_dir}/${linux_only_test_log_file_name}.xml"
echo "${linux_only_test_name_json}" > "${test_results_dir}/test-info.json"
- script:
# The Go + ASDF situation is messed up on the Ubuntu 20 stack. Even though this workflow starts by installing
# the correct Go version with ASDF, the first non-Bash-toolkit step (deploy-to-bitrise-io) will fail,
# probably because the CLI process (which runs the steps) is already running by the time the Go version is set.
title: Ubuntu 20 Go hackery # TODO: remove this once the workflow is migrated to the Ubuntu 22 stack
inputs:
- content: rm ~/.asdf/shims/go
- deploy-to-bitrise-io@2: { }
test_binary_build:
steps:
- script@1:
title: Create snapshot binaries
deps:
brew:
- name: goreleaser
inputs:
- content: |
#!/usr/bin/env bash
set -ex
goreleaser release --snapshot --rm-dist
- deploy-to-bitrise-io@2: { }
setup_repo:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
- script:
title: Setup Go version
inputs:
- content: |-
#!/bin/bash
set -ex
asdf plugin add golang || true # TODO: can be removed once all workflows are migrated to Ubuntu 22
asdf install golang
setup_go_junit_report:
steps:
- script@1:
title: Setup JUnit XML converter
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go install github.com/jstemmer/go-junit-report/v2@latest
asdf reshim golang
setup_goreleaser:
steps:
- script@1:
inputs:
- content: |-
#!/bin/bash
set -ex
if [ "$(uname)" = "Linux" ]; then
wget -O /tmp/goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v1.19.2/goreleaser_1.19.2_amd64.deb
sudo dpkg -i /tmp/goreleaser.deb
else
go install github.com/goreleaser/goreleaser@latest
asdf reshim golang
fi
meta:
bitrise.io:
machine_type_id: g2.linux.x-large
stack: linux-docker-android-22.04