Skip to content

Commit

Permalink
feat: add github action that runs once a day, fetches cumulus, kagome…
Browse files Browse the repository at this point in the history
…, zombienet and WASM binaries and does the necessary zombienet tests.
  • Loading branch information
mikirov committed Aug 2, 2023
1 parent be871a0 commit 6e4bcda
Show file tree
Hide file tree
Showing 25 changed files with 293 additions and 239 deletions.
112 changes: 0 additions & 112 deletions .github/workflows/cumulus-stack-overflow.yaml

This file was deleted.

140 changes: 140 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Daily Workflow

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches:
- feat/cicd

jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- uses: oprypin/find-latest-tag@v1
with:
repository: paritytech/cumulus # The repository to scan.
releases-only: true # We know that all relevant tags have a GitHub release for them.
prefix: 'v'
id: cumulus-binary-release-tag # The step ID to refer to later.

- run: echo "Cumulus binary is at version ${{ steps.cumulus-binary-release-tag.outputs.tag }}"

- uses: oprypin/find-latest-tag@v1
with:
repository: paritytech/cumulus # The repository to scan.
releases-only: true # We know that all relevant tags have a GitHub release for them.
prefix: 'parachains'
id: cumulus-wasm-release-tag # The step ID to refer to later.

- run: echo "Cumulus WASM is at version ${{ steps.cumulus-wasm-release-tag.outputs.tag }}"

- name: Fetch Github Release Asset from polkadot
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "paritytech/polkadot"
file: "polkadot"
target: "polkadot"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Fetch Github Release Asset from polkadot-parachain
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "paritytech/cumulus"
file: "polkadot-parachain"
target: "polkadot-parachain"
version: "tags/${{ steps.cumulus-binary-release-tag.outputs.tag }}"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Fetch Github Release Asset from zombienet
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "paritytech/zombienet"
file: "zombienet-linux-x64"
target: "zombienet"
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Fetch Github Release Asset from cumulus
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "paritytech/cumulus"
file: "rococo-parachain_runtime(.*)wasm"
version: "tags/${{steps.cumulus-wasm-release-tag.outputs.tag}}"
target: "./"
regex: true
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- run: find . -type f -regex '.*/rococo-parachain_runtime.*wasm' -exec mv {} fetched.wasm \;

- name: Fetch kagome
run: |
docker run -v $GITHUB_WORKSPACE:/kagome --rm soramitsu/kagome:latest sh -c "cp /usr/local/bin/kagome . && chmod +x kagome"
- run : |
sudo apt-get update
sudo apt-get install -y --no-install-recommends software-properties-common curl gpg gpg-agent wget
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb http://deb.debian.org/debian/ experimental main" | sudo tee -a /etc/apt/sources.list.d/docker.list > /dev/null
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6ED0E7B82643E131
sudo add-apt-repository -y "deb http://deb.debian.org/debian/ testing main"
sudo apt-get update
sudo apt-get install --no-install-recommends -y libstdc++6 libc6 libnsl2
- name: Debugging
run: |
echo "Current directory:"
pwd
echo "List files:"
ls -la
echo "GLIBC version:"
ldd --version
echo "GITHUB_WORKSPACE value:"
echo "$GITHUB_WORKSPACE"
- name: Add binaries to PATH
run: |
echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH
chmod +x polkadot
chmod +x polkadot-parachain
chmod +x zombienet
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Build
uses: actions-rs/cargo@v1
with:
command: build

- run: mv fetched.wasm ./target/debug/test.wasm

- name: Run wasm_injector
run: |
./target/debug/wasm_injector nothing ./target/debug/test.wasm ./wasm/orig.wasm.hex --hexified
./target/debug/wasm_injector stack-overflow ./target/debug/test.wasm ./wasm/stack-overflow.wasm.hex --hexified
./target/debug/wasm_injector heap-overflow ./target/debug/test.wasm ./wasm/heap-overflow.wasm.hex --hexified
./target/debug/wasm_injector infinite-loop ./target/debug/test.wasm ./wasm/infinite-loop.wasm.hex --hexified
- name: Set up Julia
uses: julia-actions/setup-julia@v1
with:
version: '1.9.1'

- name: Run Julia script
run: julia scripts/runTests.jl

- uses: actions/cache@v3
if: always()
with:
path: |
./tests_output
key: test-output-${{github.run_number}}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
/target
/Cargo.lock
.DS_Store
*.log
*.log
polkadot-parachain
polkadot
kagome
46 changes: 18 additions & 28 deletions scripts/runTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,18 @@ tests_dir::String = get(ENV ,"ZN_TESTS", "./tests")
# Test output path
tests_output::String = get(ENV, "ZN_TEST_OUTPUT", "./tests_output")

# Filter out the non-`.zndsl` files, just to be safe
tests::Vector{String} = filter(file -> endswith(file, ".zndsl"), readdir(tests_dir))

# Arrays to accumulate passed and failed test names
passed_tests::Vector{String} = []
failed_tests::Vector{String} = []

# Helper for piping both outputs
function redirect_stdout_stderr(dofunc, outfile, errfile)
open(outfile, "w") do out
open(errfile, "w") do err
redirect_stdout(out) do
redirect_stderr(err) do
dofunc()
end
end
end
end
end

# For each host ...
for host::String in hosts
withenv("ZOMBIENET_DEFAULT_START_COMMAND" => host) do
# Get host tests directory
host_tests_dir::String = joinpath(tests_dir, host)
# Filter out the non-`.zndsl` files for each host
tests::Vector{String} = filter(file -> endswith(file, ".zndsl"), readdir(host_tests_dir))

# ... run each test
for test::String in tests
if endswith(test, ".zndsl")
Expand All @@ -42,25 +31,21 @@ for host::String in hosts
test_name::String = match_captures[2]

# Prepare the `zombienet test` command
command::Cmd = `zombienet -p native test $(joinpath(tests_dir, test))`
println("Running test [$(host)] $(test_name)")
command::Cmd = `zombienet -p native test $(joinpath(host_tests_dir, test))`
full_test_name::String = "[$(host)] $(test_name)"
println("Running test $(full_test_name)")

# Try to run the test
try
# Create the output files
output_stdout = joinpath(tests_output, "output_$(index)-$(test_name)_stdout.log")
output_stderr = joinpath(tests_output, "output_$(index)-$(test_name)_stderr.log")

# Try to run the command and capture its output
redirect_stdout_stderr(output_stdout, output_stderr) do
run(command)
end
# Try to run the command
run(command)

# Add the test name to the passed tests array
push!(passed_tests, test_name)
push!(passed_tests, full_test_name)
catch e
showerror(stdout, e)
# Add the test name to the failed tests array
push!(failed_tests, test_name)
push!(failed_tests, full_test_name)
end
end
end
Expand All @@ -73,3 +58,8 @@ println(passed_tests)

println("Failed tests:")
println(failed_tests)

# Exit with an error code if any tests failed
if length(failed_tests) > 0
exit(1)
end
32 changes: 0 additions & 32 deletions tests/0001-parachains-pvf-compilation-time-bad.toml

This file was deleted.

19 changes: 0 additions & 19 deletions tests/0001-parachains-pvf-compilation-time-bad.zndsl

This file was deleted.

Loading

0 comments on commit 6e4bcda

Please sign in to comment.