From afaafe0546a94dcc068c8b6cf0726b9c7501c4e8 Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Sat, 23 May 2026 21:33:17 +0100 Subject: [PATCH] chore: final post-Rust cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes leftover scaffolding and stale references that survived the Starlark migration and earlier WORKSPACE-example removal: Deleted: - tools/BUILD.bazel (empty) - tools/config_setting/ (older duplicate of tools/platforms/, no consumers) - playwright/private/cli/src/test/ (Rust unit-test fixtures) - docs/starlark_no_rust_spike.md (migration write-up — work is done) - renovate.json (dependabot.yml now covers github-actions, bazel, npm) Edited: - .gitignore: drop /target and the "Added by cargo" marker - .bazelignore: drop target/ - .github/dependabot.yml: drop two /examples/workspace entries (the example directory was removed in PR #7) - README.md: drop links to docs/extensions.md / repositories.md / integrity_map.md — those files exist only in the released doc tarball, not in source - CONTRIBUTING.md: drop the "bazel run //:gazelle" instruction — no gazelle target is configured in this repo Co-Authored-By: Claude Opus 4.7 (1M context) --- .bazelignore | 1 - .github/dependabot.yml | 11 -- .gitignore | 3 - CONTRIBUTING.md | 6 - README.md | 8 -- docs/starlark_no_rust_spike.md | 109 ------------------ playwright/private/cli/src/test/BUILD.bazel | 0 playwright/private/cli/src/test/browsers.json | 65 ----------- renovate.json | 18 --- tools/BUILD.bazel | 0 tools/config_setting/BUILD.bazel | 56 --------- 11 files changed, 277 deletions(-) delete mode 100644 docs/starlark_no_rust_spike.md delete mode 100644 playwright/private/cli/src/test/BUILD.bazel delete mode 100644 playwright/private/cli/src/test/browsers.json delete mode 100644 renovate.json delete mode 100644 tools/BUILD.bazel delete mode 100644 tools/config_setting/BUILD.bazel diff --git a/.bazelignore b/.bazelignore index 31286f4..9b45899 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1,4 +1,3 @@ -target/ node_modules/ examples/ gen/ \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cbf0387..e022abf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,19 +10,8 @@ updates: schedule: interval: "weekly" - - package-ecosystem: "bazel" - directory: "/examples/workspace" - schedule: - interval: "weekly" - - package-ecosystem: "npm" directory: "/examples/rules_js" schedule: interval: "weekly" open-pull-requests-limit: 10 - - - package-ecosystem: "npm" - directory: "/examples/workspace" - schedule: - interval: "weekly" - open-pull-requests-limit: 10 diff --git a/.gitignore b/.gitignore index 169e994..ea5f038 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,4 @@ bazel-* .ijwb/ node_modules out/ -# Added by cargo - -/target MODULE.bazel.lock diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea0e6f0..d8e5769 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,12 +19,6 @@ pre-commit install Otherwise later tooling on CI will yell at you about formatting/linting violations. -## Updating BUILD files - -Some targets are generated from sources. -Currently this is just the `bzl_library` targets. -Run `bazel run //:gazelle` to keep them up-to-date. - ## Using this as a development dependency of other rules You'll commonly find that you develop in another WORKSPACE, such as diff --git a/README.md b/README.md index b96b2f1..160f6c0 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,6 @@ Bazel rules for downloading and using Playwright browsers. These rules provide a `rules_playwright` provides Bazel targets for downloading Playwright browser binaries for use in your Bazel builds. It handles platform-specific downloads and configuration, making it easier to integrate browser-based testing into your Bazel workspace. -## Documentation - -For detailed information on the rules and how to use them, see: - -- [Module extension](docs/extensions.md) -- [Repository rule](docs/repositories.md) -- [Generating an integrity map](docs/integrity_map.md) - ## Setup Add the following to your `MODULE.bazel` file: diff --git a/docs/starlark_no_rust_spike.md b/docs/starlark_no_rust_spike.md deleted file mode 100644 index f4e6aa4..0000000 --- a/docs/starlark_no_rust_spike.md +++ /dev/null @@ -1,109 +0,0 @@ -# Spike: Remove Rust CLI and implement in Starlark - -## Question -Can `rules_playwright` remove the Rust CLI and run fully in Starlark? - -## Short answer -Yes, with moderate refactor cost. There are no fundamental blockers. - -## What Rust does today -The Rust binary (used via `//tools/release:cli`) provides 4 subcommands: - -1. `workspace` -- Reads `browsers.json` + embedded `download_paths.json` -- Expands browser/platform matrix -- Generates repository BUILD files (`BUILD.bazel`, `aliases/BUILD.bazel`, `browsers/BUILD.bazel`) - -2. `http-files` -- Computes `{name, path}` entries for `http_file(...)` repositories - -3. `unzip` -- Extracts browser zip archive to output tree artifact - -4. `integrity-map` -- Computes SHA256 for browser archives and writes JSON map - -## Where Rust is wired in -- `playwright/extensions.bzl` calls CLI `http-files` -- `playwright/repositories.bzl` calls CLI `workspace` and `http-files` -- `playwright/private/unzip_browser.bzl` calls CLI `unzip` -- `playwright/private/integrity_map.bzl` calls CLI `integrity-map` - -## Feasibility by feature - -### 1) Replace `workspace` and `http-files` with pure Starlark -Feasible. - -Repository/module extension code already has everything needed: -- `json.decode` for `browsers.json` and `download_paths.json` -- string formatting/replacement for URL templates -- `ctx.file` / `module_ctx.file` to generate BUILD files - -Implementation approach: -- Add a Starlark helper module (e.g. `playwright/private/browser_targets.bzl`) implementing the same target expansion logic currently in `browser_targets.rs` -- Read `download_paths.json` as a normal source file instead of embedding it in a binary -- Return the browser/path structures directly in Starlark -- Write repository files directly from Starlark templates - -### 2) Replace `unzip` rule implementation -Feasible. - -Current Rust unzip can be replaced with: -- `ctx.actions.run_shell` calling `unzip` (less hermetic), or -- Bazel-provided zipper tool (preferred), if wired as an executable tool dependency. - -This is a straightforward rule rewrite. - -### 3) Replace `integrity-map` -Feasible. - -Can be rewritten as: -- `ctx.actions.run_shell` using `sha256sum`/`shasum` and JSON assembly, or -- small hermetic helper script/tool. - -This is the least elegant part in pure Starlark because hashing happens in an action, but it does not require Rust specifically. - -## Main risks/tradeoffs - -1. Re-implementing matrix logic correctly -- Must preserve behavior around: - - `-headless-shell` expansion - - revision overrides per platform - - platform aliases/groups - - deterministic sorting - -2. Hermeticity for unzip/hash actions -- Need to choose tools carefully to avoid host-dependent behavior. - -3. Cross-platform stability -- Existing Rust path is already cross-platform for these operations. -- New shell-based actions need explicit portability handling. - -## Benefits of removing Rust - -- Simpler contributor setup (no Rust toolchain/crate universe for this repo) -- Smaller release artifact surface (no prebuilt CLI binaries) -- Less moving parts in module lock stability across platforms - -## Costs - -- One-time refactor of repository generation logic and action tooling -- Need strong regression tests for generated targets and labels - -## Recommended migration path - -1. Phase 1 (low risk): -- Rewrite `workspace` + `http-files` in Starlark -- Keep Rust only for `unzip` and `integrity-map` - -2. Phase 2: -- Replace `unzip` with Starlark action using hermetic unzip tool - -3. Phase 3: -- Replace `integrity-map` hashing action - -4. Phase 4: -- Remove Rust module/toolchain, CLI sources, and prebuilt artifacts - -## Verdict -A fully Starlark implementation is practical and likely worth it if this fork is intended to be the long-term canonical version. The safest way is incremental replacement with parity tests after each phase. diff --git a/playwright/private/cli/src/test/BUILD.bazel b/playwright/private/cli/src/test/BUILD.bazel deleted file mode 100644 index e69de29..0000000 diff --git a/playwright/private/cli/src/test/browsers.json b/playwright/private/cli/src/test/browsers.json deleted file mode 100644 index 81f1d3a..0000000 --- a/playwright/private/cli/src/test/browsers.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "comment": "Do not edit this file, use utils/roll_browser.js", - "browsers": [ - { - "name": "chromium", - "revision": "1148", - "installByDefault": true, - "browserVersion": "131.0.6778.33" - }, - { - "name": "chromium-headless-shell", - "revision": "1148", - "installByDefault": true, - "browserVersion": "131.0.6778.33" - }, - { - "name": "chromium-tip-of-tree", - "revision": "1277", - "installByDefault": false, - "browserVersion": "132.0.6834.0" - }, - { - "name": "firefox", - "revision": "1466", - "installByDefault": true, - "browserVersion": "132.0" - }, - { - "name": "firefox-beta", - "revision": "1465", - "installByDefault": false, - "browserVersion": "132.0b8" - }, - { - "name": "webkit", - "revision": "2104", - "installByDefault": true, - "revisionOverrides": { - "mac10.14": "1446", - "mac10.15": "1616", - "mac11": "1816", - "mac11-arm64": "1816", - "mac12": "2009", - "mac12-arm64": "2009", - "ubuntu20.04-x64": "2092", - "ubuntu20.04-arm64": "2092" - }, - "browserVersion": "18.2" - }, - { - "name": "ffmpeg", - "revision": "1010", - "installByDefault": true, - "revisionOverrides": { - "mac12": "1010", - "mac12-arm64": "1010" - } - }, - { - "name": "android", - "revision": "1001", - "installByDefault": false - } - ] -} diff --git a/renovate.json b/renovate.json deleted file mode 100644 index e2bab3e..0000000 --- a/renovate.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - ":dependencyDashboard", - ":enablePreCommit", - ":semanticPrefixFixDepsChoreOthers", - "group:monorepos", - "group:recommended", - "replacements:all", - "workarounds:all" - ], - "packageRules": [ - { - "matchFiles": ["MODULE.bazel"], - "enabled": false - } - ] -} diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel deleted file mode 100644 index e69de29..0000000 diff --git a/tools/config_setting/BUILD.bazel b/tools/config_setting/BUILD.bazel deleted file mode 100644 index 6d4a2a5..0000000 --- a/tools/config_setting/BUILD.bazel +++ /dev/null @@ -1,56 +0,0 @@ -load("//playwright:defs.bzl", "LINUX_DISTROS", "MACOS_VERSIONS") - -package(default_visibility = ["//visibility:public"]) - -config_setting( - name = "linux_x86_64", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - ], -) - -config_setting( - name = "linux_arm64", - constraint_values = [ - "@platforms//cpu:arm64", - "@platforms//os:linux", - ], -) - -config_setting( - name = "macos_x86_64", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:macos", - ], -) - -config_setting( - name = "macos_arm64", - constraint_values = [ - "@platforms//cpu:arm64", - "@platforms//os:macos", - ], -) - -[ - config_setting( - name = "mac{}".format(version), - values = { - "//:macos_version": version, - }, - ) - - for version in MACOS_VERSIONS -] - -[ - config_setting( - name = distro, - values = { - "//:linux_distro": distro, - }, - ) - for distro in LINUX_DISTROS -]