name: Build

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

env:
  CARGO_TERM_COLOR: always

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        rust: [stable, beta, nightly]

    steps:
      - uses: actions/checkout@v4

      - name: Setup Rust and cache
        uses: ./.github/actions/setup-rust-cached
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt,clippy
          cache-key-suffix: ${{ matrix.rust }}

      - name: Install cargo-make
        uses: ./.github/actions/install-cargo-tools
        with:
          tools: make
          cache-tools: "true"

      - name: Build
        run: |
          cargo build --verbose
          if [ "${{ matrix.rust }}" = "nightly" ]; then
            echo "⚠️  Nightly build completed (failures ignored)"
          fi
        continue-on-error: ${{ matrix.rust == 'nightly' }}

      - name: Run tests
        run: |
          # Exclude London TDD tests (broken - missing type imports)
          cargo test --workspace --lib --verbose
          cargo test --test cli --test marketplace --verbose
          if [ "${{ matrix.rust }}" = "nightly" ]; then
            echo "⚠️  Nightly tests completed (failures ignored)"
          fi
        continue-on-error: ${{ matrix.rust == 'nightly' }}
