forked from bitrise-io/bitrise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitrise.yml
More file actions
498 lines (435 loc) · 16.2 KB
/
bitrise.yml
File metadata and controls
498 lines (435 loc) · 16.2 KB
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
---
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
pipelines:
ci:
triggers:
push:
- branch: master
pull_request:
- source_branch: "*"
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:
release:
triggers:
tag:
- name: "*.*.*"
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
run_lint:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies: {}
- bundle::run_lint: {}
run_unit_tests_macos:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies: {}
- bundle::setup_go_junit_report: {}
- bundle::run_unit_tests: {}
meta:
bitrise.io:
stack: osx-xcode-16.4.x
machine_type_id: g2.mac.large
run_unit_tests_linux:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies:
inputs:
- IGNORE_CUSTOM_GOLANG: "true"
- bundle::setup_go_junit_report: {}
- bundle::run_unit_tests: {}
run_integration_tests_macos:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies: {}
- bundle::setup_go_junit_report: {}
- bundle::run_integration_tests: {}
meta:
bitrise.io:
# TODO: switch to stable stack when Nix is rolled out there
stack: osx-xcode-edge
machine_type_id: g2.mac.large
run_integration_tests_linux:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies:
inputs:
- IGNORE_CUSTOM_GOLANG: "true"
- bundle::setup_go_junit_report: {}
- bundle::run_integration_tests: {}
meta:
bitrise.io:
# TODO: switch to stable stack when Nix is rolled out there
stack: ubuntu-noble-24.04-bitrise-2025-android
machine_type_id: g2.linux.x-large
run_docker_integration_tests_linux:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies:
inputs:
- IGNORE_CUSTOM_GOLANG: "true"
- bundle::setup_go_junit_report: {}
- bundle::run_docker_integration_tests:
envs:
- SRC_DIR_IN_GOPATH: $BITRISE_SOURCE_DIR
# Note: this workflow is triggered externally during stack testing, do not remove or break.
run_system_asdf_tests:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies: {}
- bundle::setup_go_junit_report: {}
- bundle::run_system_asdf_integration_tests: {}
# Note: this workflow is triggered externally during stack testing, do not remove or break.
run_system_mise_tests:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies: {}
- bundle::setup_go_junit_report: {}
- bundle::run_system_mise_integration_tests: {}
test_binary_build_macos:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies: {}
- bundle::setup_goreleaser: {}
- bundle::test_binary_build: {}
meta:
bitrise.io:
stack: osx-xcode-16.4.x
machine_type_id: g2.mac.large
test_binary_build_linux:
steps:
- bundle::setup_repo: {}
- bundle::install_dependencies:
inputs:
- IGNORE_CUSTOM_GOLANG: "true"
- bundle::setup_goreleaser: {}
- bundle::test_binary_build: {}
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: Validate if Bitrise CLI version matches the git tag
inputs:
- content: |-
#!/bin/bash
set -ex
version=$(go run main.go --version)
if [[ "v$version" != "$BITRISE_GIT_TAG" ]]; then
echo "Bitrise CLI version ($version) does not match the git tag ($BITRISE_GIT_TAG)"
echo "Please update the Bitrise CLI version to match the git tag"
exit 1
fi
- 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
unpin-go-version:
title: Unpin Go version from .tool-versions
description: |-
Removes golang line from .tool-versions file, so the global version is used.
TODO: this is only needed as long as Go steps are built from source
(because tool setup has no influence on the environment of the CLI process itself, just the environment of the workflow).
steps:
- script@1:
title: Unpin Go version
inputs:
- content: |-
#!/bin/bash
set -ex
TOOL_VERSIONS_FILE=".tool-versions"
if [ ! -f "$TOOL_VERSIONS_FILE" ]; then
echo "Error: $TOOL_VERSIONS_FILE not found"
exit 1
fi
# Remove lines with golang from .tool-versions
grep -v '^golang ' "$TOOL_VERSIONS_FILE" > "$TOOL_VERSIONS_FILE.tmp" || true
mv "$TOOL_VERSIONS_FILE.tmp" "$TOOL_VERSIONS_FILE"
step_bundles:
run_lint:
title: Run linter
steps:
- script:
title: golangci-lint
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s v2.6.0
./bin/golangci-lint run
run_unit_tests:
steps:
- script@1:
title: Run unit 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}"
# 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
export BITRISE_ANALYTICS_DISABLED=true
# 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
set +e # Temporarily disable exit on error
# Note about `-p 1`: `bitrise run` is not parallelizable and has some race conditions, we need to execute tests sequentially
cd ./integrationtests && go test -v --tags linux_and_mac -p 1 ./... 2>&1 | tee "./${test_log_file_name}.log"
test_exit_code=$?
set -e # Re-enable exit on error
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"
exit $test_exit_code
- deploy-to-bitrise-io@2: {}
run_system_asdf_integration_tests:
steps:
- script@1:
title: Run integration tests against system asdf
inputs:
- content: |
#!/bin/bash
set -ex
# Special test mode that doesn't use the test harness but uses the system-wide asdf install and config
export TOOLPROVIDER_TEST_USE_SYSTEM_ASDF=1
# We test the system bitrise executable, not one built from source
export INTEGRATION_TEST_BINARY_PATH="$(which bitrise)"
cd integrationtests && go test -v --tags linux_and_mac ./toolprovider/asdf/... -timeout 360s
run_system_mise_integration_tests:
steps:
- script@1:
title: Run mise integration tests against system
inputs:
- content: |
#!/bin/bash
set -ex
# We test the system bitrise executable, not one built from source
export INTEGRATION_TEST_BINARY_PATH="$(which bitrise)"
cd integrationtests && go test -v --tags linux_and_mac ./toolprovider/mise/... -timeout 360s
run_docker_integration_tests:
steps:
- script@1:
title: Docker login for pulls
run_if: .IsCI
inputs:
- content: echo "${DOCKER_LOGIN_PULLONLY_PASS}" | docker login -u bitrisedev --password-stdin
- 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
set +e # Temporarily disable exit on error
cd ./integrationtests && go test -v -p 1 --tags linux_only ./... 2>&1 | tee "./${linux_only_test_log_file_name}.log"
test_exit_code=$?
set -e # Re-enable exit on error
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"
# Exit with the original test exit code
exit $test_exit_code
- 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 --clean
- deploy-to-bitrise-io@2: {}
setup_repo:
steps:
- git-clone@8:
inputs:
- fetch_tags: "yes"
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
go install github.com/goreleaser/goreleaser/v2@latest
asdf reshim golang
install_dependencies:
steps:
- bitrise-run@0:
inputs:
- workflow_id: unpin-go-version
run_if: '{{ enveq "IGNORE_CUSTOM_GOLANG" "true" }}'
- script@1:
inputs:
- content: bitrise tools setup --config .tool-versions
inputs:
- IGNORE_CUSTOM_GOLANG: "false"
opts:
title: Skip Custom Golang Version Installation
value_options:
- "true"
- "false"
description: >-
Removes golang line from .tool-versions file, so the global version is
used.
TODO: this is only needed as long as Go steps are built from source
(because tool setup has no influence on the environment of the CLI
process itself, just the environment of the workflow).
meta:
bitrise.io:
machine_type_id: g2.linux.x-large
stack: ubuntu-noble-24.04-bitrise-2025-android