Skip to content

Commit

Permalink
Merge pull request #383 from liberland/auto-fork-test
Browse files Browse the repository at this point in the history
Autotesting runtime upgrade storage sanity on forked prod networks
  • Loading branch information
DorianSternVukotic authored Jun 16, 2024
2 parents a5c965c + 11331a7 commit 2e704fe
Show file tree
Hide file tree
Showing 12 changed files with 836 additions and 186 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Check formatting

on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main

jobs:
fmt:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C debug-assertions=y"
RUST_BACKTRACE: 1
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v2

# this is needed to make sure that cargo uses the cached target files,
# which will have an older date than the checked out source code.
- name: Restore files timestamps
run: |
# set all dirs and files mtime to the fixed timestamp, this one was chosen
# symbolically as polkadot genesis block date
find . -exec touch -t 202005260100 {} +
# restore mtime based on git commit log
git restore-mtime
- name: Setup caching for rust/cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-rust-${{ hashFiles('**/Cargo.lock') }}

- name: Format code with rustfmt
run: cargo fmt --check -p pallet-liberland-initializer -p pallet-liberland-legislation -p liberland-traits -p pallet-llm -p pallet-office -p pallet-registry -p pallet-custom-account -p pallet-contracts-registry
70 changes: 70 additions & 0 deletions .github/workflows/fork-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Fork test

on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main

jobs:
forktest:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C debug-assertions=y"
RUST_BACKTRACE: 1
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime moreutils

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"

- name: Install check-unknowns script deps
run: yarn
working-directory: substrate/scripts/fork-test/check-unknowns

- name: Standard prod build - mainnet
run: cargo build --release

- name: Run check-unknowns test on mainnet fork
run: |
./run-fork.sh mainnet.config.sh &
cd check-unknowns
timeout 5m npx ts-node src/index.ts
working-directory: substrate/scripts/fork-test

- name: Kill mainnet node
run: killall -9 substrate-node

- name: Standard prod build - bastiat
run: cargo build --release -F testnet-runtime

- name: Run check-unknowns test on mainnet fork
run: |
./run-fork.sh bastiat.config.sh &
cd check-unknowns
timeout 5m npx ts-node src/index.ts
working-directory: substrate/scripts/fork-test

- name: Kill bastiat node
run: killall -9 substrate-node
189 changes: 5 additions & 184 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Check
name: Run tests

on:
pull_request:
Expand All @@ -9,56 +9,6 @@ on:
- main

jobs:
fmt:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C debug-assertions=y"
RUST_BACKTRACE: 1
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v2

# this is needed to make sure that cargo uses the cached target files,
# which will have an older date than the checked out source code.
- name: Restore files timestamps
run: |
# set all dirs and files mtime to the fixed timestamp, this one was chosen
# symbolically as polkadot genesis block date
find . -exec touch -t 202005260100 {} +
# restore mtime based on git commit log
git restore-mtime
- name: Setup caching for rust/cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-rust-${{ hashFiles('**/Cargo.lock') }}

- name: Format code with rustfmt
run: cargo fmt --check -p pallet-liberland-initializer -p pallet-liberland-legislation -p liberland-traits -p pallet-llm -p pallet-office -p pallet-registry -p pallet-custom-account -p pallet-contracts-registry

test:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -86,140 +36,11 @@ jobs:
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# this is needed to make sure that cargo uses the cached target files,
# which will have an older date than the checked out source code.
- name: Restore files timestamps
run: |
# set all dirs and files mtime to the fixed timestamp, this one was chosen
# symbolically as polkadot genesis block date
find . -exec touch -t 202005260100 {} +
# restore mtime based on git commit log
git restore-mtime
- name: Setup caching for rust/cargo
uses: actions/cache@v2
- uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-rust-${{ hashFiles('**/Cargo.lock') }}
cache-all-crates: "true"

- name: Run cargo test suite
run: cargo test -j2 --features runtime-benchmarks

tryruntime:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C debug-assertions=y"
RUST_BACKTRACE: 1
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v2

# this is needed to make sure that cargo uses the cached target files,
# which will have an older date than the checked out source code.
- name: Restore files timestamps
run: |
# set all dirs and files mtime to the fixed timestamp, this one was chosen
# symbolically as polkadot genesis block date
find . -exec touch -t 202005260100 {} +
# restore mtime based on git commit log
git restore-mtime
- name: Setup caching for rust/cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-rust-${{ hashFiles('**/Cargo.lock') }}

- name: Build try-runtime bastiat runtime
run: cargo build --release --features try-runtime,testnet-runtime -p kitchensink-runtime

- name: Install try-runtime CLI
run: cargo install --git https://github.com/paritytech/try-runtime-cli --locked

- name: try-runtime bastiat
run: try-runtime --runtime ./target/release/wbuild/kitchensink-runtime/kitchensink_runtime.wasm on-runtime-upgrade --disable-idempotency-checks --no-weight-warnings live --uri wss://archive.testchain.liberland.org:443

- name: Build try-runtime mainnet runtime
run: cargo build --release --features try-runtime -p kitchensink-runtime

- name: try-runtime mainnet
run: try-runtime --runtime ./target/release/wbuild/kitchensink-runtime/kitchensink_runtime.wasm on-runtime-upgrade --disable-idempotency-checks --no-weight-warnings live --uri wss://mainnet.liberland.org:443

build:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C debug-assertions=y"
RUST_BACKTRACE: 1
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v2

# this is needed to make sure that cargo uses the cached target files,
# which will have an older date than the checked out source code.
- name: Restore files timestamps
run: |
# set all dirs and files mtime to the fixed timestamp, this one was chosen
# symbolically as polkadot genesis block date
find . -exec touch -t 202005260100 {} +
# restore mtime based on git commit log
git restore-mtime
- name: Setup caching for rust/cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-rust-${{ hashFiles('**/Cargo.lock') }}

- name: Check standard production build
run: cargo build --release
run: cargo test -j2 --features runtime-benchmarks
55 changes: 55 additions & 0 deletions .github/workflows/try-runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Try Runtime

on:
pull_request:
workflow_dispatch:
push:
branches:
- develop
- main

jobs:
tryruntime:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C debug-assertions=y"
RUST_BACKTRACE: 1
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential git clang curl libssl-dev llvm libudev-dev make protobuf-compiler pkg-config git-restore-mtime

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rustfmt, clippy

- name: Checkout
uses: actions/checkout@v4

- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"

- name: Build try-runtime bastiat runtime
run: cargo build --release --features try-runtime,testnet-runtime -p kitchensink-runtime

- name: Install try-runtime CLI
run: cargo install --git https://github.com/paritytech/try-runtime-cli --locked

- name: try-runtime bastiat
run: try-runtime --runtime ./target/release/wbuild/kitchensink-runtime/kitchensink_runtime.wasm on-runtime-upgrade --disable-idempotency-checks --no-weight-warnings live --uri wss://archive.testchain.liberland.org:443

- name: Build try-runtime mainnet runtime
run: cargo build --release --features try-runtime -p kitchensink-runtime

- name: try-runtime mainnet
run: try-runtime --runtime ./target/release/wbuild/kitchensink-runtime/kitchensink_runtime.wasm on-runtime-upgrade --disable-idempotency-checks --no-weight-warnings live --uri wss://mainnet.liberland.org:443
Loading

0 comments on commit 2e704fe

Please sign in to comment.