-
Notifications
You must be signed in to change notification settings - Fork 375
/
config.yml
520 lines (452 loc) · 15.2 KB
/
config.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
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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
version: 2
references:
golang_workspace: &golang_workspace
working_directory: /go/src/berty.tech
environment:
GOPATH: /go
GOTEST_TIMEOUT: 5m
GOPROXY: http://goproxy.berty.io:3000/
GO111MODULE: "on"
TEST_OPTS: "-coverprofile=profile.out -covermode=count"
docker:
- image: circleci/golang:1.11.4
master_version: &master_version
run:
name: retrieve master version
command: |
cd ~/go/src/berty.tech
no_repo=false
if [ ! -e .git ]; then
no_repo=true
git init
git remote add origin git@github.com:berty/berty
fi
git fetch origin master
echo $(git rev-list --count origin/master) > /tmp/master_version
[ $no_repo = true ] && rm -rf .git || true
install_retry: &install_retry
run:
name: install retry
command: |
command -v wget &>/dev/null && wget -O /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)" || true
if [ ! -f /tmp/retry ]; then command -v curl &>/dev/null && curl -L -o /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)"; fi
chmod +x /tmp/retry
/tmp/retry --version
install_go: &install_go
run:
name: install-go
command: |
if [ ! -f ~/go-install/go/bin/go ]; then
cd ~ && git clone https://github.com/udhos/update-golang
cd ~/update-golang && mkdir ~/go-install && sudo DESTINATION=~/go-install RELEASE=1.11 ./update-golang.sh
fi
echo "export PATH=~/go-install/go/bin/:~/go/bin:$PATH" >> $BASH_ENV
install_gomobile: &install_gomobile
run:
name: install gomobile
command: |
if [ ! -f ~/go/bin/gomobile ]; then
go get golang.org/x/mobile/cmd/gomobile
cd ~/go/src/golang.org/x/mobile
git remote add upstream git@github.com:sfroment/mobile
git fetch upstream
git cherry-pick af3c051e0603af005260579c432830164f68933b
go install golang.org/x/mobile/cmd/gomobile
gomobile init
fi
jobs:
lint:
<<: *golang_workspace
docker:
- image: bertychat/linter:v2
steps:
- *install_retry
- checkout
- restore_cache:
keys:
- v1-go-cache
- run:
name: fetch deps
command: |
cd core
/tmp/retry -m 3 go mod download
- run:
name: prepare CI
command: make _ci_prepare
- run:
name: lint
command: /tmp/retry -m 3 make lint
- save_cache:
key: v1-go-cache
paths:
- "/go/pkg"
generate:
docker:
- image: bertychat/protoc:v5
working_directory: /go/src/berty.tech
environment:
GOPATH: /go
steps:
- *install_retry
- checkout
- setup_remote_docker
- run:
name: make generate_local
command: |
# 1. checkout
# 2. generate prepare
# 3. generate
# 4. ignore go.mod (this file regularly changes with useless information (adding `// indirect`)
# 5. check if files changed
cd core
/tmp/retry -m 5 -t 300 sh -xec ' \
git checkout . && \
make generate_prepare clean && \
make generate_local && \
git checkout go.mod && \
git status | cat && \
git diff -w | cat && \
git diff-index -w --quiet HEAD -- \
'
# IDEA: diff-index -w is not working as expected, maybe we should ignore some of the parts of the output
# IDEA: try to pass a `goimports -w -s` on files listed in `git diff-index` output to remove whitespaces
docker.build:
docker:
- image: docker:17.05.0-ce-git
steps:
- run:
name: install ca-certificates
command: apk --no-cache add openssl
- *install_retry
- checkout
- setup_remote_docker
- restore_cache:
keys:
- v1-docker-berty
paths:
- /caches/berty.tar
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /caches/berty.tar | true
- run:
name: Build application Docker image
command: /tmp/retry -m 3 docker build --cache-from=berty -t berty .
- run:
name: Run application within Docker
command: /tmp/retry -m 3 docker run --rm berty daemon --init-only --no-p2p
- run:
name: Save Docker image layer cache
command: |
mkdir -p /caches
docker save -o /caches/berty.tar berty
- save_cache:
key: v1-docker-berty
paths:
- /caches/berty.tar
core.go.test:
<<: *golang_workspace
steps:
- *install_retry
- checkout
- restore_cache:
keys:
- v1-go-cache
- run:
name: prepare CI
command: |
make _ci_prepare
mkdir -p /tmp/test-results
go get github.com/jstemmer/go-junit-report
- run:
name: install openssl 1.0.x
command: |
sudo apt-get update
sudo apt-get install libssl1.0-dev
- run:
name: install core
command: |
cd core
BUILD_MODE="ci-${CIRCLE_BRANCH}" /tmp/retry -m 3 make install
- run:
name: berty version
command: berty --version
- run:
name: test core
command: |
cd core
TEST_SLEEP_BETWEEN_STEPS=1s TEST_OPTS="$TEST_OPTS" /tmp/retry -m 3 make test | tee /tmp/test-results/go-test-report.out
- run:
name: test gomobile
command: |
cd client/react-native/gomobile/core
/tmp/retry -m 3 go test $TEST_OPTS -v . | tee /tmp/test-results/go-test-report.out
GOARCH=386 /tmp/retry -m 3 go test -v . | tee /tmp/test-results/go-test-report.out
- run:
name: integration core
command: |
cd core
/tmp/retry -m 3 make integration
- run:
name: junit-report
command: go-junit-report < /tmp/test-results/go-test-report.out > /tmp/test-results/go-test-report.xml
- save_cache:
key: v1-go-cache
paths:
- "/go/pkg"
- run:
name: aggretate coverage
command: |
cat `find . -name profile.out` > coverage.txt
bash <(curl -s https://codecov.io/bash) -t 1eefe35e-d1a9-45f3-910d-3e84db1ec04c
- store_test_results:
path: /tmp/test-results
client.rn.node:
working_directory: ~/go/src/berty.tech
docker:
- image: circleci/node:8
steps:
- *install_retry
- checkout
- restore_cache:
key: yarn-v1-{{ checksum "client/react-native/yarn.lock" }}-{{ arch }}
- restore_cache:
key: node-v1-{{ checksum "client/react-native/package.json" }}-{{ arch }}
- run:
name: install react-native deps
command: |
cd client/react-native
/tmp/retry -m 3 make deps
- save_cache:
key: yarn-v1-{{ checksum "client/react-native/yarn.lock" }}-{{ arch }}
paths:
- ~/.cache/yarn
- save_cache:
key: node-v1-{{ checksum "client/react-native/package.json" }}-{{ arch }}
paths:
- node_modules
- persist_to_workspace:
root: ~/go/src/berty.tech
paths:
- client/react-native/common
- client/react-native/node_modules
client.rn.android:
working_directory: ~/go/src/berty.tech/client/react-native/android
environment:
FASTLANE_SKIP_UPDATE_CHECK: 1
FASTLANE_HIDE_CHANGELOG: 1
FL_BUILDLOG_PATH: /tmp/fl/log/build/android
BUILD: /tmp/fl/build
docker:
- image: bertychat/android-ci:v3
steps:
- checkout:
path: ~/go/src/berty.tech/
- attach_workspace:
at: ~/go/src/berty.tech/
- *install_retry
- run:
name: setup golang environment
command: echo "export PATH=/usr/local/go/bin/:~/go/bin:$PATH" >> $BASH_ENV
- run:
name: gomobile android build
command: |
cd ../gomobile
BUILD_MODE=ci-${CIRCLE_BRANCH} /tmp/retry -m 3 make build.android
- restore_cache:
key: v1-rn-gems-{{ checksum "~/go/src/berty.tech/client/react-native/Gemfile.lock" }}
- run:
name: install bundle
working_directory: ~/go/src/berty.tech/client/react-native
command: |
bundle check || /tmp/retry -m 3 bundle install --path vendor/bundle
- save_cache:
key: v1-rn-gems-{{ checksum "~/go/src/berty.tech/client/react-native/Gemfile.lock" }}
paths:
- ~/go/src/berty.tech/client/react-native/vendor/bundle
- run:
name: patch android repo
working_directory: ~/go/src/berty.tech/client/react-native
command: make patch.android
- run:
name: set version
working_directory: ~/go/src/berty.tech/client/react-native
command: make version.android
- run:
name: build app
working_directory: ~/go/src/berty.tech/client/react-native
command: /tmp/retry -m 3 make fastlane.android.build
- store_artifacts:
path: /tmp/fl
client.rn.ios:
working_directory: ~/go/src/berty.tech
macos:
xcode: "9.4.1"
environment:
FASTLANE_SKIP_UPDATE_CHECK: 1
FASTLANE_HIDE_CHANGELOG: 1
SCAN_OUTPUT_DIRECTORY: /tmp/fl/log/scan
GYM_OUTPUT_DIRECTORY: /tmp/fl/log/gym
FL_BUILDLOG_PATH: /tmp/fl/log/build/ios
SCAN_INCLUDE_SIMULATOR_LOGS: true
BUILD: /tmp/fl/build
shell: /bin/bash --login -o pipefail
steps:
- *install_retry
- run:
name: set Ruby version
command: echo "ruby-2.4" > ~/.ruby-version
- *master_version
- restore_cache:
key: ios-{{checksum "/tmp/master_version"}}
- checkout:
path: ~/go/src/berty.tech/
- attach_workspace:
at: ~/go/src/berty.tech/
- *install_go
- *install_gomobile
- run:
name: install core
working_directory: ~/go/src/berty.tech/client/react-native/gomobile
command: BUILD_MODE=ci-${CIRCLE_BRANCH} /tmp/retry -m 3 make build.ios
- restore_cache:
key: rn-gems-{{ checksum "~/go/src/berty.tech/client/react-native/Gemfile.lock" }}-3
- run:
name: install bundle
working_directory: ~/go/src/berty.tech/client/react-native
command: bundle check || /tmp/retry -m 3 bundle install --path vendor/bundle
- save_cache:
key: rn-gems-{{ checksum "~/go/src/berty.tech/client/react-native/Gemfile.lock" }}-3
paths:
- ~/go/src/berty.tech/client/react-native/vendor/bundle
- run:
name: set version
working_directory: ~/go/src/berty.tech/client/react-native
command: make version.ios
- run:
name: install fsevents
working_directory: ~/go/src/berty.tech/client/react-native
command: /tmp/retry -m 3 yarn add fsevents
- run:
name: build app
working_directory: ~/go/src/berty.tech/client/react-native
command: |
make fastlane.setup_circle
/tmp/retry -m 3 make fastlane.ios.adhoc
- store_artifacts:
path: /tmp/fl
client.rn.ios-beta:
working_directory: ~/go/src/berty.tech
macos:
xcode: "9.4.1"
environment:
FASTLANE_SKIP_UPDATE_CHECK: 1
FASTLANE_HIDE_CHANGELOG: 1
SCAN_OUTPUT_DIRECTORY: /tmp/flb/log/scan
GYM_OUTPUT_DIRECTORY: /tmp/flb/log/gym
FL_BUILDLOG_PATH: /tmp/flb/log/build/ios
SCAN_INCLUDE_SIMULATOR_LOGS: true
BUILD: /tmp/flb/build
shell: /bin/bash --login -o pipefail
steps:
- *install_retry
- run:
name: set Ruby version
command: echo "ruby-2.4" > ~/.ruby-version
- checkout:
path: ~/go/src/berty.tech/
- attach_workspace:
at: ~/go/src/berty.tech/
- *install_go
- *install_gomobile
- run:
name: install core
working_directory: ~/go/src/berty.tech/client/react-native/gomobile
command: BUILD_MODE=ci-${CIRCLE_BRANCH} /tmp/retry -m 3 make build.ios
- restore_cache:
key: rn-gems-{{ checksum "~/go/src/berty.tech/client/react-native/Gemfile.lock" }}-4
- run:
name: install bundle
working_directory: ~/go/src/berty.tech/client/react-native
command: bundle check || /tmp/retry -m 3 bundle install --path vendor/bundle
- save_cache:
key: rn-gems-{{ checksum "~/go/src/berty.tech/client/react-native/Gemfile.lock" }}-4
paths:
- ~/go/src/berty.tech/client/react-native/vendor/bundle
- run:
name: set version
working_directory: ~/go/src/berty.tech/client/react-native
command: make version.ios
- run:
name: install fsevents
working_directory: ~/go/src/berty.tech/client/react-native
command: /tmp/retry -m 3 yarn add fsevents
- run:
name: build app
working_directory: ~/go/src/berty.tech/client/react-native
command: |
make fastlane.setup_circle
/tmp/retry -m 3 make fastlane.ios.house
- *master_version
- save_cache:
key: ios-{{checksum "/tmp/master_version"}}
paths:
- ~/go/pkg
- ~/go/src
- ~/go-install
- store_artifacts:
path: /tmp/flb
client.rn.web:
working_directory: ~/go/src/berty.tech
docker:
- image: circleci/node:8
steps:
- *install_retry
- checkout
- attach_workspace:
at: ~/go/src/berty.tech/
- restore_cache:
key: yarn-v1-{{ checksum "client/react-native/web/yarn.lock" }}-{{ arch }}
- restore_cache:
key: node-v1-{{ checksum "client/react-native/web/package.json" }}-{{ arch }}
- run: cd client/react-native/web && /tmp/retry -m 3 yarn
- save_cache:
key: yarn-v1-{{ checksum "client/react-native/web/yarn.lock" }}-{{ arch }}
paths:
- ~/.cache/yarn
- save_cache:
key: node-v1-{{ checksum "client/react-native/web/package.json" }}-{{ arch }}
paths:
- node_modules
- run:
name: build web app
working_directory: ~/go/src/berty.tech/client/react-native/web
command: /tmp/retry -m 3 yarn build
workflows:
version: 2
build-client:
jobs:
- client.rn.node
- client.rn.android:
requires:
- client.rn.node
- client.rn.ios:
requires:
- client.rn.node
- client.rn.ios-beta:
filters:
branches:
only: master
requires:
- client.rn.node
- client.rn.web:
requires:
- client.rn.node
check-quality:
jobs:
- lint
- generate
- core.go.test
- docker.build
# todo later: build-services