|
| 1 | +--- |
| 2 | +name: playwright-triage |
| 3 | +description: Triage and fix one microsoft/playwright-python issue, or do a maintainer's task, unattended inside the Issue triage GitHub Actions workflow (.github/workflows/triage.yml), which a needs-triage, needs-triage-mac or needs-triage-win label starts, or a maintainer starts by hand with an issue, a task or both. Reproduces the issue on the runner, then leaves a verified fix proposal for the workflow to open as a draft PR, an investigation note for it to post on the issue, or an upstream bug report for a maintainer to file in microsoft/playwright. Only for that workflow. |
| 4 | +--- |
| 5 | + |
| 6 | +# Playwright Python Issue Triage |
| 7 | + |
| 8 | +You run unattended in the [Issue triage](../../../.github/workflows/triage.yml) workflow of |
| 9 | +`microsoft/playwright-python`. First read the shared guide, `$AGENT_GUIDES_DIR/triage.md`, a copy of |
| 10 | +[microsoft/playwright/.github/actions/run-agent/guides/triage.md](https://github.com/microsoft/playwright/blob/main/.github/actions/run-agent/guides/triage.md), |
| 11 | +and then [AGENTS.md](../../../AGENTS.md), both in full. The guide says how to triage an issue in any |
| 12 | +Playwright repo. AGENTS.md says how to build, test and lint this one, and where a regression test |
| 13 | +goes. This file covers what neither has: the checkouts, how to run a published version, and the |
| 14 | +outcome that this repo adds, an upstream bug report. |
| 15 | + |
| 16 | +## The checkouts |
| 17 | + |
| 18 | +`$REPO_DIR` is the checkout of `microsoft/playwright-python` that the guide describes. Its requirements |
| 19 | +are installed (`pip install -r local-requirements.txt`, `pip install -r requirements.txt`, |
| 20 | +`pip install -e .`), the wheel is built (`python -m build --wheel`, which builds the driver into |
| 21 | +`playwright/driver/`), and Chromium, Firefox and WebKit are installed with |
| 22 | +`python -m playwright install --with-deps`. It is the working directory, and the checkout that the |
| 23 | +guides refer to. The clone is shallow: run `git fetch --unshallow --tags origin` in it before you |
| 24 | +bisect or use `git tag --contains`. |
| 25 | + |
| 26 | +`$PLAYWRIGHT_DIR` is `$REPO_DIR/.upstream/`, a full clone of `microsoft/playwright` at the commit |
| 27 | +in `DRIVER_VERSION`, created by `python scripts/upstream.py checkout`. The driver was built from it. |
| 28 | +Read upstream code there. Do not edit, commit or switch branches in it: the wheel build and |
| 29 | +`./scripts/lint.sh` stop when it is not at that commit or has local changes. Before you run upstream |
| 30 | +tests in it, it needs `npm ci`, `npm run build` and `npx playwright install`. The wheel build |
| 31 | +(`scripts/build_driver.py`) ran the first two there; run them again when `node_modules/` is missing. |
| 32 | + |
| 33 | +## Published versions |
| 34 | + |
| 35 | +To run a published version, for example to bisect, create `$SCRATCH_DIR/playwright-python-<n>/<version>/` |
| 36 | +and run there: |
| 37 | + |
| 38 | +```bash |
| 39 | +python -m venv env && source env/bin/activate # env\Scripts\activate on Windows |
| 40 | +pip install playwright==<version> |
| 41 | +python -m playwright install |
| 42 | +``` |
| 43 | + |
| 44 | +The fixtures of the repo are not available there. Write the condensed repro as a plain script with |
| 45 | +`sync_playwright()` or `async_playwright()` in that directory, with `page.set_content()` in place of |
| 46 | +the test server, and run it from there. In `$REPO_DIR`, the source tree shadows the installed package. |
| 47 | + |
| 48 | +The driver of a release is in `DRIVER_VERSION` at its tag: `git show v<version>:DRIVER_VERSION` |
| 49 | +prints the upstream commit it was built from, or, for releases up to 1.64, the `playwright-core` |
| 50 | +version of the driver; `npm view playwright-core@<core version> gitHead` prints its commit. Match a |
| 51 | +regression in the driver to commits with `git -C $PLAYWRIGHT_DIR log <good>..<bad> -- <path>`. |
| 52 | + |
| 53 | +## Upstream bugs |
| 54 | + |
| 55 | +The client talks to the Node driver that is built from `$PLAYWRIGHT_DIR`, and `microsoft/playwright` |
| 56 | +and this repo are one team. Reproduce the bug in Python first. Then write the same calls as an |
| 57 | +upstream test and run it in `$PLAYWRIGHT_DIR`. The triage skill of `microsoft/playwright`, in |
| 58 | +`$PLAYWRIGHT_DIR/.claude/skills/playwright-triage/`, says where such a test goes, which fixtures it |
| 59 | +uses and how to run it. The rest of that skill is not for this run. Put the test in a new spec |
| 60 | +file, and delete the file when you are done, so that the checkout is clean. |
| 61 | + |
| 62 | +- The Node test passes: the bug is in the Python client. Fix it here. |
| 63 | +- The Node test fails too: the root cause is upstream, and the fix lands in `microsoft/playwright`. |
| 64 | + Do not work around it in `playwright/_impl/`. Run `git -C $PLAYWRIGHT_DIR fetch origin main`. |
| 65 | + When `git -C $PLAYWRIGHT_DIR log HEAD..origin/main -- <path>` shows a fix that already landed, |
| 66 | + the note says that it reaches this repo with the next roll. Otherwise write the report. |
| 67 | +- The Python API lacks a member or an option: the generated API has everything that the upstream |
| 68 | + docs in `$PLAYWRIGHT_DIR/docs/src/api` give Python (`* langs:` decides; no `langs` means every |
| 69 | + language). The gap is in the docs, so it is an upstream change too. Do not edit a generated file, |
| 70 | + and do not add to `scripts/codegen/python_rules.js` to go around the docs. |
| 71 | + |
| 72 | +Create `$OUTPUT_DIR/upstream/` with: |
| 73 | + |
| 74 | +- `report.md`: the report for an engineer of `microsoft/playwright` who did not read the Python |
| 75 | + issue: what fails, expected versus actual, the versions (the Python package, the commit in |
| 76 | + `DRIVER_VERSION`, the browser, the platform), the root cause when you found it, and the condensed |
| 77 | + Node test as the repro. |
| 78 | +- `report.json`: `{"title": "..."}`, at most 256 characters, for example |
| 79 | + `route.fulfill() drops the charset of Content-Type`. |
| 80 | + |
| 81 | +The comment job appends the title and the body to your comment, for a maintainer to file in |
| 82 | +`microsoft/playwright`. The bot never files it. Write `report.json` last, when `report.md` and the |
| 83 | +comment are done. Like `proposal.json`, it marks the report as ready. |
| 84 | + |
| 85 | +## PRs from third parties |
| 86 | + |
| 87 | +Do not run a PR that changes `setup.py`, `pyproject.toml`, `setup.cfg`, `local-requirements.txt`, |
| 88 | +`requirements.txt`, `DRIVER_VERSION`, `NODE_VERSION`, `.pre-commit-config.yaml`, `test.sh`, |
| 89 | +`scripts/`, `utils/`, `.github/`, `.azure-pipelines/`, `.claude/`, or a generated file. A PR that |
| 90 | +changes a ported test under `tests/{async,sync}/{page,library}`, or adds a mark to one, has faults: |
| 91 | +the ports have zero deviations. |
0 commit comments