---
name: test-wf
on:
  pull_request:
  push:
    tags-ignore:
      - v*
jobs:
  test-all:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v5
      - uses: actions/setup-python@v5
        with:
          python-version-file: "pyproject.toml"

      - name: Install Dependencies
        if: ${{ matrix.os == 'ubuntu-latest' }}
        run: sudo apt-get update && sudo apt-get install xvfb
        timeout-minutes: 1
      - name: Install choreographer
        run:  uv sync --no-sources --all-extras --locked
      - name: Install google-chrome-for-testing
        run: uv run --no-sources choreo_get_chrome -v
      - name: Diagnose
        run:  uv run --no-sources choreo_diagnose --no-run
        timeout-minutes: 1

      - name: Test
        if: ${{ ! runner.debug && matrix.os != 'ubuntu-latest' }}
        run: uv run --no-sources poe test
        timeout-minutes: 7

      - name: Test (Linux)
        if: ${{ ! runner.debug && matrix.os == 'ubuntu-latest' }}
        run: xvfb-run uv run --no-sources poe test
        timeout-minutes: 7

      - name: Test (Debug)
        if: ${{ runner.debug && matrix.os != 'ubuntu-latest' }}
        env:
          CHOREO_ENABLE_DEBUG: 1
        run: uv run --no-sources poe debug-test
        timeout-minutes: 20

      - name: Test (Debug, Linux)
        if: ${{ runner.debug && matrix.os == 'ubuntu-latest' }}
        env:
          CHOREO_ENABLE_DEBUG: 1
        run: xvfb-run uv run --no-sources poe debug-test
        timeout-minutes: 7
