From 116130f8bdd44eb093c73b323f9f1116282b3f71 Mon Sep 17 00:00:00 2001 From: Boyu Yang Date: Thu, 31 Aug 2023 18:15:26 +0800 Subject: [PATCH] chore(cli): apply new cli to documents and scripts --- .../axon-start-with-short-genesis.yml | 37 ++++++++++++++----- .github/workflows/openzeppelin_test_11.yml | 3 +- .github/workflows/openzeppelin_test_16_19.yml | 3 +- .../openzeppelin_test_1_5_and_12_15.yml | 5 ++- .github/workflows/openzeppelin_test_6_10.yml | 5 ++- .github/workflows/somking_test.yml | 3 +- .github/workflows/v3_core_test.yml | 3 +- .github/workflows/web3_compatible.yml | 9 +++-- Dockerfile | 2 +- Makefile | 6 ++- README.md | 3 +- devtools/chain/docker-compose.yml | 3 +- devtools/docker/docker-entrypoint.sh | 10 +++++ 13 files changed, 66 insertions(+), 26 deletions(-) create mode 100755 devtools/docker/docker-entrypoint.sh diff --git a/.github/workflows/axon-start-with-short-genesis.yml b/.github/workflows/axon-start-with-short-genesis.yml index 1c60101e6..a2906cda3 100644 --- a/.github/workflows/axon-start-with-short-genesis.yml +++ b/.github/workflows/axon-start-with-short-genesis.yml @@ -37,10 +37,13 @@ jobs: LOG_FILE: ${{ runner.temp }}/${{ matrix.os }}-single-axon-node.log run: | target/debug/axon --version | tee ${{ env.LOG_FILE }} - target/debug/axon run \ + target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - | tee ${{ env.LOG_FILE }} & + | tee -a ${{ env.LOG_FILE }} + target/debug/axon run \ + --config devtools/chain/config.toml \ + | tee -a ${{ env.LOG_FILE }} & sleep 10 @@ -85,22 +88,36 @@ jobs: mkdir -p ${{ env.LOG_PATH }} target/debug/axon --version - target/debug/axon run \ + + target/debug/axon init \ --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 \ + > ${{ env.LOG_PATH }}/node_1.log + target/debug/axon init \ --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 \ + > ${{ env.LOG_PATH }}/node_2.log + target/debug/axon init \ --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 \ + > ${{ env.LOG_PATH }}/node_3.log + target/debug/axon init \ --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 & + > ${{ env.LOG_PATH }}/node_4.log + + target/debug/axon run \ + --config devtools/chain/nodes/node_1.toml \ + >> ${{ env.LOG_PATH }}/node_1.log & + target/debug/axon run \ + --config devtools/chain/nodes/node_2.toml \ + >> ${{ env.LOG_PATH }}/node_2.log & + target/debug/axon run \ + --config devtools/chain/nodes/node_3.toml \ + >> ${{ env.LOG_PATH }}/node_3.log & + target/debug/axon run \ + --config devtools/chain/nodes/node_4.toml \ + >> ${{ env.LOG_PATH }}/node_4.log & npx zx <<'EOF' import { waitXBlocksPassed } from './devtools/ci/scripts/helper.js' diff --git a/.github/workflows/openzeppelin_test_11.yml b/.github/workflows/openzeppelin_test_11.yml index a356b65a0..497b899f7 100644 --- a/.github/workflows/openzeppelin_test_11.yml +++ b/.github/workflows/openzeppelin_test_11.yml @@ -108,7 +108,8 @@ jobs: - name: Deploy Local Network of Axon run: | 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & - name: Run prepare id: runtest diff --git a/.github/workflows/openzeppelin_test_16_19.yml b/.github/workflows/openzeppelin_test_16_19.yml index 7bb7b08b5..db71b3f0a 100644 --- a/.github/workflows/openzeppelin_test_16_19.yml +++ b/.github/workflows/openzeppelin_test_16_19.yml @@ -108,7 +108,8 @@ jobs: - name: Deploy Local Network of Axon run: | 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & - name: Run prepare id: runtest diff --git a/.github/workflows/openzeppelin_test_1_5_and_12_15.yml b/.github/workflows/openzeppelin_test_1_5_and_12_15.yml index c3b68e357..dcc94a024 100644 --- a/.github/workflows/openzeppelin_test_1_5_and_12_15.yml +++ b/.github/workflows/openzeppelin_test_1_5_and_12_15.yml @@ -97,7 +97,7 @@ 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: @@ -109,7 +109,8 @@ jobs: - name: Deploy Local Network of Axon run: | 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & - name: Run prepare id: runtest diff --git a/.github/workflows/openzeppelin_test_6_10.yml b/.github/workflows/openzeppelin_test_6_10.yml index 58371e4e5..a014dc6fa 100644 --- a/.github/workflows/openzeppelin_test_6_10.yml +++ b/.github/workflows/openzeppelin_test_6_10.yml @@ -104,11 +104,12 @@ jobs: target/debug/axon target/release/axon key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-axon-${{ github.sha }} - + - name: Deploy Local Network of Axon run: | 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & - name: Run prepare id: runtest run: | diff --git a/.github/workflows/somking_test.yml b/.github/workflows/somking_test.yml index 471f9be7b..3195eecb0 100644 --- a/.github/workflows/somking_test.yml +++ b/.github/workflows/somking_test.yml @@ -23,7 +23,8 @@ jobs: - name: Start axon run: | cd ${{ github.workspace }}/axon - ./axon run --config ${{ github.workspace }}/axon/config.toml --chain-spec ${{ github.workspace }}/axon/specs/single_node/chain-spec.toml > /tmp/log 2>&1 & + ./axon init --config ${{ github.workspace }}/axon/config.toml --chain-spec ${{ github.workspace }}/axon/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./axon run --config ${{ github.workspace }}/axon/config.toml >> /tmp/log 2>&1 & sleep 120 - name: Check Axon Status run: | diff --git a/.github/workflows/v3_core_test.yml b/.github/workflows/v3_core_test.yml index 9c3e1825b..a512b25d6 100644 --- a/.github/workflows/v3_core_test.yml +++ b/.github/workflows/v3_core_test.yml @@ -97,7 +97,8 @@ jobs: - name: Deploy Local Network of Axon run: | 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & - name: Install dependencies run: | cd /home/runner/work/axon/axon/v3-core diff --git a/.github/workflows/web3_compatible.yml b/.github/workflows/web3_compatible.yml index 710887581..a23d6eba0 100644 --- a/.github/workflows/web3_compatible.yml +++ b/.github/workflows/web3_compatible.yml @@ -18,7 +18,7 @@ jobs: os: [ubuntu-22.04] fail-fast: false runs-on: ${{ matrix.os }} - env: + env: IS_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }} IS_REGRESSION: ${{ github.event.inputs.dispatch == 'regression' }} @@ -66,10 +66,13 @@ jobs: - name: Deploy Local Network of Axon run: | rm -rf ./devtools/chain/data - ./target/debug/axon run \ + ./target/debug/axon init \ --config devtools/chain/config.toml \ --chain-spec devtools/chain/specs/single_node/chain-spec.toml \ - > /tmp/log 2>&1 & + > /tmp/log 2>&1 + ./target/debug/axon run \ + --config devtools/chain/config.toml \ + >> /tmp/log 2>&1 & - name: Checkout gpBlockchain/axon-test uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index e45e1a299..7eeaf24d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,4 +29,4 @@ RUN set -eux; \ COPY --from=builder /build/target/release/axon /app/axon COPY --from=builder /build/devtools /app/devtools -CMD ./axon run -c=/app/devtools/chain/config.toml -s=/app/devtools/chain/specs/single_node/chain-spec.toml +CMD /app/devtools/docker/docker-entrypoint.sh diff --git a/Makefile b/Makefile index b1047bef5..0822bd691 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,8 @@ e2e-test-lint: e2e-test: 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & cd tests/e2e && yarn cd tests/e2e/src && yarn exec http-server & cd tests/e2e && yarn exec wait-on -t 5000 tcp:8000 && yarn exec wait-on -t 5000 tcp:8080 && yarn test @@ -73,7 +74,8 @@ e2e-test: e2e-test-ci: 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 & + ./target/debug/axon init --config devtools/chain/config.toml --chain-spec devtools/chain/specs/single_node/chain-spec.toml > /tmp/log 2>&1 + ./target/debug/axon run --config devtools/chain/config.toml >> /tmp/log 2>&1 & cd tests/e2e && yarn cd tests/e2e/src && yarn exec http-server & cd tests/e2e && yarn exec wait-on -t 5000 tcp:8000 && yarn exec wait-on -t 5000 tcp:8080 && HEADLESS=true yarn test diff --git a/README.md b/README.md index 3e69da699..22446a6c8 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ Axon provides the compiled binary on the [release page](`https://github.com/axon # Clone from GitHub git clone https://github.com/axonweb3/axon.git && cd axon # Run release binary for single node -cargo run --release -- run -c devtools/chain/config.toml -s devtools/chain/specs/single_node/chain-spec.toml +cargo run --release -- init -c devtools/chain/config.toml -s devtools/chain/specs/single_node/chain-spec.toml +cargo run --release -- run -c devtools/chain/config.toml ``` diff --git a/devtools/chain/docker-compose.yml b/devtools/chain/docker-compose.yml index ca1a2f9f9..5b6115aa1 100644 --- a/devtools/chain/docker-compose.yml +++ b/devtools/chain/docker-compose.yml @@ -15,7 +15,8 @@ services: - axon-net restart: unless-stopped command: | - /app/axon run --config=/app/config.toml --chain-spec=/app/single_node_spec/chain-spec.toml + /app/axon init --config=/app/config.toml --chain-spec=/app/single_node_spec/chain-spec.toml + /app/axon run --config=/app/config.toml explorer: container_name: blockscan diff --git a/devtools/docker/docker-entrypoint.sh b/devtools/docker/docker-entrypoint.sh new file mode 100755 index 000000000..bb79b4187 --- /dev/null +++ b/devtools/docker/docker-entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +DATA_DIR="/app/devtools/chain/data" +CONFIG_FILE="/app/devtools/chain/config.toml" +CHAIN_SPEC_FILE="/app/devtools/chain/specs/single_node/chain-spec.toml" + +if [ ! -e "${DATA_DIR}" ]; then + /app/axon init -c=${CONFIG_FILE} -s=${CHAIN_SPEC_FILE} +fi +/app/axon run -c=${CONFIG_FILE}