[explorer] Add CI #56
Workflow file for this run
This file contains hidden or 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: Tests | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| UDEPS_VERSION: 0.1.50 | |
| NODE_VERSION: 20 | |
| jobs: | |
| All: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get Rust version | |
| id: rust-version | |
| run: echo "rust_version=$(rustc --version)" >> "$GITHUB_OUTPUT" | |
| - name: Run setup | |
| uses: ./.github/actions/setup | |
| with: | |
| rust-version: ${{ steps.rust-version.outputs.rust_version}} | |
| - name: Lint | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Fmt | |
| run: cargo fmt --all -- --check | |
| - name: Check docs | |
| run: cargo doc --no-deps --document-private-items | |
| env: | |
| RUSTDOCFLAGS: "-D warnings" | |
| - name: Run tests | |
| run: cargo test --verbose | |
| Dependencies: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install nightly Rust toolchain | |
| run: rustup toolchain install nightly | |
| - name: Get Rust version | |
| id: rust-version | |
| run: echo "rust_version=$(rustc +nightly --version)" >> "$GITHUB_OUTPUT" | |
| - name: Run setup | |
| uses: ./.github/actions/setup | |
| with: | |
| rust-version: ${{ steps.rust-version.outputs.rust_version}} | |
| - name: Cache cargo-udeps | |
| id: cargo-udeps-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cargo/bin/cargo-udeps | |
| key: ${{ runner.os }}-${{ env.UDEPS_VERSION }}-cargo-udeps-${{ steps.rust-version.outputs.rust_version }} | |
| - name: Install cargo-udeps | |
| if: steps.cargo-udeps-cache.outputs.cache-hit != 'true' | |
| run: cargo +nightly install cargo-udeps --version ${{ env.UDEPS_VERSION }} | |
| - name: Check for unused dependencies | |
| run: cargo +nightly udeps --all-targets | |
| React: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: explorer/package-lock.json | |
| - name: Install dependencies | |
| run: cd explorer && npm ci | |
| - name: Mock alto_types WASM file | |
| run: | | |
| mkdir -p explorer/src/alto_types | |
| touch explorer/src/alto_types/alto_types.js | |
| touch explorer/src/alto_types/alto_types_bg.wasm | |
| echo "export function parse_seed() { return null; }" >> explorer/src/alto_types/alto_types.js | |
| echo "export function parse_notarized() { return null; }" >> explorer/src/alto_types/alto_types.js | |
| echo "export function parse_finalized() { return null; }" >> explorer/src/alto_types/alto_types.js | |
| echo "export function leader_index() { return 0; }" >> explorer/src/alto_types/alto_types.js | |
| echo "export default function init() { return Promise.resolve(); }" >> explorer/src/alto_types/alto_types.js | |
| - name: Test compilation | |
| run: cd explorer && CI=true npm run build | |
| WASM: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get Rust version | |
| id: rust-version | |
| run: echo "rust_version=$(rustc --version)" >> "$GITHUB_OUTPUT" | |
| - name: Run setup | |
| uses: ./.github/actions/setup | |
| with: | |
| rust-version: ${{ steps.rust-version.outputs.rust_version}} | |
| - name: Add WASM target | |
| run: rustup target add wasm32-unknown-unknown | |
| - name: Build types | |
| run: cargo build --target wasm32-unknown-unknown --release --manifest-path types/Cargo.toml && du -h target/wasm32-unknown-unknown/release/alto_types.wasm | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack | |
| - name: Pack types | |
| run: wasm-pack build types --release --target web |