diff --git a/.github/workflow-templates/zombienet-tests/action.yml b/.github/workflow-templates/zombienet-tests/action.yml new file mode 100644 index 000000000..9b3d80cc5 --- /dev/null +++ b/.github/workflow-templates/zombienet-tests/action.yml @@ -0,0 +1,62 @@ +name: Zombienet Tests +description: | + Downloads tanssi binaries compiled in previous step, and executes zombienet test suite using moonwall. + Uploads zombienet logs as an artifact in case of failure. + +inputs: + test_name: + description: Zombienet suite to run + required: true + +runs: + using: "composite" + steps: + - name: Pnpm + uses: pnpm/action-setup@v3.0.0 + with: + version: 8 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: "pnpm" + + - name: "Download binaries" + uses: actions/download-artifact@v4 + with: + name: binaries + path: target/release + + - name: "Run zombie test" + shell: bash + run: | + chmod uog+x target/release/tanssi-node + chmod uog+x target/release/tanssi-relay + chmod uog+x target/release/tanssi-relay-prepare-worker + chmod uog+x target/release/tanssi-relay-execute-worker + chmod uog+x target/release/container-chain-simple-node + chmod uog+x target/release/container-chain-frontier-node + + cd test + pnpm install + + ## Run tests + pnpm moonwall test ${{ inputs.test_name }} + + - name: "Gather zombie logs" + if: failure() + shell: bash + run: | + ls -ltr /tmp + latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ") + logs_dir="logs" + mkdir -p "$logs_dir" + find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \; + + - name: "Upload zombie logs" + if: failure() + uses: actions/upload-artifact@v4 + with: + name: logs-${{ inputs.test_name }} + path: logs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a32f5e75..7ee29a61c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -552,228 +552,26 @@ jobs: zombienet-tests: runs-on: self-hosted needs: ["set-tags", "build"] + strategy: + fail-fast: false + matrix: + test_name: [zombie_tanssi, zombie_tanssi_parathreads, zombie_tanssi_rotation, zombie_tanssi_warp_sync, zombie_tanssi_relay] steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ needs.set-tags.outputs.git_ref }} - - - name: Pnpm - uses: pnpm/action-setup@v3.0.0 - with: - version: 8 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "pnpm" - - - name: "Download binaries" - uses: actions/download-artifact@v4 - with: - name: binaries - path: target/release - - - name: "Run zombie test" - run: | - chmod uog+x target/release/tanssi-node - chmod uog+x target/release/container-chain-simple-node - chmod uog+x target/release/container-chain-frontier-node - - cd test - pnpm install - - ## Run tests - - pnpm moonwall test zombie_tanssi - - - name: "Gather zombie logs" - if: failure() - run: | - ls -ltr /tmp - latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ") - logs_dir="logs" - mkdir -p "$logs_dir" - find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \; - - - name: "Upload zombie logs" - if: failure() - uses: actions/upload-artifact@v4 - with: - name: logs - path: logs - - zombienet-tests-parathreads: - runs-on: ubuntu-latest - needs: ["set-tags", "build"] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ needs.set-tags.outputs.git_ref }} - - - name: Pnpm - uses: pnpm/action-setup@v3.0.0 - with: - version: 8 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "pnpm" - - - name: "Download binaries" - uses: actions/download-artifact@v4 - with: - name: binaries - path: target/release - - - name: "Run zombie test" - run: | - chmod uog+x target/release/tanssi-node - chmod uog+x target/release/container-chain-simple-node - chmod uog+x target/release/container-chain-frontier-node - - cd test - pnpm install - - ## Run tests - - pnpm moonwall test zombie_tanssi_parathreads - - - name: "Gather zombie logs" - if: failure() - run: | - ls -ltr /tmp - latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ") - logs_dir="logs" - mkdir -p "$logs_dir" - find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \; - - - name: "Upload zombie logs" - if: failure() - uses: actions/upload-artifact@v4 - with: - name: logs-parathreads - path: logs - - zombienet-tests-rotation: - runs-on: self-hosted - needs: ["set-tags", "build"] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ needs.set-tags.outputs.git_ref }} - - - name: Pnpm - uses: pnpm/action-setup@v3.0.0 - with: - version: 8 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "pnpm" - - - name: "Download binaries" - uses: actions/download-artifact@v4 - with: - name: binaries - path: target/release - - - name: "Run zombie test" - run: | - chmod uog+x target/release/tanssi-node - chmod uog+x target/release/container-chain-simple-node - chmod uog+x target/release/container-chain-frontier-node - - cd test - pnpm install - - ## Run tests - - pnpm moonwall test zombie_tanssi_rotation - - - name: "Gather zombie logs" - if: failure() - run: | - ls -ltr /tmp - latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ") - logs_dir="logs" - mkdir -p "$logs_dir" - find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \; - - - name: "Upload zombie logs" - if: failure() - uses: actions/upload-artifact@v4 - with: - name: logs-rotation - path: logs - - zombienet-tests-warp-sync: - runs-on: ubuntu-latest - needs: ["set-tags", "build"] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ needs.set-tags.outputs.git_ref }} - - - name: Pnpm - uses: pnpm/action-setup@v3.0.0 - with: - version: 8 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "pnpm" - - - name: "Download binaries" - uses: actions/download-artifact@v4 - with: - name: binaries - path: target/release - - - name: "Run zombie test" - run: | - chmod uog+x target/release/tanssi-node - chmod uog+x target/release/container-chain-simple-node - chmod uog+x target/release/container-chain-frontier-node - - cd test - pnpm install - - ## Run tests - - pnpm moonwall test zombie_tanssi_warp_sync - - - name: "Gather zombie logs" - if: failure() - run: | - ls -ltr /tmp - latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ") - logs_dir="logs" - mkdir -p "$logs_dir" - find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \; - - - name: "Upload zombie logs" - if: failure() - uses: actions/upload-artifact@v4 - with: - name: logs-warp-sync - path: logs + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ needs.set-tags.outputs.git_ref }} + - name: Run Zombienet Test ${{ matrix.test_name }} + uses: ./.github/workflow-templates/zombienet-tests + with: + test_name: ${{ matrix.test_name }} chopsticks-upgrade-test: runs-on: labels: ubuntu-latest needs: ["set-tags", "build"] strategy: + fail-fast: false matrix: chains: [ { chain: "stagenet_dancebox", runtime: "dancebox" }, @@ -815,6 +613,7 @@ jobs: runs-on: self-hosted needs: ["set-tags", "build"] strategy: + fail-fast: false matrix: chain: ["dancebox"] steps: @@ -894,6 +693,7 @@ jobs: runs-on: self-hosted needs: ["set-tags", "build"] strategy: + fail-fast: false matrix: chains: [ { chain: "frontier_template", runtime: "container-chain-template-frontier" }, @@ -937,67 +737,11 @@ jobs: pnpm install pnpm moonwall test zombie_${{ matrix.chains.chain }}_upgrade - zombienet-tests-tanssi-relay: - runs-on: self-hosted - needs: ["set-tags", "build"] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ needs.set-tags.outputs.git_ref }} - - - name: Pnpm - uses: pnpm/action-setup@v3.0.0 - with: - version: 8 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: 20.x - cache: "pnpm" - - - name: "Download binaries" - uses: actions/download-artifact@v4 - with: - name: binaries - path: target/release - - - name: "Run zombie test" - run: | - chmod uog+x target/release/tanssi-node - chmod uog+x target/release/tanssi-relay - chmod uog+x target/release/tanssi-relay-execute-worker - chmod uog+x target/release/tanssi-relay-prepare-worker - chmod uog+x target/release/container-chain-simple-node - - cd test - pnpm install - - ## Run tests - - pnpm moonwall test zombie_tanssi_relay - - - name: "Gather zombie logs" - if: failure() - run: | - ls -ltr /tmp - latest_zombie_dir=$(find /tmp -type d -iname "*zombie*" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" ") - logs_dir="logs" - mkdir -p "$logs_dir" - find "$latest_zombie_dir" -type f -name "*.log" -exec cp {} "$logs_dir" \; - - - name: "Upload zombie logs" - if: failure() - uses: actions/upload-artifact@v4 - with: - name: logs-tanssi-relay - path: logs - docker-tanssi: runs-on: ubuntu-latest needs: ["set-tags", "build"] strategy: + fail-fast: false matrix: image: ["tanssi", "container-chain-simple-template", "container-chain-evm-template"] if: ${{ (needs.set-tags.outputs.image_exists == 'false') && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push') }} diff --git a/.github/workflows/run-zombienet-tests.yml b/.github/workflows/run-zombienet-tests.yml new file mode 100644 index 000000000..cf6f2229c --- /dev/null +++ b/.github/workflows/run-zombienet-tests.yml @@ -0,0 +1,143 @@ +name: Manually run all zombienet tests + +on: + workflow_dispatch: + inputs: + test_name: + description: "Name of the test suite to be run (e.g. zombie_flashbox, supports regex)" + required: true + type: string + default: ".*" + foundation_type: + description: Foundation type to filter tests, select zombie to run all zombienet tests + required: true + type: choice + default: "zombie" + options: + - "*" + - zombie + - dev + - chopsticks + - read_only + +jobs: + # Preliminary job to get the list of tests + get-tests: + runs-on: self-hosted + outputs: + matrix: ${{ steps.set_tests.outputs.tests }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Pnpm + uses: pnpm/action-setup@v3.0.0 + with: + version: 8 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: "pnpm" + + - name: Get test names + id: get_tests + run: | + foundation_type=${{ github.event.inputs.foundation_type || 'zombie' }} + test_name=${{ github.event.inputs.test_name || '.*' }} + + # Read and filter the tests from the config file using regex and foundation type + # Exclude zombie upgrade tests because they need more complex logic, using docker + tests=$(jq -r --arg type "$foundation_type" --arg regex "$test_name" ' + .environments + | map(select((.foundation.type == $type or $type == "*") and (.name | test($regex)))) + | map(.name) + | if $type == "zombie" then map(select(test("_upgrade$") | not)) else . end # Exclude upgrade tests only if foundation type is zombie + ' test/moonwall.config.json | jq -c '.') + + echo "Will run tests: $tests" + if [ -z "$tests" ]; then + echo "No tests found. Exiting." + exit 1 + fi + echo "tests=$tests" >> $GITHUB_ENV + + - name: Set tests output + id: set_tests + run: | + include_tests=$(echo '${{ env.tests }}' | jq -c '{include: . | map({test_name: .})}') + echo "tests=$include_tests" >> $GITHUB_OUTPUT + + ####### Building binaries ####### + build: + runs-on: self-hosted + needs: [ "get-tests" ] + env: + TMP_TARGET: "/tmp/target" + CARGO_TARGET_DIR: "target" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ needs.set-tags.outputs.git_ref }} + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.4 + - name: Setup Variables + shell: bash + run: | + echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "SCCACHE_CACHE_SIZE=100GB" >> $GITHUB_ENV + # Set RUSTFLAGS if not already set + if [ -z "$RUSTFLAGS" ]; then + echo "RUSTFLAGS=-C opt-level=3 -D warnings -C linker=clang -C link-arg=-fuse-ld=$(pwd)/mold/bin/mold" >> $GITHUB_ENV + fi + - name: Setup Mold Linker + shell: bash + run: | + mkdir -p mold + curl -L --retry 10 --silent --show-error https://github.com/rui314/mold/releases/download/v2.30.0/mold-2.30.0-$(uname -m)-linux.tar.gz | tar -C $(realpath mold) --strip-components=1 -xzf - + - name: Setup Rust toolchain + run: rustup show + - name: Build + run: cargo build --features=fast-runtime --release --all + - name: Save runtime wasm + run: | + mkdir -p runtimes + cp $CARGO_TARGET_DIR/release/wbuild/container-chain-template-simple-runtime/container_chain_template_simple_runtime.compact.compressed.wasm runtimes/; + cp $CARGO_TARGET_DIR/release/wbuild/container-chain-template-frontier-runtime/container_chain_template_frontier_runtime.compact.compressed.wasm runtimes/; + cp $CARGO_TARGET_DIR/release/wbuild/dancebox-runtime/dancebox_runtime.compact.compressed.wasm runtimes/; + cp $CARGO_TARGET_DIR/release/wbuild/flashbox-runtime/flashbox_runtime.compact.compressed.wasm runtimes/; + - name: Upload runtimes + uses: actions/upload-artifact@v4 + with: + name: runtimes + path: runtimes + - name: Save tanssi and template binaries + run: | + mkdir -p binaries + cp $CARGO_TARGET_DIR/release/tanssi-node binaries/tanssi-node; + cp $CARGO_TARGET_DIR/release/tanssi-relay binaries/tanssi-relay; + cp $CARGO_TARGET_DIR/release/tanssi-relay-prepare-worker binaries/tanssi-relay-prepare-worker; + cp $CARGO_TARGET_DIR/release/tanssi-relay-execute-worker binaries/tanssi-relay-execute-worker; + cp $CARGO_TARGET_DIR/release/container-chain-frontier-node binaries/container-chain-frontier-node; + cp $CARGO_TARGET_DIR/release/container-chain-simple-node binaries/container-chain-simple-node; + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: binaries + path: binaries + + # Run each test as a separate job using a matrix strategy + run-tests: + runs-on: self-hosted + needs: [ "get-tests", "build" ] + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.get-tests.outputs.matrix) }} + steps: + - name: Run Zombienet Test ${{ matrix.test_name }} + uses: ./.github/workflow-templates/zombienet-tests + with: + test_name: ${{ matrix.test_name }} diff --git a/test/moonwall.config.json b/test/moonwall.config.json index 2677cc343..c7b295b31 100644 --- a/test/moonwall.config.json +++ b/test/moonwall.config.json @@ -175,7 +175,7 @@ "runScripts": [ "build-spec-flashbox.sh", "download-polkadot.sh", - "compile-wasm.ts compile -b ../target/release/tanssi-node -o wasm -c specs/tanssi-1000.json", + "compile-wasm.ts compile -b ../target/release/tanssi-node -o wasm -c specs/flashbox-1000.json", "compile-wasm.ts compile -b ../target/release/container-chain-simple-node -o wasm -c specs/template-container-2000.json", "compile-wasm.ts compile -b ../target/release/container-chain-frontier-node -o wasm -c specs/template-container-2001.json" ],