drep-ai 3.0.0

A local commit gate: runs the linters your repo configures, and sends changed code to an LLM for review
Documentation
name: rust

on:
  push:
    branches: [main]
  pull_request:

env:
  CARGO_TERM_COLOR: always

permissions:
  contents: read

jobs:
  # homelab-1 has one repository-scoped runner, so separate Linux jobs would only
  # serialize while repeating checkout, cache and toolchain setup. Keep the
  # complete Linux gate in one allocation; macOS remains independent below.
  linux:
    name: validate (homelab-1)
    if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
    runs-on: [self-hosted, linux, x64, drep-linux]
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
        with:
          toolchain: stable
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          # Its default save cleanup deletes every Cargo binary present when
          # the action starts. These runners own pinned publisher tools.
          cache-bin: false

      - name: Format
        run: cargo fmt --all --check

      # Lint levels come from [lints] in Cargo.toml, not from flags here.
      - name: Clippy
        run: cargo clippy --all-targets --all-features

      - name: Test
        run: cargo test --all-targets --all-features

      # If this breaks, the MSRV in Cargo.toml is wrong - do not paper over it
      # by bumping the toolchain here. It has moved once already: `ignore`
      # 0.4.30 raised the real floor to 1.88 while open-agent-sdk still asks
      # for 1.85, and declares no `rust-version`, so the first sign was a
      # compile error in a dependency.
      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
        with:
          toolchain: 1.88.0

      # No --all-targets: MSRV is a property of [dependencies]. Whether the dev
      # dependencies build on 1.88 has no consumer.
      - name: MSRV
        run: cargo +1.88.0 check

  test-macos:
    name: test (Mac mini)
    if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
    runs-on: [self-hosted, macos, arm64, drep-macos]
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
        with:
          toolchain: stable
          components: clippy

      - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
        with:
          cache-bin: false

      - run: cargo test --all-targets --all-features

  # Exhaustive mutation is scheduled separately. A trusted main push needs
  # fast feedback only for production code changed by the complete push, after
  # both ordinary validation lanes have accepted the same revision.
  mutants-diff:
    name: mutate pushed diff (Legion)
    needs: [linux, test-macos]
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    runs-on: [self-hosted, linux, x64, homelab-legion, drep-mutants]
    timeout-minutes: 120
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          clean: false
          fetch-depth: 0
          persist-credentials: false

      # Keeping target/ avoids rebuilding every dependency for a small diff.
      # No other persistent state may influence the mutation result.
      - name: Verify persistent workspace hygiene
        shell: bash
        run: |
          set -euo pipefail
          unexpected="$(
            git status --porcelain=v1 --untracked-files=all --ignored=matching |
              grep -Ev '^!! target/$' || true
          )"
          if [ -n "$unexpected" ]; then
            echo "unexpected persistent runner state:" >&2
            echo "$unexpected" >&2
            exit 1
          fi

      - uses: dtolnay/rust-toolchain@4360b52568e2003a75bf9bc1d59f33a8e3fc893c # stable
        with:
          toolchain: stable
          components: clippy

      - uses: taiki-e/install-action@1ed6d7be6168f6c9046541087ff549b6bc581fdf # v2.87.2
        with:
          tool: cargo-mutants@27.1.0

      - name: Materialize pushed diff
        shell: bash
        env:
          PUSH_BASE: ${{ github.event.before }}
          PUSH_HEAD: ${{ github.sha }}
        run: |
          set -euo pipefail
          git diff --no-ext-diff --unified=0 "$PUSH_BASE" "$PUSH_HEAD" > "$RUNNER_TEMP/pushed.diff"

      - run: ./scripts/mutants-run.sh --in-diff "$RUNNER_TEMP/pushed.diff"