From 93d554805f53fb74e5a6b35ff69a60d47a541bc6 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 08:55:59 +0100 Subject: [PATCH 01/12] Add COSMOS_ENABLED to ci --- .circleci/config.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 28e6a717..0999f28b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,8 +30,37 @@ jobs: - ~/.cache/yarn - run: command: yarn build + test: + docker: + - image: circleci/node:10 + steps: + - checkout - run: + name: Version information + command: echo "node $(node --version)"; echo "yarn $(yarn --version)" + - restore_cache: + name: Restore Yarn Package Cache + keys: + - yarn-packages-{{ checksum "yarn.lock" }} + - run: + name: Install Dependencies + command: yarn install --frozen-lockfile + - save_cache: + name: Save Yarn Package Cache + key: yarn-packages-{{ checksum "yarn.lock" }} + paths: + - ~/.cache/yarn + - run: + command: docker pull cosmwasm/wasmd:latest + - run: + command: ./projects/scripts/cosm/start.sh + - run: + command: sleep 15 + - run: + environment: COSMOS_ENABLED=1 command: yarn test + - run: + command: ./projects/scripts/cosm/stop.sh lint: docker: - image: circleci/node:10 From 690a93ae59bfbb45d3a961b4b17c5b50eef3d18a Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 08:57:09 +0100 Subject: [PATCH 02/12] Add background flag to start.sh --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0999f28b..98d5fa80 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,6 +54,7 @@ jobs: command: docker pull cosmwasm/wasmd:latest - run: command: ./projects/scripts/cosm/start.sh + background: true - run: command: sleep 15 - run: From 94a49ed89964a2b39d3fe29e769081791f82457d Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 09:11:13 +0100 Subject: [PATCH 03/12] Enable test in ci, move pull into start.sh --- .circleci/config.yml | 13 ++++++------- scripts/cosm/start.sh | 5 +++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 98d5fa80..164a818e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,6 +6,7 @@ workflows: - build - lint - faucet_docker + - test jobs: build: @@ -38,6 +39,9 @@ jobs: - run: name: Version information command: echo "node $(node --version)"; echo "yarn $(yarn --version)" + - run: # start early for less wait time below + command: ./projects/scripts/cosm/start.sh + background: true - restore_cache: name: Restore Yarn Package Cache keys: @@ -50,13 +54,8 @@ jobs: key: yarn-packages-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn - - run: - command: docker pull cosmwasm/wasmd:latest - - run: - command: ./projects/scripts/cosm/start.sh - background: true - - run: - command: sleep 15 + - run: # wait until cosm scripts have fully started + command: timeout 15 bash -c "until curl -s http://localhost:1317/node_info > /dev/null; do sleep 1; done - run: environment: COSMOS_ENABLED=1 command: yarn test diff --git a/scripts/cosm/start.sh b/scripts/cosm/start.sh index 98f04ff8..c9224905 100755 --- a/scripts/cosm/start.sh +++ b/scripts/cosm/start.sh @@ -15,6 +15,10 @@ echo "Using temporary dir $TMP_DIR" WASMD_LOGFILE="$TMP_DIR/wasmd.log" REST_SERVER_LOGFILE="$TMP_DIR/rest-server.log" +# pull the newest copy of the docker image +# this is important as the sleep timeout below will fail on first run (downloading entire docker stack usually > 10s) +docker pull "$REPOSITORY:$VERSION" + # This starts up wasmd docker volume rm -f wasmd_data docker run --rm \ @@ -36,6 +40,7 @@ if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME")" != "true" ]; echo "Container named '$CONTAINER_NAME' not running. We cannot continue." \ "This can happen when 'docker run' needs too long to download and start." \ "It might be worth retrying this step once the image is in the local docker cache." + docker kill "$CONTAINER_NAME" exit 1 fi From 7b1fef158c8d6a21c4e6bcb4057637c61058ba12 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 09:29:15 +0100 Subject: [PATCH 04/12] Fix syntax error with env --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 164a818e..ff57dc46 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,8 @@ jobs: - run: # wait until cosm scripts have fully started command: timeout 15 bash -c "until curl -s http://localhost:1317/node_info > /dev/null; do sleep 1; done - run: - environment: COSMOS_ENABLED=1 + environment: + COSMOS_ENABLED: 1 command: yarn test - run: command: ./projects/scripts/cosm/stop.sh From 81cbc9b51f0ba56bf7959546ed7cb03b4ed1b683 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 09:32:50 +0100 Subject: [PATCH 05/12] More fixes to ci config --- .circleci/config.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ff57dc46..d63dfea3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,11 +36,13 @@ jobs: - image: circleci/node:10 steps: - checkout + - setup_remote_docker: + docker_layer_caching: false - run: name: Version information command: echo "node $(node --version)"; echo "yarn $(yarn --version)" - run: # start early for less wait time below - command: ./projects/scripts/cosm/start.sh + command: ./project/scripts/cosm/start.sh background: true - restore_cache: name: Restore Yarn Package Cache @@ -55,13 +57,13 @@ jobs: paths: - ~/.cache/yarn - run: # wait until cosm scripts have fully started - command: timeout 15 bash -c "until curl -s http://localhost:1317/node_info > /dev/null; do sleep 1; done + command: timeout 15 bash -c "until curl -s http://localhost:1317/node_info > /dev/null; do sleep 1; done" - run: environment: COSMOS_ENABLED: 1 command: yarn test - run: - command: ./projects/scripts/cosm/stop.sh + command: ./project/scripts/cosm/stop.sh lint: docker: - image: circleci/node:10 From 10489402f8c59b340851d66b102b53e19d0756c2 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 09:44:30 +0100 Subject: [PATCH 06/12] One more typo with script path --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d63dfea3..4650f1eb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: name: Version information command: echo "node $(node --version)"; echo "yarn $(yarn --version)" - run: # start early for less wait time below - command: ./project/scripts/cosm/start.sh + command: ./scripts/cosm/start.sh background: true - restore_cache: name: Restore Yarn Package Cache @@ -63,7 +63,7 @@ jobs: COSMOS_ENABLED: 1 command: yarn test - run: - command: ./project/scripts/cosm/stop.sh + command: ./scripts/cosm/stop.sh lint: docker: - image: circleci/node:10 From 037ceebe7bcb2971268c941dcb84807c72c0a204 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Mon, 3 Feb 2020 09:47:56 +0100 Subject: [PATCH 07/12] Give 60 seconds for cosm/start.sh startup --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4650f1eb..3f76b1e6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,8 +56,8 @@ jobs: key: yarn-packages-{{ checksum "yarn.lock" }} paths: - ~/.cache/yarn - - run: # wait until cosm scripts have fully started - command: timeout 15 bash -c "until curl -s http://localhost:1317/node_info > /dev/null; do sleep 1; done" + - run: # wait until cosm scripts have fully started (this includes time for docker pull) + command: timeout 60 bash -c "until curl -s http://localhost:1317/node_info > /dev/null; do sleep 1; done" - run: environment: COSMOS_ENABLED: 1 From 95599c54e7c4f6aaf226c5c8ce087d7c5151110e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 3 Feb 2020 12:45:49 +0100 Subject: [PATCH 08/12] Run tests in machine executor --- .circleci/config.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f76b1e6..92799a1e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -32,12 +32,15 @@ jobs: - run: command: yarn build test: - docker: - - image: circleci/node:10 + machine: + # We can't use a containerized environment since it requires remote docker to start custom containers. + # However, we can't access the remote docker's network from the primary container. This is a + # feature, as documented in https://circleci.com/docs/2.0/building-docker-images/#separation-of-environments + # As a consequence, we cannot use the circleci CLI for this job because "You cannot use the machine + # executor in local jobs." (https://circleci.com/docs/2.0/local-cli/#limitations-of-running-jobs-locally) + image: ubuntu-1604:201903-01 steps: - checkout - - setup_remote_docker: - docker_layer_caching: false - run: name: Version information command: echo "node $(node --version)"; echo "yarn $(yarn --version)" From 5613c440bf81961b915c160557c933ff43c57e72 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 3 Feb 2020 12:48:32 +0100 Subject: [PATCH 09/12] Install nodejs and yarn --- .circleci/config.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 92799a1e..25c75337 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,6 +41,17 @@ jobs: image: ubuntu-1604:201903-01 steps: - checkout + - run: + # The images ubuntu-1604:201903-01 comes with preinstalled nvm, which does not work well with non-login shells + name: Uninstall nvm + command: rm -rf "$NVM_DIR" ~/.npm ~/.bower + - run: + name: Install nodejs and yarn + command: | + curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - + 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 update && sudo apt install nodejs yarn - run: name: Version information command: echo "node $(node --version)"; echo "yarn $(yarn --version)" From 91dcf047380b4ee9520c110c63233a696e06128b Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 3 Feb 2020 14:43:59 +0100 Subject: [PATCH 10/12] Start blockchain before installing nodejs/yarn --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 25c75337..67d28966 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,6 +41,9 @@ jobs: image: ubuntu-1604:201903-01 steps: - checkout + - run: # start early for less wait time below + command: ./scripts/cosm/start.sh + background: true - run: # The images ubuntu-1604:201903-01 comes with preinstalled nvm, which does not work well with non-login shells name: Uninstall nvm @@ -55,9 +58,6 @@ jobs: - run: name: Version information command: echo "node $(node --version)"; echo "yarn $(yarn --version)" - - run: # start early for less wait time below - command: ./scripts/cosm/start.sh - background: true - restore_cache: name: Restore Yarn Package Cache keys: From 9756f0361bdfc9cc74fd24dc542441239506dac7 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 3 Feb 2020 15:14:55 +0100 Subject: [PATCH 11/12] Debug rest server start --- scripts/cosm/start.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/cosm/start.sh b/scripts/cosm/start.sh index c9224905..3722d815 100755 --- a/scripts/cosm/start.sh +++ b/scripts/cosm/start.sh @@ -34,6 +34,10 @@ docker run --rm \ echo "wasmd running and logging into $WASMD_LOGFILE" +# Debug chain start +sleep 3 +cat "$WASMD_LOGFILE" + sleep 10 if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME")" != "true" ]; then @@ -52,3 +56,7 @@ docker exec "$CONTAINER_NAME" \ > "$REST_SERVER_LOGFILE" & echo "rest server running on http://localhost:1317 and logging into $REST_SERVER_LOGFILE" + +# Debug rest server start +sleep 3 +cat "$REST_SERVER_LOGFILE" From 4449f4f0c989ed280be256b5d6b512b0a1cca3fc Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 3 Feb 2020 15:19:37 +0100 Subject: [PATCH 12/12] Fix link to docker repo --- scripts/cosm/env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cosm/env b/scripts/cosm/env index 544cf984..f2eb21ba 100644 --- a/scripts/cosm/env +++ b/scripts/cosm/env @@ -1,4 +1,4 @@ -# Choose from https://hub.docker.com/r/cosmwasm/wasmd/tags +# Choose from https://hub.docker.com/r/cosmwasm/wasmd-demo/tags REPOSITORY="cosmwasm/wasmd-demo" VERSION="latest"