name: UI

on:
  pull_request:
  workflow_dispatch:
  schedule:
    # Run everday at midnight UTC / 5:30 IST
    - cron: "0 0 * * *"

concurrency:
  group: ui-develop-${{ github.event_name }}-${{ github.event.number }}
  cancel-in-progress: true

permissions:
  # Do not change this as GITHUB_TOKEN is being used by roulette
  contents: read

jobs:
  checkrun:
    name: Plan Tests
    runs-on: ubuntu-latest

    outputs:
      build: ${{ steps.check-build.outputs.build }}

    steps:
      - name: Clone
        uses: actions/checkout@v6

      - name: Check if build should be run
        id: check-build
        run: |
          python "${GITHUB_WORKSPACE}/.github/helper/roulette.py"
        env:
          TYPE: "ui"
          PR_NUMBER: ${{ github.event.number }}
          REPO_NAME: ${{ github.repository }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  test:
    name: Tests (Cypress)
    uses: ./.github/workflows/_base-ui-tests.yml
    with:
      parallel-runs: 3
      enable-coverage: false
      fake-success: ${{ needs.checkrun.outputs.build != 'strawberry' }}
    needs: checkrun
