Test rust code #2521
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: Test rust code | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to run the workflow on' | |
required: true | |
run_specific_job: | |
description: 'Specify a job to run (test-runtime, try-runtime-execute, etc.)' | |
required: true | |
env: | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
try-runtime-chain: dev | |
try-runtime-uri: wss://api-eden.dwellir.com:443/ | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
RUSTFLAGS: "" | |
jobs: | |
json-lints: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check for json syntax errors 1 | |
run: "for i in `git ls-tree --full-tree -r --name-only HEAD |grep json$`; do echo Checking $i:; json_pp <$i >/dev/null || echo ERROR: $i failed; done" | |
- name: Check for json syntax errors 2 | |
run: "for i in `git ls-tree --full-tree -r --name-only HEAD |grep json$`; do echo Checking $i:; json_pp <$i >/dev/null ; done" | |
lints: | |
runs-on: ubuntu-latest-8-cores | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup sccache | |
uses: mozilla-actions/sccache-action@v0.0.4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
components: rustfmt, clippy, rust-src | |
target: ${{ env.target }} | |
- name: Rustfmt Check | |
uses: actions-rust-lang/rustfmt@v1 | |
- name: Install protobuf-compiler | |
run: | | |
sudo apt-get install protobuf-compiler | |
- name: Clippy | |
uses: actions-rs-plus/clippy-check@v2 | |
with: | |
args: --all-features -- -A clippy::type_complexity -A clippy::identity_op -A clippy::boxed_local -D dead_code | |
toolchain: ${{ env.toolchain }} | |
test-runtime: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
components: rust-src | |
target: ${{ env.target }} | |
- name: Install protobuf-compiler | |
run: | | |
sudo apt-get install protobuf-compiler | |
- name: Setup sccache | |
uses: mozilla-actions/sccache-action@v0.0.4 | |
- name: Unit tests | |
# Other tests ran below | |
run: cargo test --all-features -p nodle-parachain | |
tests-with-linecoverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
target: ${{ env.target }} | |
components: rust-src | |
- name: Install protobuf-compiler | |
run: | | |
sudo apt-get install protobuf-compiler | |
- name: Setup sccache | |
uses: mozilla-actions/sccache-action@v0.0.4 | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Test and gather coverage | |
run: cargo llvm-cov --lcov --output-path lcov.info --all-features --workspace --exclude nodle-parachain | |
- name: Upload to Codecov | |
uses: codecov/codecov-action@v4.2.0 | |
with: | |
fail_ci_if_error: false | |
files: lcov.info | |
try-runtime-prepare: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install protobuf-compiler | |
run: | | |
sudo apt-get install protobuf-compiler | |
- name: Install Rust stable | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ env.toolchain }} | |
components: rust-src | |
target: ${{ env.target }} | |
- name: Setup sccache | |
uses: mozilla-actions/sccache-action@v0.0.4 | |
- name: Build runtime | |
run: cargo build --release --features=try-runtime -p runtime-eden | |
- name: Upload runtime artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: try_runtime | |
path: target/release/wbuild/runtime-eden/runtime_eden.wasm | |
try-runtime-paradis-execute: | |
runs-on: ubuntu-latest | |
needs: try-runtime-prepare | |
steps: | |
- name: Download runtime artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: try_runtime | |
path: try_runtime | |
- uses: robinraju/release-downloader@v1.9 | |
with: | |
repository: "NodleCode/paradis-snapshot" | |
latest: true | |
fileName: "paradis-snapshot-full.bz2" | |
out-file-path: "snaps" | |
extract: false | |
- run: bunzip2 snaps/paradis-snapshot-full.bz2 | |
- name: Run try-runtime paradis | |
uses: NodleCode/action-try-runtime/check@v0.6.1 | |
with: | |
snap: snaps/paradis-snapshot-full | |
runtime: try_runtime/runtime_eden.wasm | |
checks: "all" | |
options: "--disable-idempotency-checks" | |
try-runtime-eden-execute: | |
runs-on: ubuntu-latest | |
needs: try-runtime-prepare | |
steps: | |
- name: Download runtime artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: try_runtime | |
path: try_runtime | |
- uses: robinraju/release-downloader@v1.9 | |
with: | |
repository: "NodleCode/eden-snapshot" | |
latest: true | |
fileName: "eden-snapshot-full" | |
out-file-path: "snaps" | |
extract: false | |
- name: Run try-runtime | |
uses: NodleCode/action-try-runtime/check@v0.6.1 | |
with: | |
snap: snaps/eden-snapshot-full | |
runtime: try_runtime/runtime_eden.wasm | |
checks: "all" | |
options: "--disable-idempotency-checks" |