bsv-tracker 0.2.2

A transaction evidence state machine with host supplied headers, proofs, hints and time
Documentation
name: ci

# The machine gate. The job ids below are the status-check contexts that branch
# protection on main requires (test, fmt, clippy, vectors, wasm32); renaming a
# job removes its context and blocks every PR until the protection is updated.
# Every action is pinned by commit sha; the tag it was read at is in the comment.
on:
  pull_request:
    branches: [main]
  push:
    branches: [main]
  # release.yml runs the same jobs on a tag before it publishes.
  workflow_call:

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

defaults:
  run:
    shell: bash

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
        with:
          toolchain: stable

      # Cargo.lock is tracked, so the key follows the lock and every job is --locked.
      - name: Cache cargo
        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ubuntu-test-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ubuntu-test-

      - name: Run the tests
        run: cargo test --locked

      - name: Build the documentation
        run: cargo doc --locked --no-deps
        env:
          RUSTDOCFLAGS: -Dwarnings

  fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
        with:
          toolchain: stable
          components: rustfmt

      - name: Check formatting
        run: cargo fmt --all -- --check

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
        with:
          toolchain: stable
          components: clippy

      - name: Cache cargo
        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ubuntu-clippy-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ubuntu-clippy-

      - name: Run Clippy
        run: cargo clippy --locked --all-targets -- -D warnings

  # The wire witnesses, by name. Each step counts its passes, so a renamed or
  # removed test turns the job red and never leaves a green check that ran nothing.
  vectors:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
        with:
          toolchain: stable

      - name: Cache cargo
        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ubuntu-vectors-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ubuntu-vectors-

      # tests/vectors/chain_events/{tip,fork,reorg,invalidated,frozen,tip_age}.json
      - name: The six chain-event envelope vectors
        run: |
          cargo test --locked --test chain_events -- --exact \
            pinned_tip_round_trip \
            pinned_fork_round_trip \
            pinned_reorg_round_trip \
            pinned_invalidated_round_trip \
            pinned_frozen_round_trip \
            pinned_tip_age_round_trip | tee chain_events.out
          grep -q '^test result: ok. 6 passed; 0 failed; 0 ignored' chain_events.out

      # tests/vectors/arc_tx_status_verdicts.json
      - name: The ARC status vector
        run: |
          cargo test --locked --test verdicts -- --exact \
            arc_p0_2_twenty_bodies_are_only_hints | tee verdicts.out
          grep -q '^test result: ok. 1 passed; 0 failed; 0 ignored' verdicts.out

  # The wallet, the overlay engine and the app layer host this crate in wasm.
  wasm32:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

      - name: Install Rust
        uses: dtolnay/rust-toolchain@e2a55d2ffb04f378e9626c28d38b36d230d1e12f # master
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown

      - name: Cache cargo
        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ubuntu-wasm32-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ubuntu-wasm32-

      - name: Build for wasm32-unknown-unknown
        run: cargo build --locked --target wasm32-unknown-unknown --features wasm