@@ -13,11 +13,18 @@ commands:
1313 min_exit_period :
1414 type : integer
1515 description : " The value used for plasma contracts deployment"
16+ docker_compose_command :
17+ type : string
18+ description : " Which docker compose files should we use?"
19+ vault :
20+ type : string
21+ default : " false"
22+ description : " True/false"
1623 steps :
1724 - run :
1825 name : Get Plasma Deployer image and standup geth and deploy contracts
26+ working_directory : ~/project/contracts
1927 command : |
20- set -xe
2128 IMAGE_NAME=elixir-omg-tester-plasma-deployer
2229 if [ "$CIRCLE_BRANCH" = "master" ]; then
2330 IMAGE_DATE="$(date -u +%Y%m%d)"
@@ -26,33 +33,43 @@ commands:
2633 IMAGE_GIT=$(git rev-parse --short HEAD)
2734 TAG="$IMAGE_NAME:dev-$IMAGE_GIT"
2835 fi
29- cd contracts/
30- CONTRACT_SHA=$(cat ../tester/CONTRACT_SHA)
31- MIN_EXIT_PERIOD=<< parameters.min_exit_period >> IMAGE=${TAG} docker-compose up -d
32- ### in the mean time, install gcloud requirements
33- wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-272.0.0-linux-x86_64.tar.gz -O gcloud-sdk.tar.gz
34- tar zxf gcloud-sdk.tar.gz google-cloud-sdk
35- mv google-cloud-sdk ~/.google-cloud-sdk
36- ~/.google-cloud-sdk/install.sh --quiet
36+ echo 'export TAG='${TAG} >> $BASH_ENV
37+ # this docker compose up needs to be above the gcloud login because the credentials are different!
38+ MIN_EXIT_PERIOD=<< parameters.min_exit_period >> IMAGE=${TAG} << parameters.docker_compose_command >>
3739 echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
3840 gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
3941 gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
40- ### done installing gcloud requirements
41- ### cleanup
42- rm -rf ~/.google-cloud-sdk
43- sleep 4m
42+ - run :
43+ name : Docker logs
44+ working_directory : ~/project/contracts
45+ background : true
46+ command : |
47+ docker-compose logs -f
48+ - run :
49+ name : Wait for contracts
50+ command : |
51+ sleep 5m
4452 # wait until we're UP
4553 for i in {1..60}; do
4654 if [ "$(curl localhost:8000/contracts)" ]; then
4755 break
4856 fi;
4957 sleep 1
50- done
51- # stop geth in docker so that we can snapshot
58+ done
59+ - run :
60+ name : Stop nodes
61+ working_directory : ~/project/contracts
62+ command : |
63+ echo "stop geth in docker so that we can snapshot"
5264 docker exec -it $(docker ps -aqf "name=geth") /bin/sh -c "pkill -INT geth"
53- # ipc is not for cp
65+ docker stop $(docker ps -aqf "name=vault_server")
5466 sudo rm -f data/geth.ipc
55- TAR_NAME=$(echo data-${TAG}-MIN_EXIT_PERIOD-<< parameters.min_exit_period >>-PLASMA_CONTRACTS_SHA-${CONTRACT_SHA}.tar.gz | sed 's/:/-/')
67+ - run :
68+ name : Snapshot
69+ working_directory : ~/project/contracts
70+ command : |
71+ CONTRACT_SHA=$(cat ../tester/CONTRACT_SHA)
72+ TAR_NAME=$(echo data-${TAG}-MIN_EXIT_PERIOD-<< parameters.min_exit_period >>-PLASMA_CONTRACTS_SHA-${CONTRACT_SHA}-VAULT-<< parameters.vault >>.tar.gz | sed 's/:/-/')
5673 echo ${TAR_NAME}
5774 # for every key in object db.json create a file
5875 # where the key is the name of the file and the content of the file is it's value
@@ -61,12 +78,13 @@ commands:
6178 for i in "${!KEYS[@]}"; do
6279 echo $(cat plasma-contracts/build/db.json | jq -r '.contracts' | jq -r '.'${KEYS[i]} | tr -d '"') > plasma-contracts/build/"${KEYS[i]}"
6380 done
64- sudo tar czf ${TAR_NAME} data/geth plasma-contracts/contracts/ plasma-contracts/build/* ../tester/CONTRACT_SHA
81+ # at this point we snapshot folders we're interested in
82+ sudo tar czf ${TAR_NAME} data/geth plasma-contracts/contracts/ plasma-contracts/build/* ../tester/CONTRACT_SHA immutability/config/
6583 export BOTO_CONFIG=/dev/null
6684 gsutil cp ${TAR_NAME} gs://circleci-docker-artifacts
6785 echo "https://storage.googleapis.com/circleci-docker-artifacts/${TAR_NAME}"
6886 PLASMA_CONTRACTS=$(curl localhost:8000/contracts)
69- DATA=$(echo "Contracts snapshotted with MIN_EXIT_PERIOD for SHA ( ${CONTRACT_SHA} ): << parameters.min_exit_period >>.\r\n Snapshot located at: \r\n https://storage.googleapis.com/circleci-docker-artifacts/${TAR_NAME} \r\n Contract addresses: \r\n ${PLASMA_CONTRACTS} " | jq -Rs '.')
87+ DATA=$(echo "Contracts snapshotted with MIN_EXIT_PERIOD for SHA ( ${CONTRACT_SHA} ): << parameters.min_exit_period >>. Vault: << parameters.vault >> \r\n Snapshot located at: \r\n https://storage.googleapis.com/circleci-docker-artifacts/${TAR_NAME} \r\n Contract addresses: \r\n ${PLASMA_CONTRACTS} " | jq -Rs '.')
7088 if [ "$CIRCLE_BRANCH" = "master" ]; then
7189 # append the data you would usually post as a comment to a file and create a release out of this file
7290 echo ${DATA} >> /tmp/release
@@ -75,7 +93,10 @@ commands:
7593 curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST -d "{\"body\": ${DATA} }" "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/issues/${CIRCLE_PULL_REQUEST##*/}/comments"
7694 fi
7795 ls data/geth
78- docker-compose down && sudo rm -rf data/geth/chaindata data/geth/LOCK data/geth/lightchaindata data/geth/nodekey data/geth/nodes data/geth/transactions.rlp
96+ docker-compose down
97+ sudo rm -rf data/geth/chaindata data/geth/LOCK data/geth/lightchaindata data/geth/nodekey data/geth/nodes data/geth/transactions.rlp
98+ sudo rm -rf immutability/config/data
99+ sudo rm -rf immutability/config/ca.crt immutability/config/ca.key immutability/config/ca.srl immutability/config/my-service.crt immutability/config/my-service.csr immutability/config/my-service.key immutability/config/openssl.cnf immutability/config/unseal.json
79100
80101 snapshot_reorg :
81102 description : Deploy contracts to Geth via docker-compose with parametrized MIN_EXIT_PERIOD and expose addresses and snapshot URL
@@ -86,9 +107,8 @@ commands:
86107 steps :
87108 - run :
88109 name : Get Plasma Deployer image and standup geth and deploy contracts
89- no_output_timeout : 40m
110+ working_directory : ~/project/contracts_reorg
90111 command : |
91- set -xe
92112 IMAGE_NAME=elixir-omg-tester-plasma-deployer
93113 if [ "$CIRCLE_BRANCH" = "master" ]; then
94114 IMAGE_DATE="$(date -u +%Y%m%d)"
@@ -97,34 +117,44 @@ commands:
97117 IMAGE_GIT=$(git rev-parse --short HEAD)
98118 TAG="$IMAGE_NAME:dev-$IMAGE_GIT"
99119 fi
100- cd contracts_reorg/
101- CONTRACT_SHA=$(cat ../tester/CONTRACT_SHA)
120+ echo 'export TAG='${TAG} >> $BASH_ENV
121+ # this docker compose up needs to be above the gcloud login because the credentials are different!
102122 MIN_EXIT_PERIOD=<< parameters.min_exit_period >> IMAGE=${TAG} docker-compose up -d
103- timeout 25m docker-compose logs --follow || true
104-
105- ### in the mean time, install gcloud requirements
106- wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-272.0.0-linux-x86_64.tar.gz -O gcloud-sdk.tar.gz
107- tar zxf gcloud-sdk.tar.gz google-cloud-sdk
108- mv google-cloud-sdk ~/.google-cloud-sdk
109- ~/.google-cloud-sdk/install.sh --quiet
110123 echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
111124 gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
112125 gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE}
113- ### done installing gcloud requirements
114- ### cleanup
115- rm -rf ~/.google-cloud-sdk
126+ - run : timeout 25m docker-compose logs --follow || true
127+ - run :
128+ name : Docker logs
129+ working_directory : ~/project/contracts_reorg
130+ background : true
131+ command : |
132+ docker-compose logs -f
133+ - run :
134+ name : Wait for contracts
135+ no_output_timeout : 50m
136+ command : |
137+ sleep 30m
116138 # wait until we're UP
117139 for i in {1..60}; do
118140 if [ "$(curl localhost:8000/contracts)" ]; then
119141 break
120142 fi;
121- sleep 1
122- done
123- # stop geth in docker so that we can snapshot
143+ sleep 10
144+ done
145+ - run :
146+ name : Stop nodes
147+ working_directory : ~/project/contracts_reorg
148+ command : |
149+ echo "stop geth in docker so that we can snapshot"
124150 docker exec -it $(docker ps -aqf "name=node-1") /bin/sh -c "pkill -INT geth"
125- # ipc is not for cp
126151 sudo rm -f data/geth.ipc
127152 sudo rm -f data/geth/nodekey
153+ - run :
154+ name : Get Plasma Deployer image and standup geth and deploy contracts
155+ no_output_timeout : 40m
156+ working_directory : ~/project/contracts_reorg
157+ command : |
128158 TAR_NAME=$(echo data-${TAG}-MIN_EXIT_PERIOD-<< parameters.min_exit_period >>-PLASMA_CONTRACTS_SHA-${CONTRACT_SHA}-reorg.tar.gz | sed 's/:/-/')
129159 echo ${TAR_NAME}
130160 # for every key in object db.json create a file
@@ -148,7 +178,10 @@ commands:
148178 curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST -d "{\"body\": ${DATA} }" "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/issues/${CIRCLE_PULL_REQUEST##*/}/comments"
149179 fi
150180 ls data/geth
151- docker-compose down && sudo rm -rf data/geth/chaindata data/geth/LOCK data/geth/lightchaindata data/geth/nodekey data/geth/nodes data/geth/transactions.rlp
181+ docker-compose down
182+ sudo rm -rf data/geth/chaindata data/geth/LOCK data/geth/lightchaindata data/geth/nodekey data/geth/nodes data/geth/transactions.rlp
183+ sudo rm -rf immutability/config/data
184+ sudo rm -rf immutability/config/ca.crt immutability/config/ca.key immutability/config/ca.srl immutability/config/my-service.crt immutability/config/my-service.csr immutability/config/my-service.key immutability/config/openssl.cnf immutability/config/unseal.json
152185
153186 docker_import :
154187 description : " Load Docker acrhive from the given directory"
@@ -479,12 +512,38 @@ jobs:
479512 steps :
480513 - checkout
481514 - attach_workspace : *attach_workspace
515+ - run :
516+ name : Login so that we can pull Vault
517+ command : |
518+ echo $GCLOUD_SERVICE_KEY_VAULT | gcloud auth activate-service-account --key-file=-
519+ gcloud auth configure-docker --quiet
520+ - run : docker login -u $DOCKER_USER -p $DOCKER_PASS
521+ - run :
522+ name : Setup data dir
523+ working_directory : ~/project/contracts
524+ command : |
525+ sudo chmod -R 777 immutability/config/
482526 - snapshot :
483527 min_exit_period : 20
528+ docker_compose_command : " docker-compose up -d"
484529 - snapshot :
485530 min_exit_period : 120
531+ docker_compose_command : " docker-compose up -d"
486532 - snapshot :
487533 min_exit_period : 240
534+ docker_compose_command : " docker-compose up -d"
535+ - snapshot :
536+ min_exit_period : 20
537+ docker_compose_command : " docker-compose -f docker-compose.yml -f docker-compose.vault.yml up -d"
538+ vault : " true"
539+ - snapshot :
540+ min_exit_period : 120
541+ docker_compose_command : " docker-compose -f docker-compose.yml -f docker-compose.vault.yml up -d"
542+ vault : " true"
543+ - snapshot :
544+ min_exit_period : 240
545+ docker_compose_command : " docker-compose -f docker-compose.yml -f docker-compose.vault.yml up -d"
546+ vault : " true"
488547 - run :
489548 name : Gather all the snapshots and publish a release
490549 command : |
@@ -504,6 +563,17 @@ jobs:
504563 steps :
505564 - checkout
506565 - attach_workspace : *attach_workspace
566+ - run :
567+ name : Login so that we can pull Vault
568+ command : |
569+ echo $GCLOUD_SERVICE_KEY_VAULT | gcloud auth activate-service-account --key-file=-
570+ gcloud auth configure-docker --quiet
571+ - run : docker login -u $DOCKER_USER -p $DOCKER_PASS
572+ - run :
573+ name : Setup data dir
574+ working_directory : ~/project/contracts_reorg
575+ command : |
576+ sudo chmod -R 777 immutability/config/
507577 - snapshot_reorg :
508578 min_exit_period : 120
509579 - run :
0 commit comments