dig-peer-protocol 0.4.0

DIG Network L2 protocol types extending Chia's wire protocol (opcodes 200+)
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Format / Clippy / Test / Docs
    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

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

      - 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

      # cargo-nextest with retries (.config/nextest.toml, #489): a genuinely-flaky
      # test gets retried instead of red-flagging the whole PR, while retries are
      # still reported in the run output so real flakiness stays visible.
      - name: Run tests (nextest, flaky-retry)
        run: cargo nextest run --all-features

      # Doctests aren't run by nextest — keep them on plain cargo test.
      - name: Run doctests
        run: cargo test --doc --all-features

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

  coverage:
    name: Coverage (>=80% lines)
    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: 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

      # The crate's own logic (DigMessage / DigMessageType / introducer wire types)
      # is feature-independent — the `native-tls` / `rustls` features only forward
      # TLS re-exports from chia-sdk-client (pure glue with no coverable lines here).
      # Measuring default features keeps the gate fast and focused on this crate's code.
      # lib.rs is excluded from the floor: it is re-export-only with no own logic.
      #
      # Uses the combined `cargo llvm-cov nextest` form (#489) so llvm-cov drives
      # nextest directly — coverage instrumentation is still collected AND nextest's
      # flaky-retry (.config/nextest.toml) still applies. Running `cargo nextest run`
      # and `cargo llvm-cov` as two separate steps collects ZERO coverage from the
      # nextest run and fails this gate — do not split them.
      - name: Run coverage with 80% line floor (nextest)
        run: |
          cargo llvm-cov nextest \
            --ignore-filename-regex 'src/lib\.rs' \
            --fail-under-lines 80 \
            --all-features

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