diff --git a/.github/workflows/contracts-test.yaml b/.github/workflows/contracts-test.yaml index a3f98c5a5..d3b658364 100644 --- a/.github/workflows/contracts-test.yaml +++ b/.github/workflows/contracts-test.yaml @@ -22,10 +22,11 @@ jobs: --health-cmd="/oasis-node debug control wait-ready -a unix:/serverdir/node/net-runner/network/client-0/internal.sock" --health-start-period=90s steps: - - name: attempt to connect to sapphire-dev-ci - run: curl -kv http://sapphire-dev-ci:8545/ || true - - name: attempt to connect to sapphire-dev-ci via localhost - run: curl -kv http://127.0.0.1:8545/ || true + - name: Install jq + run: sudo apt install -y jq + - name: Wait until gateway is ready + working-directory: .github/workflows + run: wait-until-ready.sh || true - name: Checkout code uses: actions/checkout@v4 - name: Install Node.js diff --git a/.github/workflows/wait-until-ready.sh b/.github/workflows/wait-until-ready.sh new file mode 100644 index 000000000..d7e921c68 --- /dev/null +++ b/.github/workflows/wait-until-ready.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -o pipefail +SECONDS=0 + +gatewayisready() { + curl -X POST -s \ + -H 'Content-Type: application/json' \ + --data '{"jsonrpc":"2.0","method":"oasis_callDataPublicKey","params":[],"id":1}' \ + http://127.0.0.1:8545 2>&1 | jq -e '.result | has("key")' +} + +until gatewayisready +do + if (( SECONDS >= 3 )) + then + echo "Gateway not ready..." + exit 1 + fi + sleep 1 +done