Skip to content

devops: Build driver from source#3092

Open
Skn0tt wants to merge 2 commits into
microsoft:mainfrom
Skn0tt:skn0tt/build-driver-from-source
Open

devops: Build driver from source#3092
Skn0tt wants to merge 2 commits into
microsoft:mainfrom
Skn0tt:skn0tt/build-driver-from-source

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented Jun 8, 2026

Build the Playwright driver from source instead of downloading it from the CDN

setup.py no longer downloads the prebuilt driver bundles from
cdn.playwright.dev. Instead it clones microsoft/playwright at tag
v{driver_version} and builds the six platform bundles from source via the
upstream utils/build/build-playwright-driver.sh, then embeds them into the
platform wheels exactly as before. Same released version, same artifacts — just
self-built, so the wheels no longer depend on the CDN being reachable.

What changed

  • setup.py: download_driver()ensure_driver_bundle(), which shells
    out to a new portable scripts/build_driver.sh <version> (and early-returns if
    the target bundle already exists).
  • scripts/build_driver.sh (new): portable bash builder that clones the
    pinned tag and produces all six bundles on a single host. Written in bash so it
    can be shared with the other language ports.
  • .github/workflows/ci.yml: a single build-driver job builds the bundles
    once on Linux and shares them via the driver-bundles artifact; the infra,
    build, and test-stable jobs download + verify the bundles instead of each
    rebuilding the toolchain. Cross-platform builds all happen on Linux (upstream's
    script fetches a per-target Node), so Windows/macOS only need the prebuilt zips.
  • .github/workflows/{publish_docker,test_docker}.yml,
    .azure-pipelines/publish.yml
    : provision Node so the wheel build can compile
    the driver.
  • Docs (CONTRIBUTING.md, ROLLING.md, CLAUDE.md,
    .claude/skills/playwright-roll/SKILL.md): document the build-from-source flow.

Notes

  • Rebased on top of current main (driver 1.60.0); contains no conda changes
    (rebased after chore: drop Conda distribution #3091 dropped the conda distribution).
  • Opening as a draft to see CI.

@Skn0tt Skn0tt force-pushed the skn0tt/build-driver-from-source branch 4 times, most recently from 154bd49 to 6e606d2 Compare June 8, 2026 12:01
@Skn0tt Skn0tt changed the title Build the Playwright driver from source instead of the CDN devops: Build driver from source Jun 8, 2026
@Skn0tt Skn0tt force-pushed the skn0tt/build-driver-from-source branch from 6e606d2 to 489119a Compare June 8, 2026 12:05
@Skn0tt Skn0tt marked this pull request as ready for review June 8, 2026 12:28
@Skn0tt Skn0tt requested a review from dgozman June 8, 2026 12:29
Skn0tt and others added 2 commits June 8, 2026 15:37
Stop downloading the prebuilt Playwright driver bundle from
cdn.playwright.dev. Instead, clone microsoft/playwright at the tag
matching driver_version and build the per-platform bundles from source
via upstream's utils/build/build-playwright-driver.sh.

- scripts/build_driver.sh: portable bash script (shareable across the
  language forks) that clones, builds (npm ci && npm run build), runs the
  upstream driver build, and stages all 6 platform zips into driver/.
- setup.py: ensure_driver_bundle() shells out to the script when a bundle
  is missing; stale extract-dir cleanup before extraction.
- CI/release: add Node 24 (matching the bundled runtime major) wherever
  wheels are built — ci.yml, publish_docker.yml, test_docker.yml host,
  Azure NodeTool; meta.yaml conda host gains git + nodejs.
- Docs: ROLLING.md, CONTRIBUTING.md, CLAUDE.md, playwright-roll SKILL.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The per-job source build can't run on Windows (Git Bash lacks zip/unzip and
the heavy upstream monorepo build is not exercised there), and rebuilding the
fully cross-platform driver in every wheel job is redundant and slow.

Add a single 'build-driver' job that builds all six platform bundles on Linux
and uploads them as a workflow artifact. Every wheel-building job (Lint, Build,
Stable, Conda) now downloads that artifact into driver/ so setup.py's
ensure_driver_bundle early-returns and embeds the prebuilt zip -- no Node, bash
or zip/unzip needed on Windows/macOS. A verify step asserts all six bundles are
present before building.

Docker and Azure publish are unchanged: they run on Linux and build the driver
once on their own host, which already works.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Skn0tt Skn0tt force-pushed the skn0tt/build-driver-from-source branch from 489119a to d5585a5 Compare June 8, 2026 13:37
Comment thread scripts/build_driver.sh
}

clone_source() {
# Reuse an existing checkout only if it already points at exactly the pinned
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure why wipe the repo, instead of fetch/checkout the desired commit?

Comment thread scripts/build_driver.sh
echo "Installing Playwright dependencies (npm ci)"
(cd "$SOURCE_DIR" && npm ci)
echo "Building Playwright (npm run build)"
(cd "$SOURCE_DIR" && npm run build)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend npm run clean as well for a reused checkout.

Comment thread setup.py
# Don't replace this with urllib - Python won't have certificates to do SSL on all platforms.
subprocess.check_call(["curl", url, "-o", temp_destination_path])
os.rename(temp_destination_path, destination_path)
# Build all platform bundles from source (microsoft/playwright @ the commit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like I saw this comment ~15 times in this PR 😄

Comment thread setup.py
without_platform = base_wheel_location[:-7]
download_driver(wheel_bundle["zip_name"])
zip_file = f"driver/playwright-{driver_version}-{wheel_bundle['zip_name']}.zip"
ensure_driver_bundle(wheel_bundle["zip_name"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to add all drivers for all platforms into the single wheel now, since we build all of them at once? Add a filter somewhere?

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