refactor(CI): use reusable `build-axon' job to reduce time consuming #59
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Axon start test | |
on: | |
push: | |
pull_request: | |
merge_group: | |
workflow_dispatch: | |
jobs: | |
# 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: | |
- 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 | |
run: | | |
target/debug/axon --version | |
target/debug/axon run \ | |
-c devtools/chain/config.toml \ | |
-g devtools/chain/genesis_single_node.json \ | |
> ${{ runner.temp }}/${{ matrix.os }}-single-axon-node.log & | |
sleep 300 | |
set +e | |
result=$(tail -n 100 ${{ runner.temp }}/${{ matrix.os }}-single-axon-node.log | grep 'state goto new height 100') | |
if [[ "$result" != "" ]] | |
then | |
echo "axon chain works well" | |
else | |
echo "axon chain has some issues, please have a check" | |
exit 1 | |
fi | |
- name: Archive logs | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: axon-single-node-logs | |
path: | | |
${{ runner.temp }}/${{ matrix.os }}-single-axon-node.log | |
# TODO: | |
# 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, ubuntu-22.04] # TODO: test on [windows-latest, macos-latest] | |
# fail-fast: false | |
# runs-on: ${{ matrix.os }} | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - 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/geneses/genesis_multi_nodes_short_epoch_len.json devtools/chain/genesis_multi_nodes.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 |