name: 🛰️ Federation compatibility tests

concurrency:
  group: ${{ github.head_ref || github.run_id }}-federation
  cancel-in-progress: true

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
    paths:
      - "strawberry/federation/**"
      - "strawberry/printer/**"
      - "federation-compatibility/**"
      - "pyproject.toml"
      - "uv.lock"
      - ".github/workflows/federation-compatibility.yml"

jobs:
  federation-tests:
    name: Federation tests
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

      - name: Install uv
        uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
        with:
          enable-cache: true
          python-version: "3.12"
      - run: uv sync

      - name: export schema
        run: uv run strawberry export-schema schema:schema > schema.graphql
        working-directory: federation-compatibility

      - uses: apollographql/federation-subgraph-compatibility@b6981fd83d24450a7cbd2d7727196e0ba57614e0 # v2
        with:
          compose: 'federation-compatibility/docker-compose.yml'
          schema: 'federation-compatibility/schema.graphql'
          port: 4001
          token: ${{ secrets.BOT_TOKEN }}
          failOnWarning: true
          failOnRequired: true
