Skip to content

[pre-commit.ci] pre-commit autoupdate #480

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #480

Workflow file for this run

name: tests
on:
push:
branches:
- main
pull_request:
types: ["opened", "synchronize", "reopened"]
create:
# Auto-cancel outdated runs when new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup-browsers:
name: 🌐 Setup Playwright Browsers
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
playwright-version: ${{ steps.playwright-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Playwright
run: pip install playwright
- name: Get Playwright version
id: playwright-version
run: echo "version=$(pip show playwright | grep Version | cut -d' ' -f2)" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}-browsers
restore-keys: |
playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}-
- name: Install browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
playwright install chromium firefox
playwright install-deps
test:
name: pf-${{ matrix.pf-version }} (🐍 ${{ matrix.python-version }}, ${{ matrix.browser }})
runs-on: ubuntu-latest
needs: setup-browsers
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
browser: [chromium, firefox]
python-version: ["3.12", "3.13"]
pf-version: ["v5", "v6"]
# Reduce redundancy: only run coverage for one combination
include:
- browser: chromium
python-version: "3.13"
pf-version: "v6"
run-coverage: true
exclude: []
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Playwright
run: pip install playwright
- name: Restore Playwright browsers cache
uses: actions/cache/restore@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ needs.setup-browsers.outputs.playwright-version }}-browsers
fail-on-cache-miss: true
- name: Install dependencies
run: |
pip install -U pip wheel
pip install -e .[dev]
- name: Test with pytest (with coverage)
if: matrix.run-coverage == true
timeout-minutes: 25
run: |
pytest -v -n 2 --headless --browser=${{ matrix.browser }} --pf-version=${{ matrix.pf-version }} --cov=./src --cov-report=xml --reruns 2 --reruns-delay 5
- name: Test with pytest (without coverage)
if: matrix.run-coverage != true
timeout-minutes: 25
run: |
pytest -v -n 2 --headless --browser=${{ matrix.browser }} --pf-version=${{ matrix.pf-version }} --reruns 2 --reruns-delay 5
- name: Upload coverage to Codecov
if: matrix.run-coverage == true
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: unittests
name: ${{ github.run_id }}-py-${{ matrix.python-version }}-${{ matrix.browser }}