name: rust-workspace

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

jobs:
  rust-workspace:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install pinned Rust toolchain
        run: |
          rustup toolchain install 1.94.0 --profile minimal --component rustfmt --component clippy
          rustup override set 1.94.0
          rustup show active-toolchain
          cargo +1.94.0 --version
          rustc +1.94.0 --version

      - name: Format
        run: cargo +1.94.0 fmt --manifest-path adk-rust/Cargo.toml --all -- --check

      - name: Test
        run: cargo +1.94.0 test --manifest-path adk-rust/Cargo.toml --workspace

      - name: Clippy
        run: cargo +1.94.0 clippy --manifest-path adk-rust/Cargo.toml --workspace --all-targets -- -D warnings

      - name: Release build
        run: cargo +1.94.0 build --manifest-path adk-rust/Cargo.toml --workspace --release
