-
Notifications
You must be signed in to change notification settings - Fork 7
/
bitbucket-pipelines.yml
334 lines (320 loc) · 9.99 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
definitions:
services:
docker:
memory: 512
docker-large:
memory: 15360
type: docker
postgres:
image:
name: us.gcr.io/enroute-interne/enroute-postgresql:14-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
environment:
POSTGRES_DB: chouette
POSTGRES_USER: chouette
POSTGRES_PASSWORD: chouette
memory: 2048
datadog-agent:
image:
name: datadog/agent:latest
environment:
DD_INSIDE_CI: 'true'
DD_HOSTNAME: 'none'
DD_API_KEY: $DATADOG_KEY
caches:
bundler: ./vendor/bundle
yarn: ./node_modules
assets: ./public/assets
assets-cache: ./tmp/cache/assets
build-cache: ./cache
codacy-coverage: ./.codacy-coverage
steps:
- step: &setup
name: Setup
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- bundler
- yarn
script:
- eval "$(build.sh bitbucket::env)"
- build.sh ci::setup
- bundle config
artifacts:
- node_modules/**
- vendor/bundle/**
- .bundle/*
- step: &build-assets
name: Build assets
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- assets
- assets-cache
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- export RAILS_DB_ADAPTER=nulldb
- bundle exec rake ci:assets
artifacts:
- public/packs-test/**
- public/assets/**
- public/javascripts/i18n.js
- public/javascripts/translations.js
- step: &rspec-tests
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 4x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-1
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 4x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=0 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-2
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 4x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=1 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-3
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 4x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=2 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rspec-tests-4
name: Ruby Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
size: 4x
max-time: 30
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- BITBUCKET_PARALLEL_STEP_COUNT=4 BITBUCKET_PARALLEL_STEP=3 FAIL_FAST=true bundle exec rake ci:setup ci:spec
- build.sh codacy::report::partial
caches:
- build-cache
artifacts:
- parallel_tests/*
services:
- postgres
- datadog-agent
- step: &rebuild-runtime-log
name: Rebuild runtime log
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
script:
- cat parallel_tests/runtime*.log > cache/runtime.log
- build.sh codacy::report::final
caches:
- build-cache
- step: &jest-tests
name: Javascript Unit tests
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- bundle exec rake ci:jest
- build.sh codacy::report
- step: &bundle-audit
name: Bundle Audit
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
script:
- eval "$(build.sh bitbucket::env)"
- build.sh bundler::dependencies
- bundle exec rake ci:check_security
- step: &build-docker
name: Build Docker
size: 4x
image:
name: us.gcr.io/enroute-interne/enroute-cloud-sdk:latest
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- docker
script:
- build.sh gcloud::setup
- build.sh bitbucket::docker::build
services:
- docker-large
pipelines:
custom:
gems-update: # Merge ci-master from chouette-core
- step:
name: Update gems
image:
name: us.gcr.io/enroute-interne/enroute-ruby:2.7-dev
username: _json_key
password: "$GCLOUD_API_KEYFILE"
caches:
- bundler
- yarn
- assets
- assets-cache
- build-cache
script:
- eval "$(build.sh bitbucket::env)"
- build.sh ci::setup
- build.sh bummr::pull-request
services:
- postgres
default:
- step: *setup
- step: *build-assets
- parallel:
- step: *rspec-tests
- step: *rspec-tests
- step: *rspec-tests
- step: *rspec-tests
- step: *rebuild-runtime-log
- parallel:
- step: *jest-tests
- step: *bundle-audit
branches:
master:
- step: *setup
- step: *build-assets
- parallel:
fail-fast: true
steps:
- step: *build-docker
- step: *bundle-audit
- step: *jest-tests
- step: *rspec-tests-1
- step: *rspec-tests-2
- step: *rspec-tests-3
- step: *rspec-tests-4
- step: *rebuild-runtime-log
- step:
name: Tag
artifacts:
download: false
script:
- export TAG_NAME=ci-master
- git tag -afm "Build ${BITBUCKET_BUILD_NUMBER}" $TAG_NAME
- git push origin :refs/tags/$TAG_NAME
- git push origin $TAG_NAME
- step:
name: Trigger sub-projects
artifacts:
download: false
script:
- pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: $TRIGGER_REPOSITORY_1
CUSTOM_PIPELINE_NAME: "merge"
- pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: $TRIGGER_REPOSITORY_2
CUSTOM_PIPELINE_NAME: "merge"
- step:
name: Deploy to test
artifacts:
download: false
image:
name: eu.gcr.io/enroute-interne/enroute-cloud-sdk:latest
username: _json_key
password: "$GCLOUD_API_KEYFILE"
deployment: test
runs-on:
- self.hosted
- env.interne
- deploy
script:
- git clone [email protected]:enroute-mobi/chouette-env.git env
- env/deploy-with-runner.sh
- pipe: atlassian/datadog-send-event:2.2.0
variables:
API_KEY: $DATADOG_KEY
TITLE: "Build ${BITBUCKET_BUILD_NUMBER} deployed on ${BITBUCKET_REPO_SLUG} ${BITBUCKET_DEPLOYMENT_ENVIRONMENT}"
PAYLOAD: >
{ "source_type_name": "BITBUCKET", "tags":["env:test","app:chouette-core","repository:chouette-core"] }
- step:
name: Trigger User Tests
artifacts:
download: false
script:
- pipe: atlassian/trigger-pipeline:5.0.1
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
REPOSITORY: $TRIGGER_REPOSITORY_3