176 lines
5.4 KiB
YAML
176 lines
5.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- '.github/**'
|
|
- '.githooks/**'
|
|
- '*.md'
|
|
pull_request:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- '.github/**'
|
|
- '.githooks/**'
|
|
- '*.md'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUSTFLAGS: "-Dwarnings"
|
|
|
|
jobs:
|
|
# ── Stage 1: Preflight ───────────────────────────────────────────────
|
|
fmt:
|
|
name: Formatting
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache git
|
|
- uses: actions/checkout@v4
|
|
- run: rustup component add rustfmt
|
|
- run: cargo fmt --all -- --check
|
|
|
|
clippy:
|
|
name: Lint (clippy)
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- run: rustup component add clippy
|
|
- uses: Swatinem/rust-cache@v2
|
|
- run: cargo clippy --workspace --all-targets
|
|
|
|
compile-wasm:
|
|
name: Compile WASM target
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache git
|
|
- uses: actions/checkout@v4
|
|
- run: rustup target add wasm32-unknown-unknown
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Check crypto crate compiles for WASM
|
|
run: cargo check -p salvium-crypto --target wasm32-unknown-unknown
|
|
|
|
# ── Stage 2: Compile workspace ───────────────────────────────────────
|
|
compile:
|
|
name: Compile workspace
|
|
needs: [fmt, clippy, compile-wasm]
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Build all crates
|
|
run: cargo build --workspace
|
|
- name: Build in release mode
|
|
run: cargo build --workspace --release
|
|
|
|
# ── Stage 3: Tests + docs ───────────────────────────────────────────
|
|
test-types:
|
|
name: "Test: types + consensus rules"
|
|
needs: [compile]
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: salvium-types
|
|
run: cargo test -p salvium-types -- --nocapture
|
|
- name: salvium-consensus
|
|
run: cargo test -p salvium-consensus -- --nocapture
|
|
|
|
test-crypto:
|
|
name: "Test: crypto verification"
|
|
needs: [compile]
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: salvium-crypto (unit)
|
|
run: cargo test -p salvium-crypto --lib -- --nocapture
|
|
- name: salvium-crypto (integration)
|
|
run: cargo test -p salvium-crypto --test '*' -- --nocapture
|
|
|
|
test-wallet:
|
|
name: "Test: wallet + transactions + CLI"
|
|
needs: [compile]
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: salvium-wallet (unit + integration compile)
|
|
run: cargo test -p salvium-wallet -- --nocapture
|
|
- name: salvium-tx
|
|
run: cargo test -p salvium-tx -- --nocapture
|
|
- name: salvium-cli (compile check)
|
|
run: cargo test -p salvium-cli -- --nocapture
|
|
|
|
test-infra:
|
|
name: "Test: miner + multisig + RPC"
|
|
needs: [compile]
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: salvium-miner
|
|
run: cargo test -p salvium-miner -- --nocapture
|
|
- name: salvium-multisig
|
|
run: cargo test -p salvium-multisig -- --nocapture
|
|
- name: salvium-rpc
|
|
run: cargo test -p salvium-rpc -- --nocapture
|
|
|
|
docs:
|
|
name: Documentation
|
|
needs: [compile]
|
|
runs-on: self-hosted
|
|
container: rust:alpine
|
|
steps:
|
|
- run: apk add --no-cache musl-dev perl make git g++ cmake tar
|
|
- uses: actions/checkout@v4
|
|
- uses: Swatinem/rust-cache@v2
|
|
- name: Doc tests
|
|
run: cargo test --workspace --doc
|
|
- name: Build docs (check for broken links)
|
|
run: cargo doc --workspace --no-deps
|
|
env:
|
|
RUSTDOCFLAGS: "-Dwarnings"
|
|
|
|
# ── Gate: all checks must pass ──────────────────────────────────────
|
|
ci-pass:
|
|
name: CI passed
|
|
if: always()
|
|
needs:
|
|
- fmt
|
|
- clippy
|
|
- compile-wasm
|
|
- compile
|
|
- test-types
|
|
- test-crypto
|
|
- test-wallet
|
|
- test-infra
|
|
- docs
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Check all jobs passed
|
|
run: |
|
|
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
|
|
echo "One or more jobs failed"
|
|
exit 1
|
|
fi
|
|
if [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
|
|
echo "One or more jobs were cancelled"
|
|
exit 1
|
|
fi
|
|
echo "All CI checks passed"
|