Webwright
Webwright copied to clipboard
ci: add GitHub Actions workflow for unit tests
Why
Webwright has no CI today. tests/unit/ already contains 16 unit tests across two files, but they are never exercised automatically. Without CI, regressions can land silently — especially as contributor volume grows (300+ forks, multiple open PRs in flight).
What this workflow does
- Runs
pytest tests/unit/ -v --tb=shorton every push tomainand every pull request targetingmain - Covers Python 3.10, 3.11, 3.12, and 3.13 on
ubuntu-latest - Adds a
windows-latestsmoke test (Python 3.13) to guard against platform-specific issues — relevant to the open Windows bugs (#7 UnicodeEncodeError, #30/bin/bash -nnot found) - Caches pip downloads via
setup-python's built-in cache key (hashed onpyproject.toml) — saves ~20 s per matrix leg on warm cache - Cancels stale runs when a new commit is pushed to the same PR branch (
concurrency:block) - Restricts
GITHUB_TOKENtocontents: read— satisfies OSSF Scorecard "Token-Permissions" check - Pins both actions to full SHA digests with version comments for supply-chain integrity
- 10-minute job
timeout-minutesto prevent runaway jobs
What it intentionally does NOT do
- No
playwright install chromium— all 16 current unit tests are pure-Python.check_screenshot()and friends gracefully return(False, "message")when no browser binary is installed. Confirmed locally: 16/16 pass with onlypip install -e ".[dev]". - No linting step — no
ruff/flake8config exists yet; that is a separate discussion. ATODOcomment is left in the workflow. - Does not touch
README.md— badge snippet below for optional use.
pyproject.toml change
Adds a [project.optional-dependencies] section with dev = ["pytest>=7.4"] so pip install -e ".[dev]" resolves the test runner without a bare unpinned pip install pytest. This is a 2-line addition.
Verified locally
16 passed in 2.17s
All 16 tests pass on Python 3.11 without Playwright browser binaries.
Optional README badge
[](https://github.com/microsoft/Webwright/actions/workflows/ci.yml)