forked from bitrise-io/bitrise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitrise.yml
345 lines (301 loc) · 9.62 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
format_version: "4"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
- RELEASE_VERSION: 1.14.0
- BIN_NAME: bitrise
- GITHUB_RELEASES_URL: https://github.com/bitrise-io/${BIN_NAME}/releases
- INTERNAL_DEV_SLACK_WEBHOOK_URL: https://hooks.slack.com/services/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
- INTERNAL_DEV_SLACK_CHANNEL: bitrise-devs
- INTERNAL_DEV_LIFELINE_SLACK_CHANNEL: bitrise-dev-lifeline
trigger_map:
- push_branch: "/release"
workflow: create-release
- push_branch: "/release/announce"
workflow: announce-release
- push_branch: "*"
workflow: ci
- pull_request_source_branch: "*"
workflow: ci
workflows:
# ----------------------------------------------------------------
# --- workflows for CI and testing
ci:
title: Bitrise CI
description: |
1, Git clone bitrise repo and install testing tools
2, Run tests
3, Announce test result
before_run:
- _prepare-and-setup
- test
steps:
- slack:
title: Slack notifications
run_if: ".IsCI"
inputs:
- webhook_url: "$INTERNAL_DEV_SLACK_WEBHOOK_URL"
- channel: "$INTERNAL_DEV_LIFELINE_SLACK_CHANNEL"
- from_username: "${BIN_NAME} - CI - OK"
- from_username_on_error: "${BIN_NAME} - CI - ERROR"
- message: |-
CI was successful on branch: *${BITRISE_GIT_BRANCH}*
Build URL: ${BITRISE_BUILD_URL}
- message_on_error: |-
CI FAILED on branch: *${BITRISE_GIT_BRANCH}*
Build URL: ${BITRISE_BUILD_URL}
integration-test:
after_run:
- _bitrise-run-setup
steps:
- script:
title: Go build
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# build the new bitrise
current_dir=$(pwd)
current_bitrise=$current_dir/_tmp/ci-bin
go build -o $current_bitrise
# setup for the new bitrise as well
$current_bitrise setup
envman add --key CURRENT_BITRISE --value $current_bitrise
- script:
title: Run integration tests
inputs:
- content: |-
#!/usr/bin/env bash
echo "Running integration tests ..."
set -ex
export PR=""
export PULL_REQUEST_ID=""
export INTEGRATION_TEST_BINARY_PATH="$CURRENT_BITRISE"
go test -v ./_tests/integration/...
test:
title: Bitrise test
description: |
1, Err check
2, Go Lint
3, Go Test
4, Test-build
5, Step-template test
6, Integration tests
after_run:
- integration-test
steps:
- script:
title: Print go environment
inputs:
- content: |-
set -x
go version
echo $GO15VENDOREXPERIMENT
- script:
title: Export go files to test
inputs:
- content: |-
set -e
set -x
no_vendor_paths="$(go list ./... | grep -v vendor)"
envman add --key GOLIST_WITHOUT_VENDOR --value "$no_vendor_paths"
- script:
title: Err check
inputs:
- content: errcheck -asserts=true -blank=true $GOLIST_WITHOUT_VENDOR
- script:
title: Go lint
inputs:
- content: |-
#!/usr/bin/env bash
set -e
while read -r line; do
echo "-> Linting: $line"
golint_out="$(golint $line)"
if [[ "${golint_out}" != "" ]] ; then
echo "=> Golint issues found:"
echo "${golint_out}"
exit 1
fi
done <<< "$GOLIST_WITHOUT_VENDOR"
- script:
title: Go test
inputs:
- content: go test ./...
_bitrise-run-setup:
steps:
- script:
title: Setup system bitrise
run_if: ".IsCI"
inputs:
- content: |-
#!/usr/bin/env bash
bitrise setup
_prepare-and-setup:
title: Prepare bitrise and install testing tools
description: |
Prepares the environment for testing
steps:
- script:
is_skippable: true
inputs:
- content: brew update
- script:
title: Install testing tools
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# Check for unhandled errors
go get -u -v github.com/kisielk/errcheck
# Go lint
go get -u -v github.com/golang/lint/golint
- script:
title: Install bitrise tools
run_if: ".IsCI"
inputs:
- content: |-
#!/usr/bin/env bash
set -e
set -x
# Install envman
envman -v
curl -fL https://github.com/bitrise-io/envman/releases/download/1.1.0/envman-$(uname -s)-$(uname -m) > /usr/local/bin/envman
chmod +x /usr/local/bin/envman
envman -v
# Install stepman
stepman -v
curl -fL https://github.com/bitrise-io/stepman/releases/download/0.9.18/stepman-$(uname -s)-$(uname -m) > /usr/local/bin/stepman
chmod +x /usr/local/bin/stepman
stepman -v
# ----------------------------------------------------------------
# --- workflows for Releasing
create-release:
title: Create Release version
description: |-
Creates new version with specified RELEASE_VERSION environment
1, Create CHANGELOG and git release
2, Export RELEASE_VERSION
3, Create binaries
after_run:
- create-binaries
steps:
- script:
title: Create CHANGELOG and git release
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get github.com/bitrise-tools/releaseman
export CI=true
releaseman create-changelog \
--version $RELEASE_VERSION \
--set-version-script "bash _scripts/set_version.sh version/version.go"
announce-release:
title: Announce Release
description: |-
Notifying about new version of bitrise
Send Slack notifications
steps:
- slack:
title: Announce on Internal Slack channel
inputs:
- webhook_url: "$INTERNAL_DEV_SLACK_WEBHOOK_URL"
- channel: "$INTERNAL_DEV_SLACK_CHANNEL"
- from_username: ${BIN_NAME}
- message: |
Release v${RELEASE_VERSION} was just published! :tada:
You can find it at ${GITHUB_RELEASES_URL}
- emoji: ":rocket:"
- slack:
title: Announce on Public Slack channel
inputs:
- webhook_url: "$PUBLIC_SLACK_WEBHOOK_URL"
- channel: "$PUBLIC_SLACK_CHANNEL"
- from_username: ${BIN_NAME}
- message: |
Release v${RELEASE_VERSION} was just published! :tada:
You can find it at ${GITHUB_RELEASES_URL}
- emoji: ":rocket:"
create-binaries:
title: Create binaries
description: |
Creates Linux and Darwin binaries
steps:
- script:
title: Create binaries
inputs:
- content: |
#!/usr/bin/env bash
set -e
set -x
echo
echo "Create final binaries"
echo " Build number: $BITRISE_BUILD_NUMBER"
export ARCH=x86_64
export GOARCH=amd64
# Create Darwin bin
export OS=Darwin
export GOOS=darwin
DEPLOY_PATH="_bin/$BIN_NAME-$OS-$ARCH"
echo " Create final Darwin binary at: $DEPLOY_PATH"
version_package="github.com/bitrise-io/bitrise/version"
go build \
-ldflags "-X $version_package.BuildNumber=$BITRISE_BUILD_NUMBER -X $version_package.Commit=$GIT_CLONE_COMMIT_HASH" \
-o "$DEPLOY_PATH"
envman add --key OSX_DEPLOY_PATH --value $DEPLOY_PATH
cp $DEPLOY_PATH $BITRISE_DEPLOY_DIR/$BIN_NAME-$OS-$ARCH
echo " Copy final Darwin binary to: $BITRISE_DEPLOY_DIR/$BIN_NAME-$OS-$ARCH"
# Create Linux binary
export OS=Linux
export GOOS=linux
DEPLOY_PATH="_bin/$BIN_NAME-$OS-$ARCH"
echo " Create final Linux binary at: $DEPLOY_PATH"
go build \
-ldflags "-X $version_package.BuildNumber=$BITRISE_BUILD_NUMBER -X $version_package.Commit=$GIT_CLONE_COMMIT_HASH" \
-o "$DEPLOY_PATH"
envman add --key LINUX_DEPLOY_PATH --value $DEPLOY_PATH
cp $DEPLOY_PATH $BITRISE_DEPLOY_DIR/$BIN_NAME-$OS-$ARCH
echo " Copy final Linux binary to: $BITRISE_DEPLOY_DIR/$BIN_NAME-$OS-$ARCH"
# ----------------------------------------------------------------
# --- workflows for Utility
dep-update:
title: Dep update
description: |
Used for updating bitrise dependencies with dep
steps:
- script:
title: Dependency update
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
go get -u -v github.com/golang/dep/cmd/dep
dep ensure -v
dep ensure -v -update
noop:
title: Noop
description: Empty workflow for quick testing
fail-test:
title: Fails
description: Workflow will fail
steps:
- script:
title: Success
inputs:
- content: exit 0
- script:
title: Fail wit exit code 2
inputs:
- content: exit 2
- script:
title: Skippable fail with exit code 2
is_always_run: true
is_skippable: true
inputs:
- content: exit 2
- script:
title: Skipping success
is_always_run: false
inputs:
- content: exit 0