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"

permissions:
  contents: read

jobs:
  federation-tests:
    name: Federation tests
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
        with:
          persist-credentials: false

      - name: Install uv
        uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.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
