Webwright icon indicating copy to clipboard operation
Webwright copied to clipboard

ci: add GitHub Actions workflow for unit tests

Open hashwnath opened this issue 5 months ago • 0 comments

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=short on every push to main and every pull request targeting main
  • Covers Python 3.10, 3.11, 3.12, and 3.13 on ubuntu-latest
  • Adds a windows-latest smoke test (Python 3.13) to guard against platform-specific issues — relevant to the open Windows bugs (#7 UnicodeEncodeError, #30 /bin/bash -n not found)
  • Caches pip downloads via setup-python's built-in cache key (hashed on pyproject.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_TOKEN to contents: 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-minutes to 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 only pip install -e ".[dev]".
  • No linting step — no ruff/flake8 config exists yet; that is a separate discussion. A TODO comment 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

[![CI](https://github.com/microsoft/Webwright/actions/workflows/ci.yml/badge.svg)](https://github.com/microsoft/Webwright/actions/workflows/ci.yml)

hashwnath avatar Jun 07 '26 05:06 hashwnath