Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add axon sync workflows #1589

Closed
wants to merge 7 commits into from
Closed
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions .github/workflows/axon-sync-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Axon sync test

on:
workflow_dispatch:
Simon-Tl marked this conversation as resolved.
Show resolved Hide resolved
push:

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 }}
Simon-Tl marked this conversation as resolved.
Show resolved Hide resolved
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
# PORTABLE=1 USE_SSE=1 tell rocksdb to target AVX2
PORTABLE=1 USE_SSE=1 cargo build

- name: Archive axon artifacts
uses: actions/upload-artifact@v3
with:
name: axon-dir
path: |
target/debug/axon
devtools/chain/specs/single_node/chain-spec.toml
devtools/chain/default.db-options
devtools/chain/config.toml
devtools/chain/nodes/node_1*
devtools/ci/scripts/helper.js
retention-days: 7


Download_and_Start_Axon_Sync:
name: Download_and_Start_Axon_Sync
needs: Build_and_Archive_Axon
runs-on: layer2-runners

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@bls_privkey_file = "bls.key"@bls_privkey_file = "nodes/node_1_bls.key"@g' devtools/chain/config.toml
sed -i 's@net_privkey_file = "net.key"@net_privkey_file = "nodes/node_1_net.key"@g' devtools/chain/config.toml
sed -i 's@multi_address = "/ip4/127.0.0.1/tcp/8001/p2p/QmNk6bBwkLPuqnsrtxpp819XLZY3ymgjs3p1nKtxBVgqxj"@multi_address = "/dns4/axon1/tcp/8001/p2p/QmNk6bBwkLPuqnsrtxpp819XLZY3ymgjs3p1nKtxBVgqxj"@' 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 --version
target/debug/axon init \
--config devtools/chain/config.toml \
--chain-spec devtools/chain/specs/single_node/chain-spec.toml

nohup target/debug/axon run \
--config devtools/chain/config.toml &

- name: Wati for App to Start
run: sleep 10

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
Simon-Tl marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: |
npm install -g zx
Flouse marked this conversation as resolved.
Show resolved Hide resolved

- 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 localhostHeight = await getLatestBlockNum('http://127.0.0.1:8000');
const remoteHeight = await getLatestBlockNum('https://rpc-alphanet-axon.ckbapp.dev');
console.log("localBlockNumber:" + localhostHeight, "remoteBlockNumber:"+ remoteHeight)

if (localhostHeight === remoteHeight - 10) {
console.log("localBlockNumber:" + localhostHeight, "remoteBlockNumber:"+ remoteHeight, "localnode sync succeeded" );
process.exit(0);
} else if (localhostHeight === previousLocalHeight) {
console.error("synchronization exception localBlockNumber:" + localhostHeight);
process.exit(1);
}
previousLocalHeight = localhostHeight;
await new Promise(resolve => setTimeout(resolve, 600000));
Simon-Tl marked this conversation as resolved.
Show resolved Hide resolved
}
}
main();
EOF

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"
}

]
}
]
}'