name: 'Test: E2E Infrastructure'

on:
  workflow_dispatch:
  schedule:
    - cron: '0 2 * * *'

concurrency:
  group: e2e-infrastructure-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  prepare-docker:
    uses: ./.github/workflows/prepare-docker-reusable.yml
    secrets: inherit

  benchmark:
    needs: [prepare-docker]
    name: ${{ matrix.lane }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - lane: ui
            grep: '@bench:ui'
            shards: '[{"shard":1,"images":""}]'
          - lane: webhook
            grep: '@bench:webhook'
            shards: '[{"shard":1,"images":""}]'
          - lane: kafka
            grep: '@bench:kafka'
            shards: '[{"shard":1,"images":""},{"shard":2,"images":""}]'
    uses: ./.github/workflows/test-e2e-reusable.yml
    with:
      test-mode: docker-artifact
      test-command: 'pnpm --filter=n8n-playwright test:benchmark --grep ${{ matrix.grep }}'
      pre-generated-matrix: ${{ matrix.shards }}
      workers: '1'
      runner: blacksmith-8vcpu-ubuntu-2204
      timeout-minutes: 120
      artifact-prefix: 'benchmark-${{ matrix.lane }}'
    secrets: inherit
