name: Rust clippy diagnostic

on:
  push:
    branches:
      - codex/rust-professionalization
  workflow_dispatch:

jobs:
  detmir-portal-clippy-diagnostic:
    runs-on: ubuntu-latest
    timeout-minutes: 30

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust 1.85 with rustfmt and clippy
        run: |
          rustup toolchain install 1.85.0 --profile minimal --component rustfmt --component clippy
          rustup default 1.85.0

      - name: Capture detmir-portal clippy output
        working-directory: adk-rust
        run: |
          set +e
          cargo clippy -p detmir-portal --all-targets -- -D warnings > ../detmir-portal-clippy.log 2>&1
          status=$?
          echo "clippy_exit_status=${status}" > ../detmir-portal-clippy-status.txt
          tail -n 240 ../detmir-portal-clippy.log
          exit ${status}

      - name: Upload detmir-portal clippy log
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: detmir-portal-clippy-log
          path: |
            detmir-portal-clippy.log
            detmir-portal-clippy-status.txt
