Skip to content

Merge pull request #1159 from nervosnetwork/dependabot/cargo/tests/de… #6137

Merge pull request #1159 from nervosnetwork/dependabot/cargo/tests/de…

Merge pull request #1159 from nervosnetwork/dependabot/cargo/tests/de… #6137

Workflow file for this run

on: [push, pull_request, workflow_dispatch]
name: E2E tests
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
e2e-testing:
name: e2e test for ${{ matrix.workflow }} --env ${{ matrix.test_env }} ${{ matrix.extra_bru_args }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
workflow:
- 3-nodes-transfer
- invoice-ops
- open-use-close-a-channel
- udt
- reestablish
- cross-chain-hub
- router-pay
- udt-router-pay
- watchtower/force-close
- watchtower/force-close-after-multiple-payments
- watchtower/force-close-after-open-channel
- watchtower/force-close-preimage
- watchtower/force-close-preimage-multiple
- watchtower/force-close-remote-with-pending-tlcs-and-stop-watchtower
- watchtower/force-close-remote-without-pending-tlcs-and-stop-watchtower
- watchtower/force-close-with-consecutive-settlement
- watchtower/force-close-with-pending-tlcs
- watchtower/force-close-with-pending-tlcs-and-stop-watchtower
- watchtower/force-close-with-pending-tlcs-and-udt
- watchtower/revocation
release:
- "0.202.0"
test_env:
- "test"
extra_bru_args:
- ""
include:
# add an extra workflow to run udt using the env file xudt-test
- workflow: "udt"
test_env: "xudt-test"
release: "0.202.0"
# add an extra workflow to run 3-nodes-transfer with sha256 hash algorithm
- workflow: "3-nodes-transfer"
test_env: "test"
release: "0.202.0"
extra_bru_args: "--env-var HASH_ALGORITHM=sha256"
######################################
# Funding Tx Verification Test Cases
- workflow: "funding-tx-verification"
test_env: "test"
release: "0.202.0"
extra_bru_args: "--env-var FUNDING_TX_VERIFICATION_CASE=remove_change"
- workflow: "funding-tx-verification"
test_env: "test"
release: "0.202.0"
extra_bru_args: "--env-var FUNDING_TX_VERIFICATION_CASE=modify_change"
- workflow: "funding-tx-verification"
test_env: "test"
release: "0.202.0"
extra_bru_args: "--env-var FUNDING_TX_VERIFICATION_CASE=fund_from_peer"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
key: e2e-${{ matrix.workflow }}-${{ runner.os }}
- uses: dsherret/rust-toolchain-file@v1
- name: Setup Dependencies
uses: ./.github/actions/setup-dependencies
with:
ckb-version: ${{ matrix.release }}
install-bitcoin-lnd: ${{ matrix.workflow == 'cross-chain-hub' }}
cache-prefix: 'e2e'
- name: Cache build artifacts
uses: actions/cache@v4
with:
path: |
target/
tests/deploy/udt-init/target/
key: e2e-build-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
e2e-build-${{ runner.os }}-
- name: Run e2e workflow
id: e2eTests
run: |
set -euo pipefail
# Save matrix values to generate unique ID for upload-artifact
echo '${{ toJSON(matrix) }}' > matrix.json
# Create a safe workflow name for artifact upload (replace / with -)
SAFE_WORKFLOW_NAME="${{ matrix.workflow }}"
echo "SAFE_WORKFLOW_NAME=${SAFE_WORKFLOW_NAME//\//-}" >> $GITHUB_ENV
# Prebuild the program so that we can run the following script faster
cargo build --locked
cd ./tests/deploy/udt-init && cargo build --locked && cd -
export ON_GITHUB_ACTION=y
# Pass it to tests/funding-tx-builder as args
export EXTRA_BRU_ARGS="${{ matrix.extra_bru_args }}"
./tests/nodes/start.sh "e2e/${{ matrix.workflow }}" &
# when .ports file is not generated, we will retry 20 times to check if all ports are open
./tests/nodes/wait.sh
(cd ./tests/bruno; npm exec -- @usebruno/cli@1.20.0 run e2e/${{ matrix.workflow }} -r --env ${{ matrix.test_env }} ${{ matrix.extra_bru_args }} ) &
# -n means we will exit when any of the background processes exits.
# https://www.gnu.org/software/bash/manual/bash.html#index-wait
wait -n
- uses: actions/upload-artifact@v4
if: failure() && steps.e2eTests.outcome == 'failure'
with:
name: e2e-test-${{ env.SAFE_WORKFLOW_NAME }}-${{ hashFiles('matrix.json') }}-logs
path: tests/nodes/*.log