Allow manual running of all zombienet tests in CI #4
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: Manually run all zombienet tests | ||
on: | ||
pull_request: | ||
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 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Pnpm | ||
uses: pnpm/[email protected] | ||
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: | | ||
# Read and filter the tests from the config file | ||
if [ "${{ github.event.inputs.foundation_type || 'zombie' }}" = "*" ]; then | ||
tests=$(jq -r --arg regex "${{ github.event.inputs.test_name || '.*' }}" ' | ||
.environments | ||
| map(select(.name | test($regex))) | ||
| map(.name) | ||
' test/moonwall.config.json | jq -c '.') | ||
else | ||
tests=$(jq -r --arg type "${{ github.event.inputs.foundation_type || 'zombie' }}" --arg regex "${{ github.event.inputs.test_name || '.*' }}" ' | ||
.environments | ||
| map(select(.foundation.type == $type)) | ||
| map(select(.name | test($regex))) | ||
| map(.name) | ||
' test/moonwall.config.json | jq -c '.') | ||
fi | ||
echo "Will run tests: $tests" | ||
if [ -z "$tests" ]; then | ||
echo "No tests found. Exiting." | ||
exit 1 | ||
fi | ||
echo "tests=$(echo $tests | jq -c)" >> $GITHUB_ENV | ||
####### 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/[email protected] | ||
- 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: | ||
matrix: | ||
test_name: ${{ fromJson(env.tests) }} | ||
Check failure on line 135 in .github/workflows/run-zombienet-tests.yml GitHub Actions / Manually run all zombienet testsInvalid workflow file
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ needs.set-tags.outputs.git_ref }} | ||
- name: Pnpm | ||
uses: pnpm/[email protected] | ||
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 tanssi-relay-prepare-worker 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 the specific test | ||
pnpm moonwall test "${{ matrix.test_name }}" | ||
- 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" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: logs-${{ matrix.test_name }} | ||
path: logs |