Refactor CI config (#177)

* Update ci config version

* try to use orb

* command

* naming

* Common docker executor config

* Machine in orb

* Common tasks

* common caching

* nvm

* Final test
This commit is contained in:
Przemyslaw Rzad 2019-08-05 09:48:21 +02:00 committed by GitHub
parent f3419cbec4
commit 52239a9506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,81 @@
version: 2 version: 2.1
orbs:
tokenbridge-orb:
commands:
install-chrome:
steps:
- run:
name: Install Chrome
command: |
wget -O chrome.deb https://www.slimjet.com/chrome/download-chrome.php?file=files%2F75.0.3770.80%2Fgoogle-chrome-stable_current_amd64.deb
sudo dpkg -i chrome.deb
install-node:
steps:
- run:
name: Install Node
command: |
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 11.4.0 && nvm alias default 11.4.0
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
install-yarn:
steps:
- run:
name: Install Yarn
command: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get -y install yarn
yarn-install-cached-on-machine:
steps:
- restore_cache:
name: Restore Machine Yarn Package Cache
keys:
- yarn-machine-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run:
name: Install npm dependencies using Yarn
command: nvm use default; yarn install --frozen-lockfile
- save_cache:
name: Save Machine Yarn Package Cache
key: yarn-machine-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
wait-for-oracle:
steps:
- run:
name: Install redis tools
command: sudo apt-get install -y redis-tools
- run:
name: Wait for the Oracle to start
command: |
set +e
i=0
while [[ $(redis-cli GET native-erc-collected-signatures:lastProcessedBlock) = "" ]]; do
((i++))
if [ "$i" -gt 30 ]
then
exit -1
fi
echo "Sleeping..."
sleep 3
done
executors:
docker-node:
docker:
- image: circleci/node:10.15
machine-with-docker-caching:
machine:
image: circleci/classic:latest
docker_layer_caching: true
jobs: jobs:
initialize: initialize:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- checkout - checkout
- run: git submodule update --init - run: git submodule update --init
@ -36,35 +109,30 @@ jobs:
paths: paths:
- ~/project - ~/project
initialize-root: initialize-root:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- checkout - checkout
- run: sudo su - -c 'export CI=true && cd /home/circleci/project && yarn initialize && yarn test' - run: sudo su - -c 'export CI=true && cd /home/circleci/project && yarn initialize && yarn test'
build: build:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- restore_cache: - restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }} key: initialize-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn run build - run: yarn run build
lint: lint:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- restore_cache: - restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }} key: initialize-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn run lint - run: yarn run lint
test: test:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- restore_cache: - restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }} key: initialize-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn run test - run: yarn run test
oracle-e2e: oracle-e2e:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- checkout - checkout
- run: git submodule update --init - run: git submodule update --init
@ -72,123 +140,57 @@ jobs:
docker_layer_caching: true docker_layer_caching: true
- run: yarn run oracle-e2e - run: yarn run oracle-e2e
ui-e2e: ui-e2e:
machine: executor: tokenbridge-orb/machine-with-docker-caching
image: circleci/classic:latest
docker_layer_caching: true
steps: steps:
- checkout - checkout
- run: | - tokenbridge-orb/install-node
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV - tokenbridge-orb/install-yarn
echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV - tokenbridge-orb/install-chrome
- run: nvm install 11.4.0 && nvm alias default 11.4.0
- run: curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
- run: echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- run: sudo apt-get update && sudo apt-get install yarn
- run: wget -O chrome.deb https://www.slimjet.com/chrome/download-chrome.php?file=files%2F75.0.3770.80%2Fgoogle-chrome-stable_current_amd64.deb
- run: sudo dpkg -i chrome.deb
- run: git submodule update --init - run: git submodule update --init
- restore_cache: - tokenbridge-orb/yarn-install-cached-on-machine
name: Restore Machine Yarn Package Cache
keys:
- yarn-machine-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- run: yarn install --frozen-lockfile
- save_cache:
name: Save Machine Yarn Package Cache
key: yarn-machine-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run: yarn run ui-e2e - run: yarn run ui-e2e
monitor-e2e: monitor-e2e:
machine: executor: tokenbridge-orb/machine-with-docker-caching
image: circleci/classic:latest
docker_layer_caching: true
steps: steps:
- checkout - checkout
- run: git submodule update --init - run: git submodule update --init
- run: ./monitor-e2e/run-tests.sh - run: ./monitor-e2e/run-tests.sh
cover: cover:
docker: executor: tokenbridge-orb/docker-node
- image: circleci/node:10.15
steps: steps:
- restore_cache: - restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }} key: initialize-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn workspace ui run coverage - run: yarn workspace ui run coverage
- run: yarn workspace ui run coveralls - run: yarn workspace ui run coveralls
deployment-oracle: deployment-oracle:
machine: executor: tokenbridge-orb/machine-with-docker-caching
image: circleci/classic:latest
docker_layer_caching: true
steps: steps:
- checkout - checkout
- run: deployment/molecule/molecule.sh oracle - run: deployment/molecule/molecule.sh oracle
deployment-ui: deployment-ui:
machine: executor: tokenbridge-orb/machine-with-docker-caching
image: circleci/classic:latest
docker_layer_caching: true
steps: steps:
- checkout - checkout
- run: deployment/molecule/molecule.sh ui - run: deployment/molecule/molecule.sh ui
deployment-monitor: deployment-monitor:
machine: executor: tokenbridge-orb/machine-with-docker-caching
image: circleci/classic:latest
docker_layer_caching: true
steps: steps:
- checkout - checkout
- run: deployment/molecule/molecule.sh monitor - run: deployment/molecule/molecule.sh monitor
ultimate-native-to-erc: ultimate-native-to-erc:
machine: executor: tokenbridge-orb/machine-with-docker-caching
image: circleci/classic:latest
docker_layer_caching: true
steps: steps:
- checkout - checkout
- run: git submodule update --init - run: git submodule update --init
- run: - tokenbridge-orb/install-node
name: Install redis tools - tokenbridge-orb/install-chrome
command: sudo apt-get install -y redis-tools - tokenbridge-orb/install-yarn
- run: - tokenbridge-orb/yarn-install-cached-on-machine
name: Install node
command: |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install v10.15.3
nvm alias default v10.15.3
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
- run:
name: Install Chrome
command: |
wget -O chrome.deb https://www.slimjet.com/chrome/download-chrome.php?file=files%2F75.0.3770.80%2Fgoogle-chrome-stable_current_amd64.deb
sudo dpkg -i chrome.deb
- run:
name: Install yarn
command: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
- run:
name: Install npm packages
command: nvm use default; yarn install --frozen-lockfile
- run: - run:
name: Prepare the infrastructure name: Prepare the infrastructure
command: e2e-commons/up.sh deploy native-to-erc command: e2e-commons/up.sh deploy native-to-erc
no_output_timeout: 30m no_output_timeout: 30m
- run: - tokenbridge-orb/wait-for-oracle
name: Wait for the Oracle to start
command: |
set +e
i=0
while [[ $(redis-cli GET native-erc-collected-signatures:lastProcessedBlock) = "" ]]; do
((i++))
if [ "$i" -gt 30 ]
then
exit -1
fi
echo "Sleeping..."
sleep 3
done
- run: - run:
name: Run the ui-e2e tests name: Run the ui-e2e tests
command: | command: |
@ -196,7 +198,6 @@ jobs:
node ./e2e-commons/scripts/blocks.js & node ./e2e-commons/scripts/blocks.js &
cd ui-e2e; yarn mocha -g "NATIVE TO ERC" -b ./test.js cd ui-e2e; yarn mocha -g "NATIVE TO ERC" -b ./test.js
workflows: workflows:
version: 2
tokenbridge: tokenbridge:
jobs: jobs:
- initialize - initialize