-
Notifications
You must be signed in to change notification settings - Fork 12
125 lines (115 loc) · 4.22 KB
/
readonly-node-sync.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Sync Test
on:
push:
jobs:
gw-testnet_v1-readonly-node-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache chain-data
uses: actions/cache@v3
with:
path: |
chain-data/
testnet_v1_1/chain-data/readonly
key: chain-data-${{ hashFiles('testnet_v1_1/docker-compose.yml') }}-${{ github.sha }}
restore-keys: |
chain-data-${{ hashFiles('testnet_v1_1/docker-compose.yml') }}
# https://cdn-ckb-tools.sfo3.digitaloceanspaces.com/snapshots/snapshots.html?prefix=snapshots/
- name: Get the snapshots of ckb-indexer
run: |
[[ -d chain-data/ckb-indexer-data ]] && exit 0
mkdir -p chain-data && cd chain-data
curl -LO https://cdn-ckb-tools.sfo3.digitaloceanspaces.com/snapshots/20220605-nervos-ckb-indexer-0.3.2-testnet-snapshot.7z
7z x 20220605-nervos-ckb-indexer-0.3.2-testnet-snapshot.7z -ockb-indexer-data
rm 20220605-nervos-ckb-indexer-0.3.2-testnet-snapshot.7z
- name: Run a Godwoken testnet_v1 readonly node
working-directory: testnet_v1_1
run: |
cat docker-compose.yml
docker-compose up -d gw-readonly
docker-compose ps
- name: Wait until Godwoken readonly node is ready to serve
id: gw-readonly-node
working-directory: testnet_v1_1
env:
TIMEOUT: 5h
run: |
docker-compose ps
echo "Wait until Godwoken readonly node is ready to serve"
timeout ${{ env.TIMEOUT }} bash -c 'while true; do
docker-compose logs --tail=10 &> /tmp/docker.log
egrep "bad block" /tmp/docker.log && bad_block_found=true && break
egrep "sync new block" /tmp/docker.log | tail --lines=1
docker-compose ps gw-readonly | egrep healthy && break \
|| echo "Godwoken readonly node is not healthy."
sleep 6s
done' || exit 0
[[ $bad_block_found == true ]] && exit 1
docker-compose ps
docker-compose ps gw-readonly | egrep healthy \
&& echo "::set-output name=state::healthy"
- name: Start Godwoken Web3 and Indexer services if Godwoken readonly node is ready
if: steps.gw-readonly-node.outputs.state == 'healthy'
id: up
working-directory: testnet_v1_1
env:
TIMEOUT: 1h
run: |
docker-compose ps
docker-compose up -d
timeout ${{ env.TIMEOUT }} bash -c 'while true; do
docker-compose ps web3 | egrep healthy && break \
|| echo "Godwoken Web3 RPC is not healthy."
sleep 6s
done' || echo "timeout(${{ env.TIMEOUT }})"
docker-compose ps web3-indexer | egrep Up \
&& echo "::set-output name=web3::true"
- uses: actions/checkout@v3
with:
repository: nervosnetwork/godwoken-tests
ref: v1
path: godwoken-tests
submodules: 'true'
- uses: actions/setup-node@v3
with:
node-version: '16'
# cache: 'yarn'
- run: yarn install
working-directory: godwoken-tests/tools
- name: Check if web3 service is ready
if: steps.up.outputs.web3 == 'true'
uses: actions/github-script@v6
timeout-minutes: 30
with:
script: |
const { getTipBlockNumber } = require("./godwoken-tests/scripts/helper");
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const PUBLIC_WEB3_RPC='https://v1.testnet.godwoken.io/rpc';
let isSyncedToTip = false;
while (!isSyncedToTip) {
await sleep(6666);
try {
const [localTip, fullnodeTip] = await Promise.all([
getTipBlockNumber(), getTipBlockNumber(PUBLIC_WEB3_RPC)
]);
isSyncedToTip = localTip === fullnodeTip;
} catch (error) {
console.error(error);
}
}
- name: Save logs
if: always()
working-directory: testnet_v1_1
run: |
docker-compose ps
docker-compose logs --tail 666
docker-compose stop
docker-compose logs > /tmp/docker.log
- name: Archive logs
if: always()
uses: actions/upload-artifact@v2
with:
name: docker-logs
path: |
/tmp/docker.log