Skip to content

fix(test): move auth.jwt() stub and platform roles into fixture #447

fix(test): move auth.jwt() stub and platform roles into fixture

fix(test): move auth.jwt() stub and platform roles into fixture #447

Workflow file for this run

name: CI – Build & Test Soroban Contracts
on:
push:
pull_request:
workflow_dispatch:
jobs:
frontend-lint:
name: Frontend – Lint & Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10.33.0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
cache: "pnpm"
cache-dependency-path: frontend/pnpm-lock.yaml
- name: Install dependencies
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Run ESLint
working-directory: frontend
run: pnpm lint
- name: Format files automatically
working-directory: frontend
run: pnpm format --write
- name: Run Prettier format check
working-directory: frontend
run: pnpm format:check
- name: Build Next.js & Check Performance Budget
working-directory: frontend
run: |
pnpm build
pnpm check-budget
build:
name: Build Soroban Contracts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.85.0"
targets: wasm32-unknown-unknown
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Pin incompatible dependencies
working-directory: smartcontract
run: |
cargo update serde_with@3.18.0 --precise 3.17.0 || true
cargo update serde_with_macros@3.18.0 --precise 3.17.0 || true
cargo update darling@0.23.0 --precise 0.21.3 || true
cargo update darling_core@0.23.0 --precise 0.21.3 || true
cargo update darling_macro@0.23.0 --precise 0.21.3 || true
cargo update indexmap@2.14.0 --precise 2.6.0 || true
- name: Build Factory contract
working-directory: smartcontract
run: cargo build --target wasm32-unknown-unknown --release --manifest-path=contracts/factory/Cargo.toml
- name: Build Rotational contract
working-directory: smartcontract
run: cargo build --target wasm32-unknown-unknown --release --manifest-path=contracts/rotational/Cargo.toml
- name: Build Target contract
working-directory: smartcontract
run: cargo build --target wasm32-unknown-unknown --release --manifest-path=contracts/target/Cargo.toml
- name: Build Flexible contract
working-directory: smartcontract
run: cargo build --target wasm32-unknown-unknown --release --manifest-path=contracts/flexible/Cargo.toml
- name: Build Governance contract
working-directory: smartcontract
run: cargo build --target wasm32-unknown-unknown --release --manifest-path=contracts/governance/Cargo.toml
- name: Verify WASM artifacts
working-directory: smartcontract
run: |
ls -lh target/wasm32-unknown-unknown/release/*.wasm
echo "All contracts built successfully"
- name: Run unit tests
working-directory: smartcontract
run: cargo test
- name: Install rustfmt and clippy
working-directory: smartcontract
run: rustup component add rustfmt clippy
- name: Check formatting
working-directory: smartcontract
run: cargo fmt --check
- name: Lint with Clippy
working-directory: smartcontract
run: cargo clippy --workspace --all-targets -- -D warnings
fuzz-invariant:
name: Fuzz & Invariant Tests
runs-on: ubuntu-latest
# Run fuzz tests on every push/PR; they are deterministic via PROPTEST_SEED.
env:
# Fixed seed ensures reproducible failures. Override with
# cargo test -- --proptest-seed=<new-seed>
# to explore different parts of the input space.
PROPTEST_SEED: "0x5a3f9c1d7b2e4068"
steps:
- uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.85.0"
- name: Cache cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-fuzz-${{ hashFiles('**/Cargo.lock') }}
- name: Pin incompatible dependencies
working-directory: smartcontract
run: |
cargo update serde_with@3.18.0 --precise 3.17.0 || true
cargo update serde_with_macros@3.18.0 --precise 3.17.0 || true
cargo update darling@0.23.0 --precise 0.21.3 || true
cargo update darling_core@0.23.0 --precise 0.21.3 || true
cargo update darling_macro@0.23.0 --precise 0.21.3 || true
cargo update indexmap@2.14.0 --precise 2.6.0 || true
# ── Rotational (extends existing coverage) ──────────────────────────────
- name: Fuzz – Rotational contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/rotational/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-rotational.log
grep -q "test result: ok" /tmp/fuzz-rotational.log || \
{ echo "::error::Rotational fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Microloan (highest priority) ────────────────────────────────────────
- name: Fuzz – Microloan contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/microloan/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-microloan.log
grep -q "test result: ok" /tmp/fuzz-microloan.log || \
{ echo "::error::Microloan fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Yield Strategy (highest priority) ───────────────────────────────────
- name: Fuzz – Yield Strategy contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/yield-strategy/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-yield.log
grep -q "test result: ok" /tmp/fuzz-yield.log || \
{ echo "::error::Yield Strategy fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Governance ──────────────────────────────────────────────────────────
- name: Fuzz – Governance contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/governance/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-governance.log
grep -q "test result: ok" /tmp/fuzz-governance.log || \
{ echo "::error::Governance fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Flexible Pool ───────────────────────────────────────────────────────
- name: Fuzz – Flexible Pool contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/flexible/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-flexible.log
grep -q "test result: ok" /tmp/fuzz-flexible.log || \
{ echo "::error::Flexible Pool fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Target Pool ─────────────────────────────────────────────────────────
- name: Fuzz – Target Pool contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/target/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-target.log
grep -q "test result: ok" /tmp/fuzz-target.log || \
{ echo "::error::Target Pool fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Reputation Tracker ──────────────────────────────────────────────────
- name: Fuzz – Reputation Tracker contract
working-directory: smartcontract
run: |
cargo test prop_ --manifest-path=contracts/reputation/Cargo.toml --release \
-- --nocapture 2>&1 | tee /tmp/fuzz-reputation.log
grep -q "test result: ok" /tmp/fuzz-reputation.log || \
{ echo "::error::Reputation fuzz tests FAILED (seed: $PROPTEST_SEED)"; exit 1; }
# ── Upload counterexample logs on failure ───────────────────────────────
- name: Upload fuzz failure logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-failure-logs
path: /tmp/fuzz-*.log
retention-days: 30
edge-functions-unit:
name: Edge Functions – Deno Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Run edge function unit tests
working-directory: supabase/functions
run: deno task test
supabase-migrations:
name: Supabase – Migration & RLS Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
# Health check copied from the official CI examples.
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
env:
PGHOST: localhost
PGPORT: "5432"
PGUSER: postgres
PGPASSWORD: postgres
PGROOT_DB: postgres
steps:
- uses: actions/checkout@v5
- name: Install postgresql client
run: sudo apt-get update && sudo apt-get install -y postgresql-client
- name: Run migration + RLS harness
working-directory: supabase/tests
run: ./run-tests.sh
component-tests:
name: Run React Component Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10.33.0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
cache: "pnpm"
cache-dependency-path: frontend/pnpm-lock.yaml
- name: Install Frontend Dependencies
working-directory: frontend
run: pnpm install --frozen-lockfile
- name: Run React Component Test Suite with Coverage
working-directory: frontend
run: pnpm test:components:coverage