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: refactor axon start with short genesis workflow #1341

Merged
merged 6 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
158 changes: 110 additions & 48 deletions .github/workflows/axon-start-with-short-genesis.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,121 @@
name: Axon start test

on:
push:
branches:
- main
pull_request:
merge_group:
workflow_dispatch:

jobs:
build:
runs-on: [self-hosted,spark]
# Build Axon and cache the binary
build-axon:
uses: ./.github/workflows/build.yml

# Start a single Axon node
single-node:
needs: build-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-20.04, ubuntu-22.04] # TODO: test on [windows-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: axonweb3/axon:start-test
- name: axon start test
run: |
cd ${{ github.workspace }}/../docker-deploy
sudo rm -rf logs*
sudo rm -rf devtools/chain/data*
sed -i 's/image:.*$/image: axonweb3\/axon:start-test/g' docker-compose.yml
cp ${{ github.workspace }}/devtools/chain/specs/multi_nodes_short_epoch_len/chain-spec.toml devtools/chain/specs/multi_nodes/chain-spec.toml
cp ${{ github.workspace }}/devtools/chain/specs/multi_nodes_short_epoch_len/genesis_transactions.json devtools/chain/specs/multi_nodes/genesis_transactions.json
cp ${{ github.workspace }}/devtools/chain/k8s/node_1.toml devtools/chain/node_1.toml
cp ${{ github.workspace }}/devtools/chain/k8s/node_2.toml devtools/chain/node_2.toml
cp ${{ github.workspace }}/devtools/chain/k8s/node_3.toml devtools/chain/node_3.toml
cp ${{ github.workspace }}/devtools/chain/k8s/node_4.toml devtools/chain/node_4.toml
docker-compose up -d
docker-compose ps -a
sleep 700
set +e
result_axon1=$(tail -n 100 logs1/axon.log | grep 'state goto new height 200')
result_axon2=$(tail -n 100 logs2/axon.log | grep 'state goto new height 200')
result_axon3=$(tail -n 100 logs3/axon.log | grep 'state goto new height 200')
result_axon4=$(tail -n 100 logs4/axon.log | grep 'state goto new height 200')

docker-compose down
if [[ "$result_axon1" != "" || $result_axon2 != "" || $result_axon3 != "" || $result_axon4 != "" ]]
then
echo "axon chain works well"
else
echo "axon chain has some issues, please have a check"
exit 1
fi
- uses: actions/checkout@v3
- name: Cache of the axon binary
id: axon-bin-cache
uses: actions/cache@v3
with:
path: |
target/debug/axon
target/release/axon
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }}

- name: Start a single Axon node
env:
LOG_FILE: ${{ runner.temp }}/${{ matrix.os }}-single-axon-node.log
run: |
target/debug/axon --version | tee ${{ env.LOG_FILE }}
target/debug/axon run \
--config devtools/chain/config.toml \
--chain-spec devtools/chain/specs/single_node/chain-spec.toml \
| tee ${{ env.LOG_FILE }} &

sleep 10

npx zx <<'EOF'
import { waitXBlocksPassed } from './devtools/ci/scripts/helper.js'
await waitXBlocksPassed('http://127.0.0.1:8000', 2);
EOF
timeout-minutes: 1
- name: Archive logs
if: always()
uses: actions/upload-artifact@v3
with:
name: single-axon-node-logs
path: |
${{ runner.temp }}/${{ matrix.os }}-single-axon-node.log

multi-nodes:
needs: build-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-20.04] # TODO: test on [ubuntu-22.04, windows-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Cache of the axon binary
id: axon-bin-cache
uses: actions/cache@v3
with:
path: |
target/debug/axon
target/release/axon
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }}

- name: Start multiple Axon nodes
env:
LOG_PATH: ${{ runner.temp }}/${{ matrix.os }}/multi-axon-nodes
run: |
mkdir -p ${{ env.LOG_PATH }}

target/debug/axon --version
target/debug/axon run \
--config devtools/chain/nodes/node_1.toml \
--chain-spec devtools/chain/specs/multi_nodes_short_epoch_len/chain-spec.toml \
> ${{ env.LOG_PATH }}/node_1.log &
target/debug/axon run \
--config devtools/chain/nodes/node_2.toml \
--chain-spec devtools/chain/specs/multi_nodes_short_epoch_len/chain-spec.toml \
> ${{ env.LOG_PATH }}/node_2.log &
target/debug/axon run \
--config devtools/chain/nodes/node_3.toml \
--chain-spec devtools/chain/specs/multi_nodes_short_epoch_len/chain-spec.toml \
> ${{ env.LOG_PATH }}/node_3.log &
target/debug/axon run \
--config devtools/chain/nodes/node_4.toml \
--chain-spec devtools/chain/specs/multi_nodes_short_epoch_len/chain-spec.toml \
> ${{ env.LOG_PATH }}/node_4.log &

npx zx <<'EOF'
import { waitXBlocksPassed } from './devtools/ci/scripts/helper.js'
await Promise.all([
waitXBlocksPassed('http://127.0.0.1:8001', 4),
waitXBlocksPassed('http://127.0.0.1:8002', 4),
waitXBlocksPassed('http://127.0.0.1:8003', 4),
waitXBlocksPassed('http://127.0.0.1:8004', 4),
])
EOF
timeout-minutes: 1

- name: Archive logs
if: always()
uses: actions/upload-artifact@v3
with:
name: multi-axon-nodes-logs
path: |
${{ runner.temp }}/${{ matrix.os }}/multi-axon-nodes/
yangby-cryptape marked this conversation as resolved.
Show resolved Hide resolved
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Axon Binary

on:
push:
pull_request:
merge_group:
workflow_dispatch:
# Rather than copying and pasting from one workflow to another, you can make workflows reusable.
# See https://docs.github.com/en/actions/using-workflows/reusing-workflows
workflow_call:

jobs:
build-and-cache:
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-20.04, ubuntu-22.04] # TODO: test on [windows-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Cache of the Axon binary
id: axon-bin-cache
uses: actions/cache@v3
with:
path: |
target/debug/axon
target/release/axon
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }}
yangby-cryptape marked this conversation as resolved.
Show resolved Hide resolved

- name: Cache of Cargo
uses: actions/cache@v3
if: steps.axon-bin-cache.outputs.cache-hit != 'true'
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build Axon in the development profile
if: steps.axon-bin-cache.outputs.cache-hit != 'true'
run: cargo build

# TOOD: not sure if this step is required
# - name: Build a release version of Axon
# if: steps.axon-bin-cache.outputs.cache-hit != 'true'
# run: cargo build --release
23 changes: 19 additions & 4 deletions .github/workflows/openzeppelin_test_11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ on:
required: true

jobs:
# Build Axon and cache the binary
build-axon:
uses: ./.github/workflows/build.yml

openzeppelin-contracts-1:
needs: build-axon
strategy:
fail-fast: false
matrix:
net: ["axon"]
runs-on: ubuntu-latest
# 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 }}
outputs:
output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }}
steps:
Expand Down Expand Up @@ -90,9 +97,16 @@ jobs:
restore-keys: |
${{ runner.os }}-node_modules-

- name: Cache of the axon binary
uses: actions/cache@v3
with:
path: |
target/debug/axon
target/release/axon
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }}

- name: Deploy Local Network of Axon
run: |
cargo build
rm -rf ./devtools/chain/data
./target/debug/axon run --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 &

Expand All @@ -118,6 +132,7 @@ jobs:
with:
name: jfoa-build-reports-${{ runner.os }}
path: openzeppelin-contracts/mochawesome-report/

finally:
name: Finally
needs: [ openzeppelin-contracts-1 ]
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/openzeppelin_test_16_19.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ on:
required: true

jobs:
# Build Axon and cache the binary
build-axon:
uses: ./.github/workflows/build.yml

openzeppelin-contracts-1:
needs: build-axon
strategy:
fail-fast: false
matrix:
net: ["axon"]
runs-on: ubuntu-latest
# 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 }}
outputs:
output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }}
steps:
Expand Down Expand Up @@ -90,9 +97,16 @@ jobs:
restore-keys: |
${{ runner.os }}-node_modules-

- name: Cache of the axon binary
uses: actions/cache@v3
with:
path: |
target/debug/axon
target/release/axon
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }}

- name: Deploy Local Network of Axon
run: |
cargo build
rm -rf ./devtools/chain/data
./target/debug/axon run --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 &

Expand Down Expand Up @@ -133,6 +147,7 @@ jobs:
with:
name: jfoa-build-reports-${{ runner.os }}
path: openzeppelin-contracts/mochawesome-report/

finally:
name: Finally
needs: [ openzeppelin-contracts-1 ]
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/openzeppelin_test_1_5_and_12_15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ on:
required: true

jobs:
# Build Axon and cache the binary
build-axon:
uses: ./.github/workflows/build.yml

openzeppelin-contracts-1:
needs: build-axon
strategy:
fail-fast: false
matrix:
net: ["axon"]
runs-on: ubuntu-latest
# 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 }}
outputs:
output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }}
steps:
Expand Down Expand Up @@ -90,10 +97,17 @@ jobs:
key: ${{ runner.os }}-node_modules-${{ hashFiles('/home/runner/work/**/package-lock.json', '/home/runner/work/**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-

- name: Cache of the axon binary
uses: actions/cache@v3
with:
path: |
target/debug/axon
target/release/axon
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }}

- name: Deploy Local Network of Axon
run: |
cargo build
rm -rf ./devtools/chain/data
./target/debug/axon run --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 &

Expand Down Expand Up @@ -159,6 +173,7 @@ jobs:
with:
name: jfoa-build-reports-${{ runner.os }}
path: openzeppelin-contracts/mochawesome-report/

finally:
name: Finally
needs: [ openzeppelin-contracts-1 ]
Expand Down
Loading