From 704d5e01b4874421c01a51041bbfbe4453087251 Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Thu, 16 May 2024 14:00:20 +0200 Subject: [PATCH 1/8] feat: Add docker ready script to makefile --- contract/Makefile | 4 +++- contract/package.json | 3 ++- contract/scripts/wait-for-container-ready.sh | 21 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 contract/scripts/wait-for-container-ready.sh diff --git a/contract/Makefile b/contract/Makefile index 67d3b01..4e7e468 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -108,6 +108,8 @@ build-proposal: bundles/bundle-list bundles/bundle-list $(SCRIPT) $(PERMIT): ./scripts/build-proposal.sh - clean: @rm -rf $(SCRIPT) $(PERMIT) bundles/ + +wait-for-container-ready: + ./scripts/wait-for-container-ready.sh \ No newline at end of file diff --git a/contract/package.json b/contract/package.json index 3b6fc63..6ccef9d 100644 --- a/contract/package.json +++ b/contract/package.json @@ -14,7 +14,8 @@ "build": "agoric run scripts/build-contract-deployer.js", "test": "ava --verbose", "lint": "eslint '**/*.js'", - "lint:fix": "eslint --fix '**/*.js'" + "lint:fix": "eslint --fix '**/*.js'", + "make:waitForContainer": "make wait-for-container-ready" }, "devDependencies": { "@agoric/deploy-script-support": "^0.10.4-u12.0", diff --git a/contract/scripts/wait-for-container-ready.sh b/contract/scripts/wait-for-container-ready.sh new file mode 100644 index 0000000..4bd4e9e --- /dev/null +++ b/contract/scripts/wait-for-container-ready.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +cd demo + +timeout 300 bash -c ' +TARGET_HEIGHT=1111 +SLEEP=10 +echo "Waiting for the Agoric service to be fully ready..." +echo "Target block height: $TARGET_HEIGHT" +while true; do + response=$(curl --silent http://localhost:26657/abci_info) + height=$(echo $response | jq -r ".result.response.last_block_height | tonumber") + if [ "$height" -ge $TARGET_HEIGHT ]; then + echo "Service is ready! Last block height: $height" + break + else + echo "Waiting for last block height to reach $TARGET_HEIGHT. Current height: $height" + fi + sleep $SLEEP +done +' From a75aa16f8cacc07fe0d2b91da34d9fddeced4c8e Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Thu, 16 May 2024 14:18:24 +0200 Subject: [PATCH 2/8] add changes from comments --- contract/Makefile | 2 +- contract/scripts/wait-for-container-ready.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/contract/Makefile b/contract/Makefile index 4e7e468..ad1f248 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -112,4 +112,4 @@ clean: @rm -rf $(SCRIPT) $(PERMIT) bundles/ wait-for-container-ready: - ./scripts/wait-for-container-ready.sh \ No newline at end of file + TARGET_HEIGHT=1111 ./scripts/wait-for-container-ready.sh \ No newline at end of file diff --git a/contract/scripts/wait-for-container-ready.sh b/contract/scripts/wait-for-container-ready.sh index 4bd4e9e..43f0393 100644 --- a/contract/scripts/wait-for-container-ready.sh +++ b/contract/scripts/wait-for-container-ready.sh @@ -2,8 +2,10 @@ cd demo +TARGET_HEIGHT=${TARGET_HEIGHT:1111} + timeout 300 bash -c ' -TARGET_HEIGHT=1111 +TARGET_HEIGHT=TARGET_HEIGHT='$TARGET_HEIGHT' SLEEP=10 echo "Waiting for the Agoric service to be fully ready..." echo "Target block height: $TARGET_HEIGHT" From 1d5f7ee640bf39c37031f107150915ed781f3735 Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Thu, 16 May 2024 14:21:07 +0200 Subject: [PATCH 3/8] fix typo --- contract/scripts/wait-for-container-ready.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contract/scripts/wait-for-container-ready.sh b/contract/scripts/wait-for-container-ready.sh index 43f0393..cc2e0dc 100644 --- a/contract/scripts/wait-for-container-ready.sh +++ b/contract/scripts/wait-for-container-ready.sh @@ -5,7 +5,7 @@ cd demo TARGET_HEIGHT=${TARGET_HEIGHT:1111} timeout 300 bash -c ' -TARGET_HEIGHT=TARGET_HEIGHT='$TARGET_HEIGHT' +TARGET_HEIGHT='$TARGET_HEIGHT' SLEEP=10 echo "Waiting for the Agoric service to be fully ready..." echo "Target block height: $TARGET_HEIGHT" From aaf306939155f252c1ef2f4a1e01b2636d6c2ac4 Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Thu, 16 May 2024 18:51:18 +0200 Subject: [PATCH 4/8] fixed with suggestions --- .../{wait-for-container-ready.sh => wait-for-blocks.sh} | 5 +++++ 1 file changed, 5 insertions(+) rename contract/scripts/{wait-for-container-ready.sh => wait-for-blocks.sh} (56%) diff --git a/contract/scripts/wait-for-container-ready.sh b/contract/scripts/wait-for-blocks.sh similarity index 56% rename from contract/scripts/wait-for-container-ready.sh rename to contract/scripts/wait-for-blocks.sh index cc2e0dc..af89e76 100644 --- a/contract/scripts/wait-for-container-ready.sh +++ b/contract/scripts/wait-for-blocks.sh @@ -1,5 +1,10 @@ #!/bin/bash +# # Borrowed from https://github.com/DCFoundation/cosmos-proposal-builder/blob/main/.github/workflows/pr.yml#L43-L61 +# # This script waits for the Agoric service to be fully ready before running the tests. +# # It does so by polling the `/abci_info` endpoint of the Agoric service until the last block height is greater than or equal to the target height. +# # The target height is set to 1111 by default, but can be overridden by setting the `TARGET_HEIGHT` environment variable. + cd demo TARGET_HEIGHT=${TARGET_HEIGHT:1111} From c5256c6b84ddecb9dc1e8f3dbaec2c84986848e4 Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Fri, 17 May 2024 13:10:22 +0200 Subject: [PATCH 5/8] test --- .github/workflows/pr.yml | 2 ++ contract/Makefile | 4 ++-- contract/package.json | 2 +- contract/scripts/wait-for-blocks.sh | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 contract/scripts/wait-for-blocks.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2cf3268..a93860f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,6 +16,8 @@ jobs: node-version: "18.8.x" - name: yarn install run: yarn + - name: yarn make:waitForBlocks + run: yarn make:waitForBlocks - name: yarn lint run: yarn lint - name: yarn build diff --git a/contract/Makefile b/contract/Makefile index ad1f248..8c2b5da 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -111,5 +111,5 @@ bundles/bundle-list $(SCRIPT) $(PERMIT): clean: @rm -rf $(SCRIPT) $(PERMIT) bundles/ -wait-for-container-ready: - TARGET_HEIGHT=1111 ./scripts/wait-for-container-ready.sh \ No newline at end of file +wait-for-blocks: + TARGET_HEIGHT=1111 ./scripts/wait-for-blocks.sh \ No newline at end of file diff --git a/contract/package.json b/contract/package.json index 6ccef9d..382b22f 100644 --- a/contract/package.json +++ b/contract/package.json @@ -15,7 +15,7 @@ "test": "ava --verbose", "lint": "eslint '**/*.js'", "lint:fix": "eslint --fix '**/*.js'", - "make:waitForContainer": "make wait-for-container-ready" + "make:waitForBlocks": "make wait-for-blocks" }, "devDependencies": { "@agoric/deploy-script-support": "^0.10.4-u12.0", diff --git a/contract/scripts/wait-for-blocks.sh b/contract/scripts/wait-for-blocks.sh old mode 100644 new mode 100755 index af89e76..9f892df --- a/contract/scripts/wait-for-blocks.sh +++ b/contract/scripts/wait-for-blocks.sh @@ -5,7 +5,6 @@ # # It does so by polling the `/abci_info` endpoint of the Agoric service until the last block height is greater than or equal to the target height. # # The target height is set to 1111 by default, but can be overridden by setting the `TARGET_HEIGHT` environment variable. -cd demo TARGET_HEIGHT=${TARGET_HEIGHT:1111} From 24c9d2810b176b2a10ed593a35a53a689bea15b2 Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Fri, 17 May 2024 13:15:39 +0200 Subject: [PATCH 6/8] test --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3932425..ce4534c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,8 @@ "lint": "yarn workspaces run lint", "test": "yarn workspaces run test", "test:e2e": "yarn workspace offer-up-ui test:e2e", - "build": "yarn workspaces run build" + "build": "yarn workspaces run build", + "runWaitForBlocks": "cd contract && yarn make:waitForBlocks" }, "devDependencies": { "@agoric/synpress": "^3.8.1", From bae73da87952d6f4ed855d4ca403ac731fb614e7 Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Fri, 17 May 2024 13:17:02 +0200 Subject: [PATCH 7/8] test --- .github/workflows/pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a93860f..4a1d0d3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,8 +16,8 @@ jobs: node-version: "18.8.x" - name: yarn install run: yarn - - name: yarn make:waitForBlocks - run: yarn make:waitForBlocks + - name: yarn runWaitForBlocks + run: yarn runWaitForBlocks - name: yarn lint run: yarn lint - name: yarn build From eecc966856c8f433859eb267896cc542c11ed95b Mon Sep 17 00:00:00 2001 From: Ansab Gillani Date: Fri, 17 May 2024 13:19:52 +0200 Subject: [PATCH 8/8] test --- .github/workflows/pr.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4a1d0d3..2cf3268 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -16,8 +16,6 @@ jobs: node-version: "18.8.x" - name: yarn install run: yarn - - name: yarn runWaitForBlocks - run: yarn runWaitForBlocks - name: yarn lint run: yarn lint - name: yarn build