-
Notifications
You must be signed in to change notification settings - Fork 10
/
bitbucket-pipelines.yml
412 lines (409 loc) · 14 KB
/
bitbucket-pipelines.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
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
clone:
depth: 1
pipelines:
default:
- step:
image: ktomk/pipelines@sha256:2ef9a59041a7c4f36001abaec4fe7c10c26c1ead4da11515ba2af346fe60ddac
name: pipeline features and introspection
script:
- echo "test" || true
- lib/pipelines/environment.sh
custom:
lint-php-5.3:
- step: &lint-php53
image: ktomk/pipelines:docker.io-php-5.3
script:
- lib/script/ppconf.sh downpatch-phpunit-tests
- lib/pipelines/lint.sh
unit-tests-php-5.3:
- step:
image: cespi/php-5.3:cli-latest # has no zip: tomsowerby/php-5.3:cli
caches:
- build-http-cache
- composer
script:
- command -v composer || lib/pipelines/composer-install.sh
- lib/script/ppconf.sh self-test disable-tls remove-dev optional downpatch-phpunit-tests
- composer -n -q update --no-progress
- vendor/bin/phpunit # --testsuite unit,integration by default w/ phpunit 4.8.36
services:
- docker
build-phar-php-5.3:
- step:
image: docker.io/ktomk/pipelines:php5.3-cespi
caches:
- composer-53-build-cespi
script:
- lib/script/ppconf.sh self-test remove-dev optional downpatch-phpunit-tests
- composer -n -q update --no-progress
- git reset --hard HEAD # reset for phar build
- bash -c '( set -o pipefail; composer build 2>&1 | tee build/build-pipelines-phar.log; )'
artifacts:
- build/build-pipelines-phar.log
- build/pipelines.phar
unit-tests-php-7.0:
- step: &unit-tests-php70
image: ktomk/pipelines:php7.0
caches:
- build-http-cache
- composer
script:
- command -v composer || lib/pipelines/composer-install.sh
- lib/script/ppconf.sh self-test remove-dev all downpatch-phpunit-tests phpunit ^6
- vendor/bin/phpunit --testsuite unit,integration
services:
- docker
unit-tests-php-7.1:
- step:
image: ktomk/pipelines:php7.1
caches:
- build-http-cache
- composer
script:
- command -v composer || lib/pipelines/composer-install.sh
- lib/script/ppconf.sh self-test remove-dev all downpatch-phpunit-tests phpunit ^6
- vendor/bin/phpunit --testsuite unit,integration
services:
- docker
unit-tests-php-7.2:
- step:
image: ktomk/pipelines:php7.2
caches:
- build-http-cache
- composer
script:
- command -v composer || lib/pipelines/composer-install.sh
- lib/script/ppconf.sh self-test phpunit ^7
- vendor/bin/phpunit --testsuite unit,integration
services:
- docker
lint-php-7.4:
- step: &lint-php74
image: php:7.4
script:
- lib/pipelines/lint.sh
unit-tests-php-7.4:
- step:
image: ktomk/pipelines:php7.4
caches:
- build-http-cache
- composer
script:
- command -v composer || lib/pipelines/composer-install.sh
- lib/script/ppconf.sh self-test phpunit ^7
- vendor/bin/phpunit --testsuite unit,integration
services:
- docker
lint-php-8.0:
- step: &lint-php80
image: php:8.0
script:
- lib/pipelines/lint.sh
unit-tests-php-8.0:
- step:
image: ktomk/pipelines:php8.0
caches:
- build-http-cache
- composer
script:
- command -v composer || lib/pipelines/composer-install.sh
- composer -n require --no-progress --dev phpunit/phpunit ^9 --update-with-dependencies --ignore-platform-reqs
- ./lib/script/ppconf.sh patch-phpunit-tests
- vendor/bin/phpunit --migrate-configuration
- vendor/bin/phpunit --testsuite unit,integration
services:
- docker
lint-php-8.0-alpine:
- step: &lint-php80-alpine
image: ktomk/pipelines:php8.0-alpine
caches: [apk]
script:
- lib/pipelines/lint.sh
unit-tests-php-8.0-alpine:
- step:
image: ktomk/pipelines:php8.0-alpine
caches:
- composer
script:
- composer -n require --no-progress --dev phpunit/phpunit ^9 --update-with-dependencies --ignore-platform-reqs
- ./lib/script/ppconf.sh patch-phpunit-tests
- vendor/bin/phpunit --migrate-configuration
- XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite unit,integration
services:
- docker
ci-php-8.0-alpine:
- step:
image: ktomk/pipelines:php8.0-alpine
caches: [composer, vendor-php80]
script:
- composer -n install --no-progress
- composer ci
services: [docker]
lint-php-8.1-alpine:
- step: &lint-php81-alpine
image: ktomk/pipelines:php8.1-alpine
caches: [apk]
script:
- lib/pipelines/lint.sh
unit-tests-php-8.1-alpine:
- step:
image: ktomk/pipelines:php8.1-alpine
caches:
- composer
script:
- composer -n require --no-progress --dev phpunit/phpunit ^9 --update-with-dependencies --ignore-platform-reqs
- ./lib/script/ppconf.sh patch-phpunit-tests
- vendor/bin/phpunit --migrate-configuration
- XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite unit,integration
services:
- docker
ci-php-8.1-alpine:
- step:
image: ktomk/pipelines:php8.1-alpine
caches: [composer, vendor-php81]
script:
- composer -n install --no-progress || composer -n update --no-progress
- PHP_CS_FIXER_IGNORE_ENV=1 composer ci
services: [docker]
lint-php-8.2-alpine:
- step: &lint-php82-alpine
image: ktomk/pipelines:php8.2-alpine
caches: [apk]
script:
- lib/pipelines/lint.sh
unit-tests-php-8.2-alpine:
- step:
image: ktomk/pipelines:php8.2-alpine
caches:
- composer
script:
- composer -n require --no-progress --dev phpunit/phpunit ^9 --update-with-dependencies --ignore-platform-reqs
- ./lib/script/ppconf.sh patch-phpunit-tests
- vendor/bin/phpunit --migrate-configuration
- XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite unit,integration
services:
- docker
ci-php-8.2-alpine:
- step:
image: ktomk/pipelines:php8.2-alpine
caches: [composer, vendor-php82]
script:
- composer -n install --no-progress || composer -n update --no-progress
- PHP_CS_FIXER_IGNORE_ENV=1 composer ci
services: [docker]
lint-php:
- step: *lint-php53
- step: *lint-php74
- step: *lint-php80
- step: *lint-php80-alpine
- step: *lint-php81-alpine
- step: *lint-php82-alpine
unit-tests: # run phpunit suite
- step: *unit-tests-php70
html-docs:
- step:
name: build html-docs with mkdocs
image: ktomk/pipelines:mkdocs-material
artifacts: [build/html-docs/**, build/html-docs.tar.gz]
caches: [composer, pip]
script:
- make -C lib/build/mkdocs clean ../../../build/html-docs.tar.gz
artifact-tests: # run phpunit suite w/ artifact
- step:
image: php:7.0
script:
- vendor/bin/phpunit
artifacts:
- build/html/testdox.html
docker:
- step:
image: ktomk/pipelines:busybox
name: docker-in-docker
script:
- 'docker version --format "client: {{.Client.Version}} / server: {{.Server.Version}}"'
- docker ps
- docker inspect pipelines-1.docker-in-docker.custom-docker.pipelines | head -n 8
services:
- docker
docker-install:
- step:
image: php:7.0
name: docker-in-docker w/ install script
caches:
- build-http-cache
script:
- lib/pipelines/docker-client-install.sh
- docker version
- docker version --format {{.Client.Version}}
- docker version --format {{.Server.Version}}
- bin/pipelines --deploy mount --keep
docker-phar:
- step:
image: php:7.0
name: default pipeline inside pipelines pipeline
script:
- docker version
- 'docker version --format "client: {{.Client.Version}} / server: {{.Server.Version}}"'
- build/pipelines.phar --no-keep
services:
- docker
docker-phar-install:
- step:
image: php:7.0
name: default pipeline inside pipelines pipeline (extra docker client install)
caches:
- build-http-cache
script:
- lib/pipelines/docker-client-install.sh
- docker version
- 'docker version --format "client: {{.Client.Version}} / server: {{.Server.Version}}"'
- build/pipelines.phar --no-keep
recursion:
- step:
image: php:7.4
script:
- 'docker version --format "client: {{.Client.Version}} / server: {{.Server.Version}}"'
- docker cp --help
- bin/pipelines --pipeline custom/recursion/middle
services:
- docker
recursion/middle:
- step:
image: php:7.4
script:
- php --version
- step:
image: php:7.4
script:
- 'docker version --format "client: {{.Client.Version}} / server: {{.Server.Version}}"'
- bin/pipelines --pipeline custom/recursion --dry-run # must fail
services:
- docker
recursion-pip-happy:
- step:
image: php:7.4
script:
- 'docker version --format "client: {{.Client.Version}} / server: {{.Server.Version}}"'
- docker cp --help
- bin/pipelines --pipeline custom/recursion-pip-happy/end
services:
- docker
recursion-pip-happy/end:
- step:
image: php:7.4
script:
- ':'
private/docker-hub:
- step:
image:
name: ktomk/private:busybox
username: $DOCKER_ID_USER
password: $DOCKER_ID_PASSWORD
email: $DOCKER_ID_EMAIL
script:
- lib/pipelines/environment.sh
- env
printenv:
- step:
image: ktomk/pipelines:busybox
name: print environment variables
script:
- printenv | sort
after-script:
- step:
image: ktomk/pipelines:busybox
name: Happy
script:
- echo "fine"
after-script:
- 'echo "BITBUCKET_EXIT_CODE: ${BITBUCKET_EXIT_CODE}"'
- step:
name: Broken
image: ktomk/pipelines:busybox
script:
- exit 123
- echo "already broken"
after-script:
- 'echo "BITBUCKET_EXIT_CODE: ${BITBUCKET_EXIT_CODE}"'
redis-service:
- step:
name: redis service
image: redis:alpine
script:
- redis-cli -h localhost ping
services:
- redis
mysql-service:
- step:
name: mysql service
image: mysql:5.7
script:
- mysql --version
- T=10; while [ $T -gt 0 ]; do echo $T; T=$(( $T - 1 )); sleep 1; done # give mysql a bit of time to boot up
- >
mysql -h 127.0.0.1 -u test_user -ptest_user_password -D pipelines -vvv -e '
SHOW DATABASES;
SELECT VERSION();
SHOW VARIABLES LIKE "%version%";
'
services:
- mysql
deploy: # https://bitbucket.org/blog/adding-human-interaction-back-into-automated-builds
- variables:
- name: ENVIRONMENT
- step:
image: ktomk/pipelines:busybox
script:
- echo "Deploying to $ENVIRONMENT"
# ... rest of deployment script
exit-status:
- step:
name: "override set -e"
image: ktomk/pipelines:busybox
script:
- if [ $BITBUCKET_STEP_RUN_NUMBER -gt 1 ]; then exit; fi # skip on second run after failure"
- set +e
- mkdir -p /dev/null
- echo "surrender"
- step:
name: "shell pipe && (and ||) behaviour (set -e is implicit in pipelines)"
image: ktomk/pipelines:busybox
script:
- if [ $BITBUCKET_STEP_RUN_NUMBER -gt 1 ]; then exit; fi # skip on second run after failure"
- mkdir -p /dev/null && true
- echo "surrender"
- step:
name: "script scope example (per each script command, not shell command)"
image: ktomk/pipelines:busybox
script:
- |
mkdir -p /dev/null && test
echo "despite mkdir non-zero exit status ($?), this script part will be fine"
- echo "ok."
bash-runner:
- step:
name: "bash runner"
image: ktomk/pipelines:ubuntu-bash
script:
- echo "$HELLO"
- source /etc/os-release
- echo "$PRETTY_NAME"
definitions:
caches:
apk: /etc/apk/cache
build-http-cache: ~/.cache/build-http-cache
composer-53-build-cespi: ~/.composer/cache
vendor-php80: vendor
vendor-php81: vendor
vendor-php82: vendor
services:
redis:
image: redis:6.0.4-alpine
memory: 512 # memory limits are ignored locally
mysql:
image: mysql:5.7
variables:
MYSQL_DATABASE: pipelines
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_USER: $MYSQL_USER
MYSQL_PASSWORD: $MYSQL_PASSWORD