name: DevPlace CI
on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.13"

      - name: Install dependencies
        run: |
          pip install -e ".[dev]"
          python -m playwright install chromium --with-deps

      - name: Run integration tests with coverage
        env:
          COVERAGE_PROCESS_START: ${{ github.workspace }}/.coveragerc
          PLAYWRIGHT_HEADLESS: "1"
        run: |
          python -m coverage run -m pytest tests/

      - name: Build coverage report
        if: always()
        run: |
          python -m coverage combine
          python -m coverage report
          python -m coverage html

      - name: Publish coverage HTML
        if: always()
        uses: actions/upload-artifact@v3
        with:
          name: coverage-html
          path: htmlcov/

      - name: Upload test screenshots
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: failure-screenshots
          path: /tmp/devplace_test_screenshots/

