Skip to content

Commit

Permalink
Add wait
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm committed Nov 10, 2023
1 parent ab55aad commit d510f3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/contracts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/wait-until-ready.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d510f3e

Please sign in to comment.