name: Execute

on: [ push ]

jobs:
  build:
    runs-on: ubuntu-gitea
    strategy:
      matrix:
        python-version: [ "3.12" ]
    env:
      EDGEDRIVER_VERSION: 126.0.2592.102
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install python dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install -r requirements.txt
          mkdir drivers

      - name: Prep the Debian repositories
        run: |
          apt update -y
          apt upgrade -y
          apt install -y chromium-browser
          apt install -y firefox

      - name: Install Edge and EdgeDriver for Linux
        if: runner.os == 'Linux'
        run: |
          wget https://msedgedriver.azureedge.net/${EDGEDRIVER_VERSION}/edgedriver_linux64.zip
          unzip edgedriver_linux64.zip
          mv msedgedriver drivers
          
          curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
          install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
          sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
          sudo rm microsoft.gpg
          apt update
          apt install -y microsoft-edge-stable

      - name: EdgeDriver for Windows
        if: runner.os == 'Windows'
        run: |
          wget https://msedgedriver.azureedge.net/${EDGEDRIVER_VERSION}/edgedriver_win64.zip
          unzip edgedriver_win64.zip
          mv msedgedriver.exe drivers
          List-Item -Recurse drivers

      - name: Run the pytests
        run: pytest -c pytest.ini -m edge
