Skip to content

Note gw alphanet environment tests (#331) #497

Note gw alphanet environment tests (#331)

Note gw alphanet environment tests (#331) #497

name: Integration Test v1
on:
push:
workflow_call:
inputs:
# If `extra_github_env` is set, it will be put into GITHUB_ENV at the beginning of each job
#
# ```
# - name: Update GITHUB_ENV if inputs.extra_github_env set
# if: "${{ inputs.extra_github_env != '' }}"
# run: echo ${{ inputs.extra_github_env }} >> $GITHUB_ENV
# ```
#
# ## Examples
#
# * Specify the kicker version
#
# ```yaml
# extra_github_env: |
# GODWOKEN_TESTS_REPO=keroro520/godwoken-tests # default is godwokenrises/godwoken-tests
# GODWOKEN_TESTS_REF=helloworld # default is develop
# GODWOKEN_KICKER_REPO=godwokenrises/godwoken-kicker # default is godwokenrises/godwoken-kicker
# GODWOKEN_KICKER_REF=develop # default is develop
#
# GODWOKEN_PREBUILD_IMAGE_NAME=ghcr.io/keroro520/godwoken-prebuilds:v1-godwoken-d3eb41a-202205310512 # (deprecated)
# GODWOKEN_IMAGE=ghcr.io/godwokenrises/godwoken:develop
#
# # DEBUG_MODE: if we need more debug logs, we could enable log levels per Godwoken module
# # See https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html#enable-log-levels-per-module
# RUST_LOG=info,ckb_script::verify=debug ...
# ```
extra_github_env:
type: string
description: 'Append write into GITHUB_ENV at the begining of every job'
required: false
jobs:
# Run integration-tests on devnet_v1 deployed by Godowoken-Kicker
test-on-devnet-v1:
runs-on: ubuntu-latest
steps:
- name: Update GITHUB_ENV if inputs.extra_github_env set
if: "${{ inputs.extra_github_env != '' }}"
run: |
echo "${{ inputs.extra_github_env }}" >> $GITHUB_ENV
- name: Checkout godwoken-tests
uses: actions/checkout@v4
with:
repository: ${{ env.GODWOKEN_TESTS_REPO || 'godwokenrises/godwoken-tests' }}
ref: ${{ env.GODWOKEN_TESTS_REF || 'develop' }}
submodules: 'recursive'
- name: Checkout godwoken-kicker
uses: actions/checkout@v4
with:
repository: ${{ env.GODWOKEN_KICKER_REPO || 'godwokenrises/godwoken-kicker' }}
ref: ${{ env.GODWOKEN_KICKER_REF || 'develop' }}
path: kicker
submodules: 'recursive'
- name: Rust Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry
~/.cargo/git
target
kicker/cache/build
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Install moleculec
run: |
test "$(moleculec --version)" = "Moleculec 0.7.2" \
|| CARGO_TARGET_DIR=target/ cargo install moleculec --version 0.7.2 --force
- name: Install Capsule
env:
CAPSULE_VERSION: v0.7.3
run: |
capsule -V \
|| (curl -OL https://github.com/nervosnetwork/capsule/releases/download/${CAPSULE_VERSION}/capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \
&& tar xf capsule_${CAPSULE_VERSION}_x86_64-linux.tar.gz \
&& mv capsule_${CAPSULE_VERSION}_x86_64-linux/capsule ~/.cargo/bin/)
- name: Modify Godwoken image if GODWOKEN_IMAGE is set
if: ${{ env.GODWOKEN_IMAGE }}
uses: mikefarah/yq@v4
with:
cmd: |
echo "Update the image of Godwoken fullnode"
yq -i '.services.godwoken.image = "${{ env.GODWOKEN_IMAGE }}"' kicker/docker/docker-compose.yml
echo "Update the image of Godwoken readonly-node"
yq -i '.services.godwoken-readonly.image = "${{ env.GODWOKEN_IMAGE }}"' kicker/docker/docker-compose.yml
echo "====== kicker/docker/docker-compose.yml ======"
cat kicker/docker/docker-compose.yml
# set up buildx/BuildKit runner in the context,
# make the Docker cache exportable and thus properly cacheable
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Ensure clean state
- name: Run Godwoken-Kicker clean
working-directory: kicker
run: |
./kicker clean
- name: Init Godwoken-Kicker services
working-directory: kicker
run: |
docker system df -v
docker-compose --version
./kicker init
- name: Start Godwoken-Kicker services
timeout-minutes: 45
working-directory: kicker
env:
START_GODWOKEN_V0: true
run: |
# Temporary workaround unreliable web3 health check
(echo " == kicker start attempt: 1 == " && ./kicker start) || \
(echo " == kicker start attempt: 2 == " && ./kicker stop && ./kicker start) || \
(echo " == kicker start failed == " && exit 1)
./kicker logs --tail 6
# - name: Enable offchain validator of Godwoken
# working-directory: kicker
# if: ${{ false }}
# run: |
# sudo chown -R `whoami` workspace/config.toml
# grep -q "\[offchain_validator\]" workspace/config.toml \
# || cat >> workspace/config.toml << __EOF__
# [offchain_validator]
# verify_withdrawal_signature = true
# verify_tx_signature = true
# verify_tx_execution = true
# verify_max_cycles = 140000000
# dump_tx_on_failure = true
# __EOF__
# docker restart docker_godwoken_1
# docker-compose --file docker/docker-compose.yml logs --tail 6
- uses: actions/setup-node@v4
with:
node-version: '18'
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: |
npm --version
echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Get yarn cache directory
id: yarn-cache-dir
run: |
yarn --version
echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Node Cache
uses: actions/cache@v3
id: npm-and-yarn-cache
with:
path: |
${{ steps.npm-cache-dir.outputs.dir }}
${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('contracts/package-lock.json', 'light-godwoken/yarn.lock', 'scripts/light-godwoken-cli/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Light-Godwoken-CLI
working-directory: scripts/light-godwoken-cli
run: ./init.sh
- name: Deposit for 2 dev accounts
working-directory: kicker
run: |
# Deposit for the test accounts defined in `contracts/hardhat.config.js`.
# The corresponding private keys are
# 1390c30e5d5867ee7246619173b5922d3b04009cab9e9d91e14506231281a997
# 2dc6374a2238e414e51874f514b0fa871f8ce0eb1e7ecaa0aed229312ffc91b0
./kicker deposit 0x966B30e576A4d6731996748B48Dd67C94eF29067 10000
./kicker deposit 0x4fef21f1d42e0d23d72100aefe84d555781c31bb 10000
- name: init tools
working-directory: tools
run: |
yarn install && yarn build-all
- name: Wait 1 layer2 blocks passed
uses: actions/github-script@v7
with:
script: |
const { waitXl2BlocksPassed } = require("./scripts/helper");
await waitXl2BlocksPassed(1);
- name: Withdraw for 2 dev accounts
working-directory: scripts/light-godwoken-cli
run: |
lgc withdraw -p 1390c30e5d5867ee7246619173b5922d3b04009cab9e9d91e14506231281a997 -c 400 -n devnet_v1
lgc withdraw -p 2dc6374a2238e414e51874f514b0fa871f8ce0eb1e7ecaa0aed229312ffc91b0 -c 400 -n devnet_v1
- name: Deposit for withdraw from v0 to v1 test
working-directory: kicker
run: |
./kicker deposit 0x966B30e576A4d6731996748B48Dd67C94eF29999 1000
./kicker deposit-v0 10000 # Use ckb-miner key
- name: Wait 1 layer2 blocks passed
uses: actions/github-script@v7
with:
script: |
const { waitXl2BlocksPassed } = require("./scripts/helper");
await waitXl2BlocksPassed(1);
- name: Withdraw from v0 to v1
working-directory: kicker
run: |
./kicker withdraw-v0-to-v1 0x966B30e576A4d6731996748B48Dd67C94eF29999 1000
counter=1
while [ $counter -le 60 ]
do
balance=$(./kicker get-balance 0x966B30e576A4d6731996748B48Dd67C94eF29999 | grep -oE "Balance:\s*[[:digit:]]+" | awk '{print $2}')
echo "current balance: ==${balance}=="
# deposit 1000 + withdraw from v0 1000 (NOTE: CKB decimal is 18, aka 2000 * 10^18)
if [ "$balance" = "2000000000000000000000" ]; then
echo "withdraw from v0 to v1 success"
exit 0
fi
((counter++))
sleep 20s
done
echo "withdraw from v0 to v1 fail"
exit 1
- name: Wait 1 layer2 blocks passed
uses: actions/github-script@v7
with:
script: |
const { waitXl2BlocksPassed } = require("./scripts/helper");
await waitXl2BlocksPassed(1);
- name: Run hardhat test --network gw_devnet_v1
working-directory: contracts
run: npm install && npm run test
# Only enable tmate while debugging
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 30
- name: Save logs
if: always()
working-directory: kicker
run: |
./kicker ps
./kicker logs --tail 66
./kicker logs > /tmp/kicker.log
- name: Archive logs
if: always()
uses: actions/upload-artifact@v4
with:
name: kicker-logs
path: |
/tmp/kicker.log
- name: Archive the dumped transactions in kicker/workspace/debug-tx-dump
if: always()
uses: actions/upload-artifact@v4
with:
name: debug-tx-dump
path: |
kicker/workspace/debug-tx-dump
- name: Stop containers of Kicker
if: always()
working-directory: kicker
run: ./kicker stop