Skip to content

Commit e7897fc

Browse files
authored
Merge pull request #223 from oasisprotocol/xz/add-wait
Add wait for CI until Oasis Gateway is ready
2 parents ab55aad + 5cc71c8 commit e7897fc

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

.github/wait-until-ready.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
set -o pipefail
3+
SECONDS=0
4+
TIMEOUT=30
5+
OASIS_WEB3_GATEWAY=http://127.0.0.1:8545
6+
7+
gatewayisready() {
8+
curl -X POST -s \
9+
-H 'Content-Type: application/json' \
10+
--data '{"jsonrpc":"2.0","method":"oasis_callDataPublicKey","params":[],"id":1}' \
11+
${OASIS_WEB3_GATEWAY} 2>&1 | jq -e '.result | has("key")'
12+
}
13+
14+
until gatewayisready
15+
do
16+
if (( SECONDS >= TIMEOUT ))
17+
then
18+
echo "Gateway not ready..."
19+
exit 1
20+
fi
21+
sleep 1
22+
done

.github/workflows/contracts-test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
--health-cmd="/oasis-node debug control wait-ready -a unix:/serverdir/node/net-runner/network/client-0/internal.sock"
2323
--health-start-period=90s
2424
steps:
25-
- name: attempt to connect to sapphire-dev-ci
26-
run: curl -kv http://sapphire-dev-ci:8545/ || true
27-
- name: attempt to connect to sapphire-dev-ci via localhost
28-
run: curl -kv http://127.0.0.1:8545/ || true
2925
- name: Checkout code
3026
uses: actions/checkout@v4
27+
- name: Install jq
28+
run: sudo apt install -y jq
29+
- name: Wait for gateway
30+
run: bash .github/wait-until-ready.sh
3131
- name: Install Node.js
3232
uses: actions/setup-node@v4
3333
with:

0 commit comments

Comments
 (0)