-
Notifications
You must be signed in to change notification settings - Fork 59
/
config.yml
1214 lines (1168 loc) · 42.7 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
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
version: 2.1
executors:
metal:
docker:
- image: circleci/elixir:1.10.2
- image: circleci/postgres:9.6
environment:
MIX_ENV: test
POSTGRES_USER: omisego_dev
POSTGRES_PASSWORD: omisego_dev
POSTGRES_DB: omisego_test
CIRLCECI: true
working_directory: ~/src
metal_macos:
macos:
xcode: "11.0.0"
builder:
docker:
- image: omisegoimages/elixir-omg-builder:stable-20201207
working_directory: ~/src
builder_pg:
docker:
- image: omisegoimages/elixir-omg-builder:stable-20201207
- image: circleci/postgres:9.6-alpine
environment:
POSTGRES_USER: omisego_dev
POSTGRES_PASSWORD: omisego_dev
POSTGRES_DB: omisego_test
working_directory: ~/src
builder_pg_geth:
docker:
- image: omisegoimages/elixir-omg-tester:stable-20201207
- image: circleci/postgres:9.6-alpine
environment:
POSTGRES_USER: omisego_dev
POSTGRES_PASSWORD: omisego_dev
POSTGRES_DB: omisego_test
working_directory: ~/src
deployer:
docker:
- image: omisegoimages/elixir-omg-deploy:stable-20201207
working_directory: ~/src
commands:
add_rust_to_path:
description: "Add path to PATH env var"
steps:
- run:
name: Add rust to PATH env
command: echo 'export PATH=~/.cargo/bin/:$PATH' >> $BASH_ENV
install_rust:
description: "Install Rust"
steps:
- run:
name: Install Rust
command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- add_rust_to_path
setup_elixir-omg_workspace:
description: "Setup workspace"
steps:
- attach_workspace:
name: Attach workspace
at: .
docker_login:
description: login to dockerhub for private repo access
steps:
- run: printf "%s\\n" "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
make_docker_images:
description: Builds docker images
steps:
- run: make docker-watcher
- run: make docker-watcher_info
check_docker_status:
description: Installs elixir and checks if docker is healthy
steps:
- run:
name: Print docker states
command: |
docker image ls
docker-compose ps
setup_childchain:
description: "Setups Child chain for watcher tests"
steps:
# otherwise docker compose down errors with ERROR: Couldn't find env file
- run: touch localchain_contract_addresses.env
- run: docker-compose down
- run: sudo rm -rf data/
- run:
name: Setup data dir
command: |
[ -d data ] || mkdir data && chmod 777 data
- run:
name: Pull down snapshot
command: SNAPSHOT=SNAPSHOT_MIX_EXIT_PERIOD_SECONDS_20 make init_test
- run: |
echo -e "FEE_SPECS_FILE_PATH=/dev-artifacts/fee_specs.test.json\n$(cat fees_setup.env)" > fees_setup.env
echo "FEE_SPECS_FILE_PATH=/dev-artifacts/fee_specs.test.json" >> fees_setup.env
cat fees_setup.env
- run:
name: Standup Geth and Child Chain
command: docker-compose up geth childchain postgres
background: true
- run:
name: Has Childchain started?
command: |
attempt_counter=0
max_attempts=25
until $(curl --output /dev/null --silent --head --fail http://localhost:9656/alarm.get); do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Max attempts reached"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
run_test_in_docker:
description: "Quick test runs"
parameters:
test_command:
type: string
test_name:
type: string
steps:
- run:
name: "Docker run <<parameters.test_name>>"
command: |
docker run --rm -it --network=chain_net -e DOCKER=true -e CHILD_CHAIN_URL=http://172.27.0.108:9656/ -e ETHEREUM_RPC_URL=http://172.27.0.108:80 -e DOCKER_GETH=true -e TEST_DATABASE_URL=postgresql://omisego_dev:[email protected]:5432/omisego_test -e SHELL=/bin/sh -v $(pwd):/app --entrypoint /bin/sh omisegoimages/elixir-omg-builder:stable-20201207 -c "cd /app && mix deps.get && <<parameters.test_command>>"
install_elixir:
description: Installs elixir and checks if docker is healthy
steps:
- restore_cache:
key: v2-asdf-install
- run:
name: Install Erlang and Elixir
command: |
[ -d ~/.asdf-vm ] || git clone https://github.com/asdf-vm/asdf.git ~/.asdf-vm --branch v0.8.0
echo 'source ~/.asdf-vm/asdf.sh' >> $BASH_ENV
source $BASH_ENV
asdf plugin-add erlang || asdf plugin-update erlang
asdf plugin-add elixir || asdf plugin-update elixir
asdf plugin-add rust || asdf plugin-update rust
asdf install
no_output_timeout: 2400
- install_rust
- save_cache:
key: v2-asdf-install
paths:
- ~/.asdf
- ~/.asdf-vm
- run: make install-hex-rebar
- restore_cache:
key: v2-mix-specs-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
install_deps:
description: Install linux dependencies
steps:
- run:
name: Install deps
command: |
set -e
sudo killall dpkg || true &&
sudo rm /var/lib/dpkg/lock || true &&
sudo rm /var/cache/apt/archives/lock || true &&
sudo dpkg --configure -a || true &&
sudo apt-get update &&
./bin/setup
no_output_timeout: 2400
install_and_setup_gcloud:
description: Installs and sets up gcloud to fetch feefeed
steps:
- run: |
export LD_LIBRARY_PATH=/usr/local/lib
export CLOUDSDK_PYTHON=/usr/bin/python
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-323.0.0-linux-x86_64.tar.gz -O gcloud-sdk.tar.gz
tar zxf gcloud-sdk.tar.gz google-cloud-sdk
mv google-cloud-sdk ~/.google-cloud-sdk
~/.google-cloud-sdk/install.sh --quiet
echo $GCP_KEY_FILE | gcloud auth activate-service-account $GCP_SERVICE_EMAIL --key-file=-
gcloud --quiet config set project ${GCP_PROJECT}
gcloud --quiet config set compute/zone ${GCP_ZONE}
gcloud --quiet auth configure-docker
jobs:
barebuild:
executor: metal
environment:
MIX_ENV: test
steps:
- checkout
- run: make install-hex-rebar
- run: echo 'export PATH=~/.cargo/bin:$PATH' >> $BASH_ENV
- run:
command: ./bin/setup
no_output_timeout: 2400
- run: make deps-elixir-omg
- run: ERLANG_ROCKSDB_BUILDOPTS='-j 2' make build-test
- run: mix test
- run:
name: Integration Tests
command: |
# Slow, serial integration test, run nightly. Here to make sure the standard `mix test --only integration ` works
export SHELL=/bin/bash
mix test --only integration
no_output_timeout: 30m
barebuild_macos:
executor: metal_macos
environment:
MIX_ENV: test
steps:
- checkout
- run: echo 'export PATH=~/.cargo/bin:$PATH' >> $BASH_ENV
- run: |
brew install postgres
initdb /usr/local/var/postgres/data
pg_ctl -D /usr/local/var/postgres/data -l /tmp/postgresql.log start
psql template1 \<<EOF
CREATE USER omisego_dev WITH CREATEDB ENCRYPTED PASSWORD 'omisego_dev';
CREATE DATABASE omisego_dev OWNER 'omisego_dev';
EOF
- run: |
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.7.4
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile
source ~/.bash_profile
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin-add rust || asdf plugin-update rust
asdf install
- run: make init_test
- install_rust
- run:
command: ./bin/setup
no_output_timeout: 2400
- run: make deps-elixir-omg
- run: ERLANG_ROCKSDB_BUILDOPTS='-j 2' make build-test
- run: mix test
build:
executor: builder
environment:
MIX_ENV: test
steps:
- checkout
- restore_cache:
key: v1-rocksdb-cache-{{ checksum "mix.lock" }}
- run: make init_test
- run: make deps-elixir-omg
- run: ERLANG_ROCKSDB_BUILDOPTS='-j 2' make build-test
- save_cache:
key: v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
paths: "_build_docker"
- save_cache:
key: v1-rocksdb-cache-{{ checksum "mix.lock" }}
paths:
- "deps_docker/"
- "deps_docker/rocksdb"
- "_build_docker/test/lib/rocksdb/"
- "_build_docker/test/dev/rocksdb/"
- "deps/"
- "_build/test/lib/rocksdb/"
- "_build/test/dev/rocksdb/"
- persist_to_workspace:
name: Persist workspace
root: ~/src
paths:
- .circleci
- dialyzer.ignore-warnings
- .formatter.exs
- _build_docker
- .credo.exs
- apps
- bin
- config
- deps_docker
- doc
- mix.exs
- mix.lock
- deploy_and_populate.sh
- launcher.py
- docker-compose.yml
- rel/
- VERSION
- .git
- Makefile
- priv
- data
- snapshots.env
- snapshot_reorg.env
- nginx.conf
- contract_addresses_template.env
- localchain_contract_addresses.env
audit_deps:
executor: builder
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- run: mix deps.audit
lint:
executor: builder
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- run: make install-hex-rebar
- run: mix do compile --warnings-as-errors --force, credo --ignore-checks Credo.Check.Readability.SinglePipe, format --check-formatted --dry-run
- run:
command: |
export SHELL=/bin/bash
set +eo pipefail
_counter=$(mix credo --only Credo.Check.Readability.SinglePipe | grep -c "Use a function call when a pipeline is only one function long")
echo "Current Credo.Check.Readability.SinglePipe occurrences:"
echo $_counter
if [ $_counter -gt 273 ]; then
echo "Have you been naughty or nice? Find out if Santa knows."
exit 1
fi
sobelow:
executor: builder_pg
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- run: mix archive.install hex sobelow --force
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r .
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_bus
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_db
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_eth
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_status
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_utils
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_watcher
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_watcher_info
- run: mix sobelow --exit --skip --ignore Config.HTTPS -r apps/omg_watcher_rpc --router apps/omg_watcher_rpc/lib/web/router.ex
watcher_coveralls_and_integration_tests:
executor: builder_pg_geth
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
- run:
name: Compile
command: mix compile
- run:
name: Integration Tests & Coveralls Part Watcher
command: |
# Don't submit coverage report for forks, but let the build succeed
export SHELL=/bin/bash
if [[ -z "$COVERALLS_REPO_TOKEN" ]]; then
mix coveralls.html --parallel --umbrella --include watcher --exclude watcher_info --exclude common --exclude test
else
mix coveralls.circle --parallel --umbrella --include watcher --exclude watcher_info --exclude common --exclude test ||
# if mix failed, then coveralls_report won't run, so signal done here and return original exit status
(retval=$? && curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$CIRCLE_WORKFLOW_WORKSPACE_ID&payload[status]=done" && exit $retval)
fi
watcher_mix_based_childchain:
machine:
image: ubuntu-2004:202010-01
environment:
MIX_ENV: test
steps:
- checkout
- restore_cache:
keys:
- v2-mix-cache-test-compile-watcher_mix_based_childchain-{{ checksum "mix.lock" }}-{{ .Branch }}
- run: rm -rf _build_docker/test/lib/omg*
- run:
name: Setup dirs
command: |
[ -d _build_docker ] || mkdir _build_docker && sudo chmod -R 777 _build_docker
- run:
name: Setup dirs deps_docker
command: |
[ -d deps_docker ] || mkdir deps_docker && sudo chmod -R 777 deps_docker
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/invalid_exit_1_test.exs --include mix_based_child_chain"
test_name: "invalid_exit_1_test.exs"
- save_cache:
key: v2-mix-cache-test-compile-watcher_mix_based_childchain-{{ checksum "mix.lock" }}-{{ .Branch }}
paths:
- deps_docker
- _build_docker
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/in_flight_exit_test_3_test.exs --include mix_based_child_chain"
test_name: "in_flight_exit_test_3_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/in_flight_exit_test_2_test.exs --include mix_based_child_chain"
test_name: "in_flight_exit_test_2_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/in_flight_exit_test_1_test.exs --include mix_based_child_chain"
test_name: "in_flight_exit_test_1_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/in_flight_exit_test_4_test.exs --include mix_based_child_chain"
test_name: "in_flight_exit_test_4_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/in_flight_exit_test.exs --include mix_based_child_chain"
test_name: "in_flight_exit_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/invalid_exit_2_test.exs --include mix_based_child_chain"
test_name: "invalid_exit_2_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/block_getter_1_test.exs --include mix_based_child_chain"
test_name: "block_getter_1_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/block_getter_2_test.exs --include mix_based_child_chain"
test_name: "block_getter_2_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/block_getter_3_test.exs --include mix_based_child_chain"
test_name: "block_getter_3_test.exs"
- setup_childchain
- run_test_in_docker:
test_command: "mix test test/omg_watcher/integration/block_getter_4_test.exs --include mix_based_child_chain"
test_name: "block_getter_4_test.exs"
watcher_info_coveralls_and_integration_tests:
executor: builder_pg_geth
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
- run:
name: Compile
command: mix compile
- run:
name: Integration Tests & Coveralls Part Watcher
command: |
# Don't submit coverage report for forks, but let the build succeed
export SHELL=/bin/bash
if [[ -z "$COVERALLS_REPO_TOKEN" ]]; then
mix coveralls.html --parallel --umbrella --include watcher_info --exclude watcher --exclude common --exclude test
else
mix coveralls.circle --parallel --umbrella --include watcher_info --exclude watche --exclude common --exclude test ||
# if mix failed, then coveralls_report won't run, so signal done here and return original exit status
(retval=$? && curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$CIRCLE_WORKFLOW_WORKSPACE_ID&payload[status]=done" && exit $retval)
fi
common_coveralls_and_integration_tests:
executor: builder_pg_geth
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
- run:
name: Compile
command: mix compile
- run:
name: Integration Tests & Coveralls Part Common
command: |
# Don't submit coverage report for forks, but let the build succeed
export SHELL=/bin/bash
if [[ -z "$COVERALLS_REPO_TOKEN" ]]; then
mix coveralls.html --parallel --umbrella --include common --exclude watcher --exclude watcher_info --exclude test
else
mix coveralls.circle --parallel --umbrella --include common --exclude watcher --exclude watcher_info --exclude test ||
# if mix failed, then coveralls_report won't run, so signal done here and return original exit status
(retval=$? && curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$CIRCLE_WORKFLOW_WORKSPACE_ID&payload[status]=done" && exit $retval)
fi
test:
executor: builder_pg
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
- run:
name: Compile
command: mix compile
- run:
name: Test
command: |
# Don't submit coverage report for forks, but let the build succeed
export SHELL=/bin/bash
if [[ -z "$COVERALLS_REPO_TOKEN" ]]; then
mix coveralls.html --parallel --umbrella --exclude common --exclude watcher --exclude watcher_info
else
mix coveralls.circle --parallel --umbrella --exclude common --exclude watcher --exclude watcher_info ||
# if mix failed, then coveralls_report won't run, so signal done here and return original exit status
(retval=$? && curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$CIRCLE_WORKFLOW_WORKSPACE_ID&payload[status]=done" && exit $retval)
fi
property_tests:
executor: builder_pg_geth
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
- run:
name: Compile
command: mix compile
- run:
name: Property Test
command: |
export SHELL=/bin/bash
# no coverage calculation, coverage is on the other tests
mix test --only property
integration_tests:
executor: builder_pg_geth
environment:
MIX_ENV: test
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v2-mix-cache-test-compile-{{ checksum "mix.lock" }}-{{ .Branch }}-{{ .Revision }}
- run:
name: Compile
command: mix compile
- install_rust
- run:
name: Integration Tests
command: |
# Slow, serial integration test, run nightly. Here to make sure the standard `mix test --only integration` works
export SHELL=/bin/bash
mix test --only integration
dialyzer:
executor: builder_pg
steps:
- setup_elixir-omg_workspace
- restore_cache:
keys:
- v3-plt-cache-{{ ".tool-versions" }}-{{ checksum "mix.lock" }}
- v3-plt-cache-{{ ".tool-versions" }}-{{ checksum "mix.exs" }}
- v3-plt-cache-{{ ".tool-versions" }}
- run:
name: Unpack PLT cache
command: |
mkdir -p _build_docker/test
cp plts/dialyxir*.plt _build_docker/test/ || true
mkdir -p ~/.mix
cp plts/dialyxir*.plt ~/.mix/ || true
- run: mix dialyzer --plt
- run:
name: Pack PLT cache
command: |
mkdir -p plts
cp _build_docker/test/dialyxir*.plt plts/
cp ~/.mix/dialyxir*.plt plts/
- save_cache:
key: v3-plt-cache-{{ ".tool-versions" }}-{{ checksum "mix.lock" }}
paths:
- plts
- save_cache:
key: v3-plt-cache-{{ ".tool-versions" }}-{{ checksum "mix.exs" }}
paths:
- plts
- save_cache:
key: v3-plt-cache-{{ ".tool-versions" }}
paths:
- plts
- run: mix dialyzer --format short
test_docker_compose_release:
machine:
image: ubuntu-2004:202010-01
environment:
SNAPSHOT: SNAPSHOT_MIX_EXIT_PERIOD_SECONDS_120
LD_LIBRARY_PATH: /usr/local/lib
CLOUDSDK_PYTHON: /usr/bin/python
CHILD_CHAIN_URL: "http://localhost:9656"
FEE_CLAIMER_ADDRESS: "0x3b9f4c1dd26e0be593373b1d36cee2008cbeb837"
parallelism: 5
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- run:
name: Setup data dir
command: |
[ -d data ] || mkdir data && chmod 777 data
- docker_login
- make_docker_images
- install_and_setup_gcloud
- run:
name: Start daemon services
command: make cabbage-start-services
- run:
name: Log daemon services
command: make cabbage-logs
background: true
- check_docker_status
- install_elixir
- run: sh .circleci/status.sh
- run:
name: Run specs
command: |
cd priv/cabbage
make install
make generate_api_code
mix deps.get
- run:
name: Run specs
working_directory: ~/project/priv/cabbage
environment:
MIX_ENV: test
command: |
mix compile
- run:
name: Run specs
working_directory: ~/project/priv/cabbage
command: |
TESTFILES=$(circleci tests glob "apps/itest/test/itest/*_test.exs" | circleci tests split --split-by=timings --show-counts)
echo ${TESTFILES}
mix test ${TESTFILES} --trace
- store_test_results:
path: ~/project/priv/cabbage/_build/test/lib/itest/
test_docker_compose_performance:
description: "These are not actually performance tests, we're checking if the scripts work"
machine:
image: ubuntu-2004:202010-01
environment:
PERF_IMAGE_NAME: "omisego/perf:latest"
STATIX_TAG: "env:perf_circleci"
LD_LIBRARY_PATH: /usr/local/lib
CLOUDSDK_PYTHON: /usr/bin/python
steps:
- checkout
- run:
name: Setup data dir
command: |
[ -d data ] || mkdir data && chmod 777 data
- docker_login
- make_docker_images
- install_and_setup_gcloud
- run:
name: Build perf docker image
command: make docker-perf IMAGE_NAME=$PERF_IMAGE_NAME
- install_elixir
- run:
name: Start daemon services
command: |
cd priv/perf
make start-services
- run:
name: docker services logs
background: true
command: |
cd priv/perf
make log-services
- run: sh .circleci/status.sh
- run:
name: Run load test
command: |
cd priv/perf
make init
export $(cat ../../localchain_contract_addresses.env | xargs)
make test
- run:
name: Show help information
command: docker run -it $PERF_IMAGE_NAME mix run -e "LoadTest.TestRunner.run()" -- help
- run:
name: Run perf smoke test (deposits)
command: |
docker run -it --env-file ./localchain_contract_addresses.env -e FEE_AMOUNT=1 --env DD_API_KEY --env DD_APP_KEY --env STATIX_TAG --network host $PERF_IMAGE_NAME mix run -e "LoadTest.TestRunner.run()" -- "deposits" 1 200
- run:
name: Run perf smoke test (transactions)
command: |
docker run -it --env-file ./localchain_contract_addresses.env -e FEE_AMOUNT=1 --env DD_API_KEY --env DD_APP_KEY --env STATIX_TAG --network host $PERF_IMAGE_NAME mix run -e "LoadTest.TestRunner.run()" -- "transactions" 1 200
- run:
name: (Perf) Format generated code and check for warnings
command: |
cd priv/perf
# run format ONLY on formatted code so that it cleans up quoted atoms because
# we cannot exclude folders to --warnings-as-errors
mix format apps/*_api/lib/*_api/model/*.ex
export $(cat ../../localchain_contract_addresses.env | xargs)
make format-code-check-warnings
- save_cache:
key: v2-mix-specs-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths:
- "priv/perf/deps"
- run:
name: (Perf) Credo and formatting
command: |
cd priv/perf
mix do credo, format --check-formatted --dry-run
test_docker_compose_reorg:
machine:
image: ubuntu-2004:202010-01
environment:
REORG: true
LD_LIBRARY_PATH: /usr/local/lib
CLOUDSDK_PYTHON: /usr/bin/python
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- run:
name: Setup data dir
command: |
[ -d data1 ] || mkdir data1 && chmod 777 data1
[ -d data2 ] || mkdir data2 && chmod 777 data2
[ -d data ] || mkdir data && chmod 777 data
- docker_login
- make_docker_images
- install_and_setup_gcloud
- run:
name: Start daemon services
command: |
make init_test_reorg
cp ./localchain_contract_addresses.env ./priv/cabbage/apps/itest/localchain_contract_addresses.env
docker-compose -f docker-compose.yml -f docker-compose.reorg.yml -f docker-compose.specs.yml up -d || (START_RESULT=$?; docker-compose logs; exit $START_RESULT;)
- run:
name: Log daemon services
command: make cabbage-logs-reorg
background: true
- check_docker_status
- install_elixir
- run: sh .circleci/status.sh
- run:
name: Print watcher logs
command: make cabbage-reorg-watcher-logs
background: true
- run:
name: Print watcher_info logs
command: make cabbage-reorg-watcher_info-logs
background: true
- run:
name: Print childchain logs
command: make cabbage-reorg-childchain-logs
background: true
- run:
name: Print geth logs
command: make cabbage-reorg-geth-logs
background: true
- run:
name: Print reorg logs
command: make cabbage-reorgs-logs
background: true
- run:
name: Run specs
command: |
cd priv/cabbage
make install
make generate_api_code
mix deps.get
mix test --only deposit --trace
no_output_timeout: 30m
test_barebone_release:
machine:
image: ubuntu-2004:202010-01
environment:
TERM: xterm-256color
LD_LIBRARY_PATH: /usr/local/lib
CLOUDSDK_PYTHON: /usr/bin/python
steps:
- checkout
- run:
name: "Pull Submodules"
command: |
git submodule init
git submodule update --remote
- run: echo 'export PATH=~/.cargo/bin:$PATH' >> $BASH_ENV
- install_and_setup_gcloud
- docker_login
- run:
name: Start geth, postgres, feefeed and pull in blockchain snapshot
command: make start-services
background: true
- run: echo 'export PATH=~/.cargo/bin:$PATH' >> $BASH_ENV
- install_elixir
- install_deps
- run: make install-hex-rebar
- restore_cache:
key: v1-dev-release-cache-{{ checksum "mix.lock" }}
- run:
name: Compile
command: |
set -e
make deps-elixir-omg
mix compile
no_output_timeout: 2400
- save_cache:
key: v1-dev-release-cache-{{ checksum "mix.lock" }}
paths:
- "deps_docker/"
- "deps/"
- "_build/dev/"
- "_build/dev/"
- run:
name: Run Watcher
command: |
set -e
make start-watcher OVERRIDING_START=start_iex OVERRIDING_VARIABLES=./bin/variables_test_barebone
background: true
no_output_timeout: 2400
- run:
name: Run Watcher Info
command: |
set -e
make start-watcher_info OVERRIDING_START=start_iex OVERRIDING_VARIABLES=./bin/variables_test_barebone
background: true
no_output_timeout: 2400
- run:
name: Print docker and process states
command: |
docker ps
ps axww | grep watcher
ps axww | grep watcher_info
ps axww | grep child_chain
- run:
name: Has Watcher started?
command: |
attempt_counter=0
max_attempts=25
until $(curl --output /dev/null --silent --head --fail http://localhost:7434/alarm.get); do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Max attempts reached"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
- run:
name: Has Watcher Info started?
command: |
attempt_counter=0
max_attempts=25
until $(curl --output /dev/null --silent --head --fail http://localhost:7534/alarm.get); do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Max attempts reached"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
publish_watcher:
machine:
image: ubuntu-2004:202010-01
environment:
WATCHER_IMAGE_NAME: "omisego/watcher"
steps:
- checkout
- run: make docker-watcher WATCHER_IMAGE_NAME=$WATCHER_IMAGE_NAME
- run:
name: "cp release"
command: |
mkdir current_release/
cp _build_docker/prod/watcher-$(git describe --tags).tar.gz current_release/
md5sum current_release/watcher-$(git describe --tags).tar.gz | awk '{print $1}' >> current_release/md5
- store_artifacts:
path: current_release/
- run: IMAGE_NAME=$WATCHER_IMAGE_NAME sh .circleci/ci_publish.sh
publish_perf:
machine:
image: ubuntu-2004:202010-01
environment:
PERF_IMAGE_NAME: "omisego/perf"
steps:
- checkout
- run: make docker-perf IMAGE_NAME=$PERF_IMAGE_NAME
- run: IMAGE_NAME=$PERF_IMAGE_NAME sh .circleci/ci_publish.sh
publish_watcher_info:
machine:
image: ubuntu-2004:202010-01
environment:
WATCHER_INFO_IMAGE_NAME: "omisego/watcher_info"
steps:
- checkout
- run: make docker-watcher_info WATCHER_INFO_IMAGE_NAME=$WATCHER_INFO_IMAGE_NAME
- run:
name: "cp release"
command: |
mkdir current_release/
cp _build_docker/prod/watcher_info-$(git describe --tags).tar.gz current_release/
md5sum current_release/watcher_info-$(git describe --tags).tar.gz | awk '{print $1}' >> current_release/md5
- store_artifacts:
path: current_release/
- run: IMAGE_NAME=$WATCHER_INFO_IMAGE_NAME sh .circleci/ci_publish.sh
increase_chart_version_watcher_master:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher
HELM_CHART_REPO: helm-development
UPDATE_DEV: true
steps:
- checkout
- run: APP_VERSION="$(echo "$CIRCLE_SHA1" | head -c 7)" sh .circleci/ci_increase_chart_version.sh
increase_chart_version_watcher_info_master:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher-info
HELM_CHART_REPO: helm-development
UPDATE_DEV: true
steps:
- checkout
- run: APP_VERSION="$(echo "$CIRCLE_SHA1" | head -c 7)" sh .circleci/ci_increase_chart_version.sh
increase_chart_version_watcher_release:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher
HELM_CHART_REPO: helm-development
UPDATE_DEV: false
steps:
- checkout
- run: APP_VERSION="${CIRCLE_TAG#*v}" sh .circleci/ci_increase_chart_version.sh
increase_chart_version_watcher_info_release:
docker:
- image: cimg/base:2020.01
environment:
CHART_NAME: watcher-info
HELM_CHART_REPO: helm-development
UPDATE_DEV: false
steps:
- checkout
- run: APP_VERSION="${CIRCLE_TAG#*v}" sh .circleci/ci_increase_chart_version.sh
release:
docker:
- image: node:15.2.1
steps:
- checkout
- run: npx -y [email protected]
coveralls_report:
docker:
- image: omisegoimages/elixir-omg-circleci:v1.8-20190129-02
environment:
MIX_ENV: test
steps:
- run:
name: Tell coveralls.io build is done
command: curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$CIRCLE_WORKFLOW_WORKSPACE_ID&payload[status]=done"
notify_services:
executor: builder_pg
steps:
- run:
name: Send development deployment markers
command: |
curl -X POST -H 'Content-type: application/json' -d '{"title": "Starting Service", "text": "Starting with git SHA '"$CIRCLE_SHA1"'", "alert_type": "info" }' 'https://app.datadoghq.com/api/v1/events?api_key='"$DD_API_KEY"''
curl -X POST -H 'Content-type: application/json' -H 'Authorization: Bearer '"$SENTRY_TOKEN"'' -d '{"projects": ["elixir-omg"], "ref": "'"$CIRCLE_SHA1"'", "version": "Watcher-ChildChain-'"$CIRCLE_SHA1"'"}' 'https://sentry.io/api/0/organizations/omisego/releases/'