Skip to content

Commit 77ad8ab

Browse files
authored
Migrate substrate zombienet test poc (#7178)
Zombienet substrate tests PoC (using native provider). cc: @emamihe @alvicsam
1 parent f7baa84 commit 77ad8ab

4 files changed

+223
-23
lines changed

.github/workflows/build-publish-images.yml

+24-23
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: pack artifacts
5454
run: |
5555
mkdir -p ./artifacts
56-
VERSION="${{ needs.preflight.outputs.SOURCE_REF_NAME }}" # will be tag or branch name
56+
VERSION="${{ needs.preflight.outputs.SOURCE_REF_SLUG }}" # will be tag or branch name
5757
mv ./target/testnet/polkadot ./artifacts/.
5858
mv ./target/testnet/polkadot-prepare-worker ./artifacts/.
5959
mv ./target/testnet/polkadot-execute-worker ./artifacts/.
@@ -62,7 +62,7 @@ jobs:
6262
sha256sum polkadot | tee polkadot.sha256
6363
shasum -c polkadot.sha256
6464
cd ../
65-
EXTRATAG="${{ needs.preflight.outputs.SOURCE_REF_NAME }}-${COMMIT_SHA}"
65+
EXTRATAG="${{ needs.preflight.outputs.SOURCE_REF_SLUG }}-${COMMIT_SHA}"
6666
echo "Polkadot version = ${VERSION} (EXTRATAG = ${EXTRATAG})"
6767
echo -n ${VERSION} > ./artifacts/VERSION
6868
echo -n ${EXTRATAG} > ./artifacts/EXTRATAG
@@ -77,7 +77,7 @@ jobs:
7777
- name: upload artifacts
7878
uses: actions/upload-artifact@v4
7979
with:
80-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
80+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
8181
path: artifacts.tar
8282
retention-days: 1
8383

@@ -103,15 +103,15 @@ jobs:
103103
mkdir -p ./artifacts
104104
mv ./target/release/polkadot-parachain ./artifacts/.
105105
echo "___The VERSION is either a tag name or the curent branch if triggered not by a tag___"
106-
echo ${{ needs.preflight.outputs.SOURCE_REF_NAME }} | tee ./artifacts/VERSION
106+
echo ${{ needs.preflight.outputs.SOURCE_REF_SLUG }} | tee ./artifacts/VERSION
107107
108108
- name: tar
109109
run: tar -cvf artifacts.tar artifacts
110110

111111
- name: upload artifacts
112112
uses: actions/upload-artifact@v4
113113
with:
114-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
114+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
115115
path: artifacts.tar
116116
retention-days: 1
117117

@@ -147,7 +147,7 @@ jobs:
147147
- name: upload artifacts
148148
uses: actions/upload-artifact@v4
149149
with:
150-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
150+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
151151
path: artifacts.tar
152152
retention-days: 1
153153

@@ -172,8 +172,8 @@ jobs:
172172
mkdir -p ./artifacts
173173
mv ./target/testnet/adder-collator ./artifacts/.
174174
mv ./target/testnet/undying-collator ./artifacts/.
175-
echo -n "${{ needs.preflight.outputs.SOURCE_REF_NAME }}" > ./artifacts/VERSION
176-
echo -n "${{ needs.preflight.outputs.SOURCE_REF_NAME }}-${COMMIT_SHA}" > ./artifacts/EXTRATAG
175+
echo -n "${{ needs.preflight.outputs.SOURCE_REF_SLUG }}" > ./artifacts/VERSION
176+
echo -n "${{ needs.preflight.outputs.SOURCE_REF_SLUG }}-${COMMIT_SHA}" > ./artifacts/EXTRATAG
177177
echo "adder-collator version = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))"
178178
echo "undying-collator version = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))"
179179
cp -r ./docker/* ./artifacts
@@ -184,7 +184,7 @@ jobs:
184184
- name: upload artifacts
185185
uses: actions/upload-artifact@v4
186186
with:
187-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
187+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
188188
path: artifacts.tar
189189
retention-days: 1
190190

@@ -209,8 +209,8 @@ jobs:
209209
mv ./target/testnet/malus ./artifacts/.
210210
mv ./target/testnet/polkadot-execute-worker ./artifacts/.
211211
mv ./target/testnet/polkadot-prepare-worker ./artifacts/.
212-
echo -n "${{ needs.preflight.outputs.SOURCE_REF_NAME }}" > ./artifacts/VERSION
213-
echo -n "${{ needs.preflight.outputs.SOURCE_REF_NAME }}-${COMMIT_SHA}" > ./artifacts/EXTRATAG
212+
echo -n "${{ needs.preflight.outputs.SOURCE_REF_SLUG }}" > ./artifacts/VERSION
213+
echo -n "${{ needs.preflight.outputs.SOURCE_REF_SLUG }}-${COMMIT_SHA}" > ./artifacts/EXTRATAG
214214
echo "polkadot-test-malus = $(cat ./artifacts/VERSION) (EXTRATAG = $(cat ./artifacts/EXTRATAG))"
215215
cp -r ./docker/* ./artifacts
216216
@@ -220,7 +220,7 @@ jobs:
220220
- name: upload artifacts
221221
uses: actions/upload-artifact@v4
222222
with:
223-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
223+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
224224
path: artifacts.tar
225225
retention-days: 1
226226

@@ -246,6 +246,7 @@ jobs:
246246
WASM_BUILD_NO_COLOR=1 forklift cargo build --locked --release -p staging-node-cli
247247
ls -la target/release/
248248
- name: pack artifacts
249+
shell: bash
249250
run: |
250251
mv target/release/substrate-node ./artifacts/substrate/substrate
251252
echo -n "Substrate version = "
@@ -264,7 +265,7 @@ jobs:
264265
- name: upload artifacts
265266
uses: actions/upload-artifact@v4
266267
with:
267-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
268+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
268269
path: artifacts.tar
269270
retention-days: 1
270271

@@ -294,7 +295,7 @@ jobs:
294295
- name: upload artifacts
295296
uses: actions/upload-artifact@v4
296297
with:
297-
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
298+
name: ${{ github.job }}-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
298299
path: artifacts.tar
299300
retention-days: 1
300301

@@ -313,7 +314,7 @@ jobs:
313314

314315
- uses: actions/[email protected]
315316
with:
316-
name: build-test-parachain-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
317+
name: build-test-parachain-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
317318

318319
- name: tar
319320
run: tar -xvf artifacts.tar
@@ -337,7 +338,7 @@ jobs:
337338

338339
- uses: actions/[email protected]
339340
with:
340-
name: build-linux-stable-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
341+
name: build-linux-stable-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
341342

342343
- name: tar
343344
run: tar -xvf artifacts.tar
@@ -361,7 +362,7 @@ jobs:
361362

362363
- uses: actions/[email protected]
363364
with:
364-
name: build-test-collators-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
365+
name: build-test-collators-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
365366

366367
- name: tar
367368
run: tar -xvf artifacts.tar
@@ -385,7 +386,7 @@ jobs:
385386

386387
- uses: actions/[email protected]
387388
with:
388-
name: build-malus-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
389+
name: build-malus-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
389390

390391
- name: tar
391392
run: tar -xvf artifacts.tar
@@ -409,7 +410,7 @@ jobs:
409410

410411
- uses: actions/[email protected]
411412
with:
412-
name: build-linux-substrate-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
413+
name: build-linux-substrate-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
413414

414415
- name: tar
415416
run: tar -xvf artifacts.tar
@@ -441,23 +442,23 @@ jobs:
441442

442443
- uses: actions/[email protected]
443444
with:
444-
name: build-linux-stable-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
445+
name: build-linux-stable-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
445446
- name: tar
446447
run: |
447448
tar -xvf artifacts.tar
448449
rm artifacts.tar
449450
450451
- uses: actions/[email protected]
451452
with:
452-
name: build-linux-stable-cumulus-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
453+
name: build-linux-stable-cumulus-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
453454
- name: tar
454455
run: |
455456
tar -xvf artifacts.tar
456457
rm artifacts.tar
457458
458459
- uses: actions/[email protected]
459460
with:
460-
name: prepare-bridges-zombienet-artifacts-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
461+
name: prepare-bridges-zombienet-artifacts-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
461462
- name: tar
462463
run: |
463464
tar -xvf artifacts.tar
@@ -482,7 +483,7 @@ jobs:
482483

483484
- uses: actions/[email protected]
484485
with:
485-
name: build-linux-stable-cumulus-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
486+
name: build-linux-stable-cumulus-${{ needs.preflight.outputs.SOURCE_REF_SLUG }}
486487

487488
- name: tar
488489
run: tar -xvf artifacts.tar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Reusable workflow to set various useful variables
2+
# and to perform checks and generate conditions for other workflows.
3+
# Currently it checks if any Rust (build-related) file is changed
4+
# and if the current (caller) workflow file is changed.
5+
# Example:
6+
#
7+
# jobs:
8+
# preflight:
9+
# uses: ./.github/workflows/reusable-preflight.yml
10+
# some-job:
11+
# needs: changes
12+
# if: ${{ needs.preflight.outputs.changes_rust }}
13+
# .......
14+
15+
name: Zombienet Preflight
16+
17+
on:
18+
workflow_call:
19+
# Map the workflow outputs to job outputs
20+
outputs:
21+
changes_substrate:
22+
value: ${{ jobs.preflight.outputs.changes_substrate }}
23+
24+
ZOMBIENET_IMAGE:
25+
value: ${{ jobs.preflight.outputs.ZOMBIENET_IMAGE }}
26+
description: "ZOMBIENET CI image"
27+
28+
ZOMBIENET_RUNNER:
29+
value: ${{ jobs.preflight.outputs.ZOMBIENET_RUNNER }}
30+
description: |
31+
Main runner for zombienet tests.
32+
33+
DOCKER_IMAGES_VERSION:
34+
value: ${{ jobs.preflight.outputs.DOCKER_IMAGES_VERSION }}
35+
description: |
36+
Version for temp docker images.
37+
38+
# Global vars (from global preflight)
39+
SOURCE_REF_SLUG:
40+
value: ${{ jobs.global_preflight.outputs.SOURCE_REF_SLUG }}
41+
42+
# Zombie vars
43+
PUSHGATEWAY_URL:
44+
value: ${{ jobs.preflight.outputs.PUSHGATEWAY_URL }}
45+
description: "Gateway (url) to push metrics related to test."
46+
DEBUG:
47+
value: ${{ jobs.preflight.outputs.DEBUG }}
48+
description: "Debug value to zombienet v1 tests."
49+
ZOMBIE_PROVIDER:
50+
value: ${{ jobs.preflight.outputs.ZOMBIE_PROVIDER }}
51+
description: "Provider to use in zombienet-sdk tests."
52+
RUST_LOG:
53+
value: ${{ jobs.preflight.outputs.RUST_LOG }}
54+
description: "Log value to use in zombinet-sdk tests."
55+
RUN_IN_CI:
56+
value: ${{ jobs.preflight.outputs.RUN_IN_CI }}
57+
description: "Internal flag to make zombienet aware of the env."
58+
59+
KUBERNETES_CPU_REQUEST:
60+
value: ${{ jobs.preflight.outputs.KUBERNETES_CPU_REQUEST }}
61+
description: "Base cpu (request) for pod runner."
62+
63+
KUBERNETES_MEMORY_REQUEST:
64+
value: ${{ jobs.preflight.outputs.KUBERNETES_MEMORY_REQUEST }}
65+
description: "Base memory (request) for pod runner."
66+
67+
jobs:
68+
global_preflight:
69+
uses: ./.github/workflows/reusable-preflight.yml
70+
71+
#
72+
#
73+
#
74+
preflight:
75+
runs-on: ubuntu-latest
76+
outputs:
77+
changes_substrate: ${{ steps.set_changes.outputs.substrate_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }}
78+
79+
ZOMBIENET_IMAGE: ${{ steps.set_vars.outputs.ZOMBIENET_IMAGE }}
80+
ZOMBIENET_RUNNER: ${{ steps.set_vars.outputs.ZOMBIENET_RUNNER }}
81+
82+
DOCKER_IMAGES_VERSION: ${{ steps.set_images_version.outputs.ZOMBIENET_RUNNER }}
83+
84+
# common vars
85+
PUSHGATEWAY_URL: ${{ steps.set_vars.outputs.PUSHGATEWAY_URL }}
86+
DEBUG: ${{ steps.set_vars.outputs.DEBUG }}
87+
ZOMBIE_PROVIDER: ${{ steps.set_vars.outputs.ZOMBIE_PROVIDER }}
88+
RUST_LOG: ${{ steps.set_vars.outputs.RUST_LOG }}
89+
RUN_IN_CI: ${{ steps.set_vars.outputs.RUN_IN_CI }}
90+
KUBERNETES_CPU_REQUEST: ${{ steps.set_vars.outputs.KUBERNETES_CPU_REQUEST }}
91+
KUBERNETES_MEMORY_REQUEST: ${{ steps.set_vars.outputs.KUBERNETES_MEMORY_REQUEST }}
92+
93+
steps:
94+
95+
- uses: actions/checkout@v4
96+
97+
#
98+
# Set changes
99+
#
100+
- name: Current file
101+
id: current_file
102+
shell: bash
103+
run: |
104+
echo "currentWorkflowFile=$(echo ${{ github.workflow_ref }} | sed -nE "s/.*(\.github\/workflows\/[a-zA-Z0-9_-]*\.y[a]?ml)@refs.*/\1/p")" >> $GITHUB_OUTPUT
105+
echo "currentActionDir=$(echo ${{ github.action_path }} | sed -nE "s/.*(\.github\/actions\/[a-zA-Z0-9_-]*)/\1/p")" >> $GITHUB_OUTPUT
106+
107+
- name: Set changes
108+
id: set_changes
109+
uses: tj-actions/changed-files@v45
110+
with:
111+
files_yaml: |
112+
substrate:
113+
- 'substrate/**/*'
114+
currentWorkflow:
115+
- '${{ steps.current_file.outputs.currentWorkflowFile }}'
116+
- '.github/workflows/zombienet-reusable-preflight.yml'
117+
- '.github/zombienet-env'
118+
119+
120+
#
121+
# Set environment vars (including runner/image)
122+
#
123+
- name: Set vars
124+
id: set_vars
125+
shell: bash
126+
run: cat .github/env >> $GITHUB_OUTPUT
127+
128+
129+
#
130+
#
131+
#
132+
- name: Set docker images version
133+
id: set_images_version
134+
shell: bash
135+
run: |
136+
export BRANCH_NAME=${{ github.head_ref || github.ref_name }}
137+
export DOCKER_IMAGES_VERSION=${BRANCH_NAME/\//-}
138+
if [[ ${{ github.event_name }} == "merge_group" ]]; then export DOCKER_IMAGES_VERSION="${GITHUB_SHA::8}"; fi
139+
echo "DOCKER_IMAGES_VERSION=${DOCKER_IMAGES_VERSION}" >> $GITHUB_OUTPUT
140+
141+
- name: log
142+
shell: bash
143+
run: |
144+
echo "workflow file: ${{ steps.current_file.outputs.currentWorkflowFile }}"
145+
echo "Modified: ${{ steps.set_changes.outputs.modified_keys }}"
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Zombienet Substrate
2+
3+
on:
4+
workflow_run:
5+
workflows: [Build and push images]
6+
types: [completed]
7+
merge_group:
8+
workflow_dispatch:
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
preflight:
15+
uses: ./.github/workflows/zombienet-reusable-preflight.yml
16+
17+
zombienet-substrate-0000-block-building:
18+
needs: [preflight]
19+
# only run if we have changes in ./substrate directory and the build workflow already finish with success status.
20+
if: ${{ needs.preflight.outputs.changes_substrate && github.event.workflow_run.conclusion == 'success' }}
21+
runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }}
22+
timeout-minutes: 60
23+
container:
24+
image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }}
25+
env:
26+
FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: 1
27+
LOCAL_DIR: "./substrate/zombienet"
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- uses: actions/[email protected]
33+
with:
34+
name: build-linux-substrate-${{ needs.preflight.outputs.SOURCE_REF_NAME }}
35+
36+
- name: script
37+
run: |
38+
DEBUG=${{ needs.preflight.outputs.DEBUG }} zombie -p native ${LOCAL_DIR}/0000-block-building/block-building.zndsl
39+
40+
- name: upload logs
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: zombienet-logs-scale-net
44+
path: |
45+
/tmp/zombie*/logs/*

0 commit comments

Comments
 (0)