Skip to content

ci: add GitHub Actions workflow for unit tests#47

Open
hashwnath wants to merge 1 commit into
microsoft:mainfrom
hashwnath:ci/add-github-actions-workflow
Open

ci: add GitHub Actions workflow for unit tests#47
hashwnath wants to merge 1 commit into
microsoft:mainfrom
hashwnath:ci/add-github-actions-workflow

Conversation

@hashwnath

Copy link
Copy Markdown

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

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)

Adds .github/workflows/ci.yml that runs pytest tests/unit/ on every
push and pull request to main.

- Tests Python 3.10, 3.11, 3.12, 3.13 on ubuntu-latest
- Adds a windows-latest smoke test on 3.13 to guard against
  platform-specific issues (non-UTF-8 stdout, missing /bin/bash)
- Pins both actions to full SHA digests for supply-chain integrity
- Caches pip downloads via setup-python built-in cache (keyed on
  pyproject.toml hash)
- Restricts GITHUB_TOKEN to contents: read (OSSF Scorecard compliance)
- Cancels in-progress runs when a new commit is pushed to the same
  branch/PR
- 10-minute job timeout to prevent runaway jobs
- No Playwright browser install needed: all 16 unit tests pass without
  browser binaries (confirmed locally)

Also declares pytest>=7.4 as a [dev] optional dependency in
pyproject.toml so `pip install -e ".[dev]"` resolves the test runner
cleanly without a bare unpinned pip install.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants