chia-query 0.8.1

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` is a leftover safety net from when this crate's only test file was
      # tests/parity.rs, a live-network `#[ignore]`d suite, so a normal nextest run matched ZERO
      # tests and nextest's default `--no-tests` HARD ERROR (exit 4) failed the job before coverage
      # was even measured. That is no longer the situation -- the offline suite is real now -- but
      # the flag is kept so a future refactor that empties the suite reports an empty coverage
      # report rather than a confusing exit 4.
      #
      # Coverage is measure-only, and the suite is NO LONGER empty: 104 offline tests pass, and
      # `cargo llvm-cov --all-features` measured ~45% lines / 53% regions on 2026-08-10. Those two
      # percentages are hand-recorded and drift unwatched -- trust the job's own summary output
      # over this comment whenever they disagree. That is below the
      # ecosystem's >= 80% floor, so the exemption that was justified by an empty suite is now
      # simply debt. It is tracked in DIG-Network/dig_ecosystem#2612 -- which is also where the
      # flip to the gated form belongs: `cargo llvm-cov nextest --fail-under-lines 80 --all-features
      # --workspace --lcov --output-path lcov.info --retries 2`.
      #
      # (The two `#157` references this comment used to carry pointed at nothing: chia-query has no
      # issue #157, and dig_ecosystem#157 is an unrelated closed ticket. The gap read as owned when
      # it was not.)
      #
      # 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