name: e2e
permissions: {}

on:
  pull_request:
    branches:
      - "*"
    paths:
      - '.github/workflows/e2e.yml'
      - 'api/**'
      - 'controllers/**'
      - 'internal/**'
      - 'pkg/**'
      - 'e2e/*'
      - 'Dockerfile'
      - 'go.*'
      - 'main.go'
      - 'Makefile'

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

jobs:
  e2e:
    name: E2E Testing (CE)
    runs-on:
      labels: ubuntu-latest-8-cores
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          fetch-depth: 0

      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: 'go.mod'

      - uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5

      - name: e2e
        run: sudo make e2e

  e2e-openshift-CE:
    name: E2E OpenShift Testing (CE)
    runs-on:
      labels: ubuntu-latest-8-cores
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          fetch-depth: 0

      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: 'go.mod'

      - uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5

      - name: e2e
        run: sudo make e2e-openshift

  run-e2e:
    name: E2E Testing
    strategy:
      fail-fast: false
      matrix:
        k8s-version:
          - 'v1.33.0'
          - 'v1.34.0'
          - 'v1.35.0'
    runs-on:
      labels: ubuntu-latest-8-cores
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          repository: ${{ github.event.client_payload.repo }}
          ref: ${{ github.event.client_payload.sha }}

      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: 'go.mod'

      - uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5

      - name: e2e (Enterprise)
        run: sudo KUBERNETES_SUPPORTED_VERSION=${{ matrix.k8s-version }} make e2e

  e2e-openshift:
    name: E2E Testing (OpenShift)
    strategy:
      fail-fast: false
      matrix:
        os-version: # https://quay.io/repository/minc-org/minc?tab=tags&tag=latest
          - '4.18.0-okd-scos.9'
          - '4.19.0-okd-scos.17'
    runs-on: ubuntu-latest-8-cores
    steps:

      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          fetch-depth: 0

      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version-file: 'go.mod'

      - uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5

      - name: e2e
        run: sudo OS_SUPPORTED_VERSION=${{ matrix.os-version }} make e2e-openshift
