error-forge 1.2.0

Pragmatic Rust error-handling framework with stable error metadata, contextual diagnostics, optional async support, and synchronous recovery primitives (retry, circuit-breaker, backoff). Optional #[derive(ModError)], declarative define_errors!, and feature-gated logging / tracing / serde adapters.
Documentation
name: CI

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

# Node.js 20 was deprecated on GitHub Actions runners on 2025-09-19
# and will be removed on 2026-09-16; the default JavaScript-action
# runtime switches to Node.js 24 on 2026-06-02. We set this flag
# now so every JS-action step in this workflow runs on Node 24,
# regardless of which Node version the action itself declares. The
# flag is a no-op for the actions that already target Node 24
# natively (e.g. `actions/checkout@v7`).
env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
  build-test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        features:
          - ""
          - derive
          - serde
          - console
          - backtrace
          - "derive serde"
          - "derive console"
          - "derive backtrace"
          - "derive serde console backtrace"

    steps:
      - uses: actions/checkout@v7

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Run tests
        run: |
          echo "Testing with features: ${{ matrix.features }}"
          cargo test --workspace --no-default-features --features "${{ matrix.features }}"

  full-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Check all features
        run: cargo check --workspace --all-features
      - name: Clippy check (all features)
        run: cargo clippy --workspace --all-targets --all-features -- -D warnings
      - name: Clippy check (default features)
        run: cargo clippy --workspace --all-targets -- -D warnings
      # The build-test matrix above never enables `async`, `log`,
      # `tracing`, `jitter`, `registry`, `collector` or `context`, so
      # the tests gated on those features only run here.
      - name: Test all features
        run: cargo test --workspace --all-features
      # With default features `error-forge` must not pull any
      # third-party crate into a dependent's build, on any target.
      # `error-forge-derive` is in-house and dependency-free without
      # its `derive` feature.
      - name: Default dependency graph has no third-party crates
        run: |
          deps=$(cargo tree -p error-forge -e normal --target all --prefix none --locked             | sort -u | grep -v -E '^error-forge(-derive)? v' || true)
          if [ -n "$deps" ]; then
            echo "Third-party crates in the default build of error-forge:"
            echo "$deps"
            exit 1
          fi

  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      - name: Check documentation
        env:
          RUSTDOCFLAGS: -D warnings
        run: cargo doc --workspace --all-features --no-deps

  # MSRV verification. `rust-version` in `Cargo.toml` declares the
  # floor; this job builds on that exact toolchain to catch any
  # accidental use of newer-than-MSRV APIs, then runs the tests.
  msrv:
    name: MSRV (Rust 1.81)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      - uses: dtolnay/rust-toolchain@1.81.0
      - name: Build (all features)
        run: cargo +1.81.0 build --workspace --all-features
      # The committed lockfile tracks the newest dev-dependencies, and
      # some of them (`trybuild`, its `toml` stack) need a newer Rust.
      # Re-resolve with the MSRV-aware resolver so the tests build on
      # 1.81. Runtime dependencies are already covered by the build
      # step above, which uses the committed lockfile.
      - name: Resolve 1.81-compatible dev-dependencies
        env:
          CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
        run: cargo +stable update
      # The UI test compares compiler output recorded on stable, so it
      # only runs in the stable jobs.
      - name: Test (all features)
        run: cargo +1.81.0 test --workspace --all-features -- --skip trybuild_ui_tests

  # Checks that the version floors declared in `Cargo.toml` really
  # build: every direct dependency is resolved to the lowest version
  # its requirement allows, then the crate is built on the MSRV.
  # Dev-dependencies are dropped first; they only serve the tests and
  # their floors would otherwise constrain the runtime ones.
  minimal-versions:
    name: Minimal versions (Rust 1.81)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@nightly
      - uses: dtolnay/rust-toolchain@1.81.0
      - name: Install cargo-hack
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-hack
      - name: Drop dev-dependencies
        run: cargo hack --remove-dev-deps --workspace
      - name: Resolve direct dependencies to their minimum versions
        run: cargo +nightly update -Z direct-minimal-versions
      - name: Build (all features)
        run: cargo +1.81.0 build --workspace --all-features
      - name: Build (no default features)
        run: cargo +1.81.0 build --workspace --no-default-features

  # Security advisory scan. Runs `cargo audit` against the RustSec
  # database on every push so deprecated / vulnerable transitive
  # crates surface immediately.
  #
  # We invoke `cargo audit` directly rather than through
  # `rustsec/audit-check`, which is a Node.js 20 JavaScript action
  # (deprecated by GitHub on 2025-09-19, removed 2026-09-16). The
  # `cargo-deny` job below runs in parallel and overlaps coverage;
  # this job is the lightweight RUSTSEC-database-only scan.
  audit:
    name: cargo audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      # Prebuilt binary instead of `cargo install`, which compiled
      # cargo-audit from source on every run.
      - name: Install cargo-audit
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-audit
      - name: Run cargo audit
        run: cargo audit --deny warnings

  # License + duplicate-version policy enforcement via `cargo deny`.
  # The `deny.toml` config in the repo root pins the allow-list of
  # permissive licenses, bans wildcard version requirements, and
  # restricts dep sources to `crates.io`.
  deny:
    name: cargo deny
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: EmbarkStudios/cargo-deny-action@v2
        with:
          command: check all