name: release-preflight

on:
  pull_request:
    branches: [master]
    paths:
      - '**.rs'
      - 'Cargo.toml'
      - 'Cargo.lock'
      - 'Justfile'
      - 'just/**'
      - '.agents/**'
      - '.github/workflows/**'
      - 'README.md'
      - 'docs/**'
      - 'openspec/**'
      - 'scripts/**'
      - 'tests/**'
      - 'tools/**'
  workflow_dispatch:

permissions:
  contents: read

env:
  CARGO_INCREMENTAL: 0
  CARGO_TERM_COLOR: always

jobs:
  preflight:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 # master
        with:
          toolchain: stable
          components: clippy, rustfmt

      - name: Cache Rust build outputs
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: release-preflight-ubuntu-stable

      - name: Install just
        uses: taiki-e/install-action@just

      - name: Release readiness gate
        run: just release-check
