Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/rust-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Rust + WASM CI

on:
pull_request:
paths:
- "contracts/**"
- "backend/**"
- "Cargo.toml"
- "Cargo.lock"
push:
branches:
- main
paths:
- "contracts/**"
- "backend/**"
- "Cargo.toml"
- "Cargo.lock"

jobs:
rust-test:
name: Rust unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true

- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Run cargo fmt check
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Run tests
run: cargo test --all-features --workspace --locked --quiet
working-directory: ./contracts

wasm-build:
name: Build WASM artifacts
runs-on: ubuntu-latest
needs: rust-test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Add WASM target
run: rustup target add wasm32-unknown-unknown

- name: Build all contract crates to WASM
run: |
cd contracts
cargo build --all --target wasm32-unknown-unknown --release

- name: Collect built WASM
run: |
mkdir -p artifacts/wasm
find ./target/wasm32-unknown-unknown/release -name '*.wasm' -exec cp {} artifacts/wasm/ \;

- name: Upload WASM artifacts
uses: actions/upload-artifact@v4
with:
name: wasm-artifacts
path: artifacts/wasm
Loading