chia-query 0.3.0

Query the Chia blockchain via decentralized peers with coinset.org fallback
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

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

permissions:
  contents: read

jobs:
  build-test:
    name: Build, Test & Lint (Rust)
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          components: rustfmt, clippy, llvm-tools-preview

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov

      - name: Install cargo-nextest
        uses: taiki-e/install-action@nextest

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

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

      # Coverage MUST be collected via the combined `cargo llvm-cov nextest` form so llvm-cov
      # drives nextest directly -- never run `cargo nextest run` and `cargo llvm-cov` as two
      # separate steps, that collects zero coverage (the exact bug this fixes, #489).
      #
      # `--no-tests=warn`: today this crate's only test file (tests/parity.rs) is a live-network
      # `#[ignore]`d comparison suite (run manually with `--ignored` against mainnet), so a normal
      # nextest run matches ZERO tests. Nextest's default `--no-tests` behavior is a HARD ERROR
      # ("no tests to run", exit 4) in that case, which fails the job before coverage is even
      # measured. `warn` makes "no tests matched" a warning instead of a failure so the (currently
      # empty) coverage report still generates and uploads.
      #
      # Coverage is measure-only for now: the active unit-test suite is still being built out
      # (tracked in #157). It is NOT yet gated at >= 80% lines -- with zero non-ignored tests today,
      # a `--fail-under-lines 80` gate would fail every PR unconditionally. Once the real unit-test
      # suite lands (#157), flip this to the gated form: `cargo llvm-cov nextest --fail-under-lines 80
      # --all-features --workspace --lcov --output-path lcov.info --retries 2`.
      #
      # Runs via nextest with retries so a test that fails-then-passes is reported as FLAKY
      # (not a hard failure) instead of silently passing or blocking the build (#489).
      - name: Run tests with coverage (measure-only)
        run: cargo llvm-cov nextest --all-features --workspace --lcov --output-path lcov.info --retries 2 --no-tests=warn

      - name: Coverage summary
        if: always()
        run: cargo llvm-cov report --summary-only

      - name: Upload coverage artifact
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: lcov-coverage
          path: lcov.info
          if-no-files-found: warn

      - name: Check documentation
        run: cargo doc --no-deps --all-features

  wasm-coinset:
    name: Build & lint (wasm32 coinset-only)
    runs-on: ubuntu-latest
    # Proves the coinset REST tier stays wasm-clean: no native HTTP, no blst,
    # no getrandom leak, none of the peer/CLVM stack reaches the wasm build.
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain (wasm32 target)
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown
          components: clippy

      - name: Cache dependencies
        uses: Swatinem/rust-cache@v2

      - name: Build coinset-only for wasm32
        run: cargo build --target wasm32-unknown-unknown --no-default-features --features coinset

      - name: Clippy coinset-only for wasm32
        run: cargo clippy --target wasm32-unknown-unknown --no-default-features --features coinset -- -D warnings