feat(dev-infra): add bazel firefox browser with RBE compatibility (#38029)

Adds Firefox as browser to `dev-infra/browsers` with RBE
compatibility. The default Firefox browser is not compatible similar to
the default Chromium version exposed by `rules_webtesting`.

The Angular Components repository will use this browser target as
it enables RBE support. Also it gives us more flexibility about
the Firefox version we test against. The version provided by
`rules_webtesting` is very old and most likely not frequently
updated (based on past experience).

PR Close #38029
This commit is contained in:
Paul Gschwendtner
2020-07-13 22:25:46 +02:00
committed by Andrew Kushnir
parent b40d3c0817
commit 7abb48adfe
13 changed files with 372 additions and 173 deletions

View File

@ -0,0 +1,74 @@
# Copyright Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
#
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive")
# Override of firefox web_test_archive so that the archive is selected based on platform.
web_test_archive(
name = "firefox_archive",
testonly = True,
archive = select({
"@io_bazel_rules_webtesting//common/conditions:linux": "@org_mozilla_firefox_amd64//file",
"@io_bazel_rules_webtesting//common/conditions:mac": "@org_mozilla_firefox_macos//file",
}),
extract = "build",
named_files = select({
"@io_bazel_rules_webtesting//common/conditions:linux": {"FIREFOX": "firefox/firefox"},
"@io_bazel_rules_webtesting//common/conditions:mac": {"FIREFOX": "Firefox.app/Contents/MacOS/firefox"},
}),
visibility = ["//dev-infra/browsers:__subpackages__"],
)
# Override of geckodriver web_test_archive so that the archive is selected based on platform.
web_test_archive(
name = "geckodriver_archive",
testonly = True,
archive = select({
"@io_bazel_rules_webtesting//common/conditions:linux": "@org_mozilla_geckodriver_amd64//file",
"@io_bazel_rules_webtesting//common/conditions:mac": "@org_mozilla_geckodriver_macos//file",
}),
extract = "build",
named_files = {"GECKODRIVER": "geckodriver"},
visibility = ["//dev-infra/browsers:__subpackages__"],
)
browser(
name = "firefox",
disabled = select({
# TODO: Consider adding support for Windows. Requires a portable version of
# Firefox. Official distribution only ships with installers.
"@io_bazel_rules_webtesting//common/conditions:windows": "Firefox is not supported on Windows",
"//conditions:default": None,
}),
metadata = "firefox.json",
visibility = ["//visibility:public"],
deps = select({
"@io_bazel_rules_webtesting//common/conditions:windows": [],
"//conditions:default": [
"@io_bazel_rules_webtesting//go/wsl",
":firefox_archive",
":geckodriver_archive",
],
}),
)
# Make source files available for distribution via pkg_npm
filegroup(
name = "files",
srcs = glob(["*"]),
)

View File

@ -0,0 +1,42 @@
load("//dev-infra/browsers:platform_http_file.bzl", "platform_http_file")
"""
Defines repositories for Firefox that can be used inside Karma unit tests
and Protractor e2e tests with Bazel.
"""
def define_firefox_repositories():
# Instructions on updating the Firefox version can be found in the `README.md` file
# next to this file.
platform_http_file(
name = "org_mozilla_firefox_amd64",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "bde6e020556a21561e4b8d7aaecf8db7077951f179b98ca5d0305435bc6802c9",
# Firefox v78.0
urls = ["https://ftp.mozilla.org/pub/firefox/releases/78.0/linux-x86_64/en-US/firefox-78.0.tar.bz2"],
)
platform_http_file(
name = "org_mozilla_firefox_macos",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "69a0ae139814cc314d0c5e3fd3859e0ac9de8517550d7d32b06c57022a14f49e",
# Firefox v78.0
urls = ["https://ftp.mozilla.org/pub/firefox/releases/78.0/mac/en-US/Firefox%2078.0.dmg"],
)
platform_http_file(
name = "org_mozilla_geckodriver_amd64",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "d59ca434d8e41ec1e30dd7707b0c95171dd6d16056fb6db9c978449ad8b93cc0",
# Geckodriver v0.26.0
urls = ["https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz"],
)
platform_http_file(
name = "org_mozilla_geckodriver_macos",
licenses = ["reciprocal"], # MPL 2.0
sha256 = "4739ef8f8af5d89bd4a8015788b4dc45c2f5f16b2fdc001254c9a92fe7261947",
# Geckodriver v0.26.0
urls = ["https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-macos.tar.gz"],
)

View File

@ -0,0 +1,21 @@
{
"environment": "local",
"capabilities": {
"browserName": "firefox",
"moz:firefoxOptions": {
"binary": "%FILE:FIREFOX%",
"args": ["--headless"]
},
"google:wslConfig": {
"binary": "%FILE:GECKODRIVER%",
"port":"%WSLPORT:WSL%",
"args": [
"--port=%WSLPORT:WSL%",
"--host=%WSL:HOST_IP%",
"--marionette-port=%WSLPORT:MARIONETTE%"
],
"status": true,
"shutdown": false
}
}
}