Skip to content

Commit 6b2ef24

Browse files
authored
feat: add support for darwin m1 browsers (#427)
* feat: add support for darwin m1 browsers `rules_webtesting` currently extracts browser archives as part of an build action. Additionally, the platform archive is determined at repository creation using the `repository_ctx.os` property. This breaks remote build execution, and also makes it impossible to support darwin ARM64 because the os name is equal regardless of CPU. This is a good opportunity to move the extraction from a build action to the repository fetching (improving caching and being more Bazel-idiomatic). Additionally, with this approach we will be able to select the browser binaries at configuration time using `select`, allowing for darwin arm64, and proper remote build execution. More details can be found in the description of the `platform_archive` rule. * fixup! feat: add support for darwin m1 browsers Make sure tests can run on Windows and fix Sauce-Connect path prefix issue
1 parent 21b7552 commit 6b2ef24

38 files changed

+936
-528
lines changed

.bazelrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ test --test_env=SAUCE_ACCESS_KEY
44
test --test_env=TUNNEL_IDENTIFIER
55
test --test_env=BUILD_TAG
66
test --local_test_jobs=5
7+
8+
# Do not build runfile forests by default. If an execution strategy relies on runfile
9+
# forests, the forest is created on-demand. See: https://github.com/bazelbuild/bazel/issues/6627
10+
# and https://github.com/bazelbuild/bazel/commit/03246077f948f2790a83520e7dccc2625650e6df
11+
# Note: This also works around an issue where Bazel does not support spaces in runfiles. The
12+
# Chromium app files for Darwin contain files with spaces and this would break. For darwin though,
13+
# the sandbox strategy is used anyway and runfile forests are not needed.
14+
# Related Bazel bug: https://github.com/bazelbuild/bazel/issues/4327.
15+
build --nobuild_runfile_links

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ bazel-*
44
*.pyc
55
.vs/*
66
user.bazelrc
7+
8+
.idea/

WORKSPACE

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,33 @@ web_test_repositories()
2828

2929
http_archive(
3030
name = "io_bazel_rules_go",
31-
sha256 = "313f2c7a23fecc33023563f082f381a32b9b7254f727a7dd2d6380ccc6dfe09b",
31+
sha256 = "8e968b5fcea1d2d64071872b12737bbb5514524ee5f0a4f54f5920266c261acb",
3232
urls = [
33-
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.19.3/rules_go-0.19.3.tar.gz",
34-
"https://github.com/bazelbuild/rules_go/releases/download/0.19.3/rules_go-0.19.3.tar.gz",
33+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
34+
"https://github.com/bazelbuild/rules_go/releases/download/v0.28.0/rules_go-v0.28.0.zip",
3535
],
3636
)
3737

3838
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
3939

4040
go_rules_dependencies()
4141

42-
go_register_toolchains()
42+
go_register_toolchains(version = "1.16.5")
4343

4444
http_archive(
4545
name = "bazel_gazelle",
46-
sha256 = "be9296bfd64882e3c08e3283c58fcb461fa6dd3c171764fcc4cf322f60615a9b",
46+
sha256 = "62ca106be173579c0a167deb23358fdfe71ffa1e4cfdddf5582af26520f1c66f",
4747
urls = [
48-
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz",
49-
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.1/bazel-gazelle-0.18.1.tar.gz",
48+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
49+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
5050
],
5151
)
5252

5353
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
5454

5555
gazelle_dependencies()
5656

57-
load("//web/versioned:browsers-0.3.2.bzl", "browser_repositories")
57+
load("//web/versioned:browsers-0.3.3.bzl", "browser_repositories")
5858

5959
browser_repositories(
6060
chromium = True,

browsers/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ browser(
6363
browser(
6464
name = "firefox-local",
6565
disabled = select({
66-
"//common/conditions:windows": "firefox not supported on windows",
66+
"//common/conditions:windows_x64": "firefox not supported on windows",
6767
"//conditions:default": None,
6868
}),
6969
metadata = "firefox-local.json",
7070
required_tags = [
7171
"native",
7272
],
7373
deps = select({
74-
"//common/conditions:windows": [],
74+
"//common/conditions:windows_x64": [],
7575
"//conditions:default": [
7676
"//go/wsl",
7777
"//third_party/firefox",

browsers/chromium-local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"goog:chromeOptions" : {
66
"binary" : "%FILE:CHROMIUM%",
77
"args" : [
8-
"--headless",
8+
"--headless",
99
"--no-sandbox",
1010
"--use-gl=swiftshader-webgl"
1111
]

build_files/metadata.BUILD

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
#
1515
################################################################################
1616
#
17+
load("//web/internal:executable_name.bzl", "get_platform_executable_name")
18+
1719
licenses(["notice"]) # Apache 2.0
1820

1921
alias(
2022
name = "main",
21-
actual = select({
22-
"//common/conditions:linux": "linux_amd64_pure_stripped/main",
23-
"//common/conditions:mac": "darwin_amd64_pure_stripped/main",
24-
"//common/conditions:windows": "windows_amd64_pure_stripped/main.exe",
25-
}),
23+
actual = get_platform_executable_name(),
2624
visibility = ["//visibility:public"],
2725
testonly = True,
2826
)

build_files/wsl.BUILD

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ licenses(["notice"]) # Apache 2.0
2020

2121
web_test_named_executable(
2222
name = "wsl",
23+
testonly = True,
2324
alt_name = "WEBDRIVER_SERVER_LIGHT",
24-
executable = select({
25-
"//common/conditions:linux": "main/linux_amd64_pure_stripped/main",
26-
"//common/conditions:mac": "main/darwin_amd64_pure_stripped/main",
27-
"//common/conditions:windows": "main/windows_amd64_pure_stripped/main.exe",
28-
}),
25+
executable = "//go/wsl/main",
2926
visibility = ["//visibility:public"],
30-
testonly = True,
31-
)
27+
)

build_files/wsl_main.BUILD

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2019 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
################################################################################
16+
#
17+
load("//web/internal:executable_name.bzl", "get_platform_executable_name")
18+
19+
licenses(["notice"]) # Apache 2.0
20+
21+
alias(
22+
name = "main",
23+
actual = get_platform_executable_name(),
24+
visibility = ["//visibility:public"],
25+
testonly = True,
26+
)

build_files/wtl.BUILD

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
#
1515
################################################################################
1616
#
17+
load("//web/internal:executable_name.bzl", "get_platform_executable_name")
18+
1719
licenses(["notice"]) # Apache 2.0
1820

1921
alias(
2022
name = "main",
21-
actual = select({
22-
"//common/conditions:linux": "linux_amd64_pure_stripped/main",
23-
"//common/conditions:mac": "darwin_amd64_pure_stripped/main",
24-
"//common/conditions:windows": "windows_amd64_pure_stripped/main.exe",
25-
}),
23+
actual = get_platform_executable_name(),
2624
visibility = ["//visibility:public"],
2725
testonly = True,
2826
)

common/conditions/BUILD.bazel

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,33 @@ package(
1919
)
2020

2121
config_setting(
22-
name = "mac",
23-
values = {"cpu": "darwin"},
22+
name = "linux_x64",
23+
constraint_values = [
24+
"@platforms//os:linux",
25+
"@platforms//cpu:x86_64",
26+
],
2427
)
2528

2629
config_setting(
27-
name = "linux",
28-
values = {"cpu": "k8"},
30+
name = "macos_x64",
31+
constraint_values = [
32+
"@platforms//os:macos",
33+
"@platforms//cpu:x86_64",
34+
],
2935
)
3036

3137
config_setting(
32-
name = "windows",
33-
values = {"cpu": "x64_windows"},
38+
name = "macos_arm64",
39+
constraint_values = [
40+
"@platforms//os:macos",
41+
"@platforms//cpu:aarch64",
42+
],
43+
)
44+
45+
config_setting(
46+
name = "windows_x64",
47+
constraint_values = [
48+
"@platforms//os:windows",
49+
"@platforms//cpu:x86_64",
50+
],
3451
)

0 commit comments

Comments
 (0)