-
Notifications
You must be signed in to change notification settings - Fork 39
158 lines (136 loc) · 5.54 KB
/
axon-sync-test.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Axon sync test
on:
workflow_dispatch:
# TODO: remove `pull_request` event when this workflow is stable
pull_request:
jobs:
Build_and_Archive_Axon:
strategy:
matrix:
# Supported GitHub-hosted runners and hardware resources
# see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
os: [ubuntu-22.04]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Cache of Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
- name: Build Axon
run: |
# check for AVX2 support by inspecting `/proc/cpuinfo` or running `lscpu`
# related issue: https://github.com/axonweb3/axon/issues/1387
lscpu
cargo build
- name: Archive Axon Artifacts
uses: actions/upload-artifact@v3
with:
name: axon-dir
path: |
target/debug/axon
devtools/chain/default.db-options
devtools/chain/config.toml
devtools/chain/specs/alphanet_nodes/chain-spec.toml
devtools/ci/scripts/helper.js
retention-days: 3
Download_and_Start_Axon_Sync:
name: Download_and_Start_Axon_Sync
needs: Build_and_Archive_Axon
runs-on: layer2-runners
timeout-minutes: 1800
steps:
- name: Download Axon Binary for Build_and_Archive_Axon
uses: actions/download-artifact@v3
with:
name: axon-dir
- name: Replacement configuration
run: |
sed -i 's@multi_address = "/ip4/127.0.0.1/tcp/8001/p2p/QmNk6bBwkLPuqnsrtxpp819XLZY3ymgjs3p1nKtxBVgqxj"@multi_address = "/dns4/axon1/tcp/8001/p2p/QmcgR2Jj6XJ4B9VDp3UaG3dcwFaeqwXikHco9nLq9Eand6"@' devtools/chain/config.toml
sed -i 's@bls_privkey_file = "bls.key"@bls_privkey_file = "bls_0.key"@' devtools/chain/config.toml
sed -i 's@net_privkey_file = "net.key"@net_privkey_file = "net_0.key"@' devtools/chain/config.toml
- name: Start Axon Node
env:
LOG_FILE: ${{ runner.temp }}/layer2-runner-axon-node.log
run: |
chmod +x target/debug/axon
target/debug/axon generate-keypair -n 1 -p devtools/chain/
target/debug/axon --version
target/debug/axon init \
--config devtools/chain/config.toml \
--chain-spec devtools/chain/specs/alphanet_nodes/chain-spec.toml
nohup target/debug/axon run \
--config devtools/chain/config.toml &
- name: Wati for App to Start
run: sleep 15
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Compare Block Heights
run: |
npx zx <<'EOF'
#!/usr/bin/env zx
import { getLatestBlockNum } from './devtools/ci/scripts/helper.js';
async function main() {
let previousLocalHeight = null;
while (true) {
const localHeight = await getLatestBlockNum('http://127.0.0.1:8000');
const remoteHeight = await getLatestBlockNum('http://axon1:8000');
console.log(`localBlockNumber: ${localHeight}, remoteBlockNumber: ${remoteHeight}`);
if (localHeight >= remoteHeight - 10 && localHeight <= remoteHeight) {
console.log(`localBlockNumber: ${localHeight}, remoteBlockNumber: ${remoteHeight}, localnode sync succeeded`);
return process.exit(0);
}
if (localHeight === previousLocalHeight) {
console.error(`synchronization exception localBlockNumber: ${localHeight}`);
return process.exit(1);
}
previousLocalHeight = localHeight;
await new Promise(resolve => setTimeout(resolve, 600000));
}
}
main();
EOF
timeout-minutes: 1800
notice:
runs-on: ubuntu-latest
needs: Download_and_Start_Axon_Sync
if: success() || failure()
steps:
- name: send Axon-sync-test status
run: |
curl -H "Content-Type: application/json" \
-X POST https://discord.com/api/webhooks/${{secrets.DISCORD_CHANNEL_ID}}/${{secrets.DISCORD_CHANNEL_TOKEN}} \
--data '
{
"content": "Axon-sync-test",
"embeds": [
{
"title":"Axon Sync test Status",
"color": 5814789,
"fields": [
{
"name": "Job name",
"value": "axon-sync-test\n"
},
{ "name": "Job statues",
"value": "${{needs.Download_and_Start_Axon_Sync.result}}\n"
},
{
"name": "URL",
"value": "[Click and jump to Github workflow](https://github.com/axonweb3/axon/actions/workflows/axon-sync-test.yml)\n"
}
]
}
]
}'