Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

no easy way to port rules_webtesting from WORKSPACE to MODULE.bazel #505

@jmhodges

Description

@jmhodges

It would be nice if there was an easier way to instantiage rules_web_testing_go in a WORKSPACE in order to afford a migration to bzlmod. The current modularization breaks things unless you do a lot of hoop jumping.

Specifically, the load path for go_web_test_suite changes from //go/web:go.bzl to //web:go.bzl, and there seems to be no straightforward way to correct that.

There's seemingly no easy way to get rules_web_testing_go (from 0.4.0 and 0.4.1) to work the same way in a WORKSPACE as it does in a MODULE.bazel. (Using strip_prefix on the rules_web_testing_go repo in the WORKSPACE, for instance, removes the file that //web:go.bzl is symlinked to).

I'd managed to get a WORKSPACE working with 0.4.0 and 0.4.1 by "just" copying the rules_webtesting http_archive, giving it a new name, and then using the @rules_webtesting paths for the browsers, but using @rules_web_testing_go to load go_web_test_suite. But that breaks because it only happened to work because I was loading from //go/web:go.bzl instead of the //web:go.bzl the MODULE.bazel version would use.

I've still not figured out all the hoops you need to jump through, yet (thought I suspect commenting out the loads and uses of go_web_suite_test and then adding the necessary bits ot MODULE.bazel manually would work). It'd be cool if the rules_webtesting code layout (perhaps by duplicating instead of symlinking the files, if that actually does it?) or docs could help out future people like me.

Here's some of the files in question

WORKSPACE contained:

http_archive(
    name = "rules_webtesting",
    sha256 = "574f1c0aa072c187194d60beda7f5be15e139a5e0096089a7710818eec3a4f62",
    strip_prefix = "rules_webtesting-0.4.1",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_webtesting/releases/download/0.4.1/rules_webtesting-0.4.1.tar.gz",
        "https://github.com/bazelbuild/rules_webtesting/releases/download/0.4.1/rules_webtesting-0.4.1.tar.gz",
    ],
)

http_archive(
    name = "rules_web_testing_go",
    sha256 = "574f1c0aa072c187194d60beda7f5be15e139a5e0096089a7710818eec3a4f62",
    strip_prefix = "rules_webtesting-0.4.1",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_webtesting/releases/download/0.4.1/rules_webtesting-0.4.1.tar.gz",
        "https://github.com/bazelbuild/rules_webtesting/releases/download/0.4.1/rules_webtesting-0.4.1.tar.gz",
    ],
)

My service's BUILD.bazel contains:

load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test", "gomock")
load("@rules_web_testing_go//go/web:go.bzl", "go_web_test_suite")

go_web_test_suite(
    name = "integration_test",
    # ...
    browser_overrides = {
        "@rules_webtesting//browsers:chromium-local": {
          # ...
         },
     },
    browsers = [
        "@rules_webtesting//browsers:chromium-local",
    ],
   # ...
)

And you'll get errors like:

ERROR: Skipping '//...': error loading package under directory '': error loading package 'go/svc/howsmyssl-billing': Label '@@rules_web_testing_go~//go/web:go.bzl' is invalid because 'go/web' is not a package; perhaps you meant to put the colon here: '@@rules_web_testing_go~//:go/web/go.bzl'?

from migrate_to_bzlmod.py (well, migrate2bzlmod -t //...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions