name: e2e-prometheus-v2

on:
  workflow_dispatch:
  schedule:
    - cron:  '30 14 * * *' # Every day 14:30

jobs:
  e2e-tests:
    name: E2E Prometheus v2 tests
    runs-on: ubuntu-latest
    if: github.repository == 'prometheus-operator/prometheus-operator'
    strategy:
      # since upgrade test was failing other tests were cancelled, setting this so that other test run
      fail-fast: false
      matrix:
        suite: [alertmanager, prometheus, prometheusAllNS, thanosruler, operatorUpgrade]
        include:
          - suite: alertmanager
            target: test-e2e-alertmanager
          - suite: prometheus
            target: test-e2e-prometheus
          - suite: prometheusAllNS
            target: test-e2e-prometheus-all-namespaces
          - suite: thanosruler
            target: test-e2e-thanos-ruler
          - suite: operatorUpgrade
            target: test-e2e-operator-upgrade
    steps:
    - uses: actions/checkout@v6

    - name: Setup E2E environment
      uses: ./.github/actions/setup-e2e  # composite action with your setup steps


    - name: Run tests
      env:
        E2E_DIAGNOSTIC_DIRECTORY: ${{ env.E2E_DIAGNOSTIC_DIRECTORY }}
        TEST_PROMETHEUS_V2: "true"
      run: |
        make ${{ matrix.target }}

  # Added to summarize the matrix and allow easy branch protection rules setup
  e2e-tests-result:
    name: End-to-End Test Results
    if: github.repository == 'prometheus-operator/prometheus-operator'
    needs:
      - e2e-tests
    runs-on: ubuntu-latest
    steps:
      - name: Mark the job as a success
        if: needs.e2e-tests.result == 'success'
        run: exit 0
      - name: Mark the job as a failure
        if: needs.e2e-tests.result != 'success'
        run: exit 1
