refactor(dev-infra): move shared browser bazel setup into dedicated bazel folder (#42268)

This change moves the `dev-infra/browsers` folder into `dev-infra/bazel`.
The browser folder is providing custom configuration for Bazel, so it
should live within the `bazel` folder for a more well-structured
`dev-infra` folder.

PR Close #42268
This commit is contained in:
Paul Gschwendtner 2021-05-24 16:17:27 +02:00 committed by Jessica Janiuk
parent 49c3ce58bf
commit a16f82b851
16 changed files with 29 additions and 29 deletions

View File

@ -49,7 +49,7 @@ load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories"
web_test_repositories() web_test_repositories()
load("//dev-infra/browsers:browser_repositories.bzl", "browser_repositories") load("//dev-infra/bazel/browsers:browser_repositories.bzl", "browser_repositories")
browser_repositories() browser_repositories()

View File

@ -5,6 +5,7 @@ filegroup(
srcs = [ srcs = [
"BUILD.bazel", "BUILD.bazel",
"expand_template.bzl", "expand_template.bzl",
"//dev-infra/bazel/browsers:files",
"//dev-infra/bazel/remote-execution:files", "//dev-infra/bazel/remote-execution:files",
], ],
) )

View File

@ -4,7 +4,7 @@ package(default_visibility = ["//visibility:public"])
filegroup( filegroup(
name = "files", name = "files",
srcs = glob(["*"]) + [ srcs = glob(["*"]) + [
"//dev-infra/browsers/chromium:files", "//dev-infra/bazel/browsers/chromium:files",
"//dev-infra/browsers/firefox:files", "//dev-infra/bazel/browsers/firefox:files",
], ],
) )

View File

@ -7,8 +7,8 @@ We manually keep the configuration of these two tools in sync to create a consis
## Bazel ## Bazel
Bazel `karma_web_test_suite` and `protractor_web_test_suite` targets will use Chromium or Firefox provisioned by `//dev-infra/browsers`. Bazel `karma_web_test_suite` and `protractor_web_test_suite` targets will use Chromium or Firefox provisioned by `//dev-infra/bazel/browsers`.
The version of Chrome and Firefox are specified in the `chromium.bzl` and `firefox.bzl` files in `/dev-infra/browsers`. The version of Chrome and Firefox are specified in the `chromium.bzl` and `firefox.bzl` files in `/dev-infra/bazel/browsers`.
The process of updating the Chrome or Firefox version is not straightforward, but below are dedicated sections for each browser. The process of updating the Chrome or Firefox version is not straightforward, but below are dedicated sections for each browser.
@ -34,7 +34,7 @@ The process of updating the Chrome or Firefox version is not straightforward, bu
Chromium 83.0.4103.0 Chromium 83.0.4103.0
``` ```
3. Update the chrome & chrome driver build numbers in `dev-infra/browsers/chromium/chromium.bzl` and either run `bazel query @org_chromium_chromium_amd64//...` to prompt Bazel to calculate the new `sha256` for each platform binary or determine the new `sha256` values manually. 3. Update the chrome & chrome driver build numbers in `dev-infra/bazel/browsers/chromium/chromium.bzl` and either run `bazel query @org_chromium_chromium_amd64//...` to prompt Bazel to calculate the new `sha256` for each platform binary or determine the new `sha256` values manually.
Here is an example with `curl` & `shasum`: Here is an example with `curl` & `shasum`:
``` bash ``` bash
@ -63,7 +63,7 @@ The process of updating the Chrome or Firefox version is not straightforward, bu
## Firefox ## Firefox
In order to update Firefox, open the `dev-infra/browsers/firefox/firefox.bzl` file and update the repository URLs to the desired version. In order to update Firefox, open the `dev-infra/bazel/browsers/firefox/firefox.bzl` file and update the repository URLs to the desired version.
For example: For example:
```bzl ```bzl

View File

@ -15,12 +15,12 @@
"""Pinned browser versions. """Pinned browser versions.
This function is here to make browser repositories work with cross-platform RBE. This function is here to make browser repositories work with cross-platform RBE.
Unlike the rules_webtesting browser_repositories, this function defines Unlike the `rules_webtesting` `browser_repositories`, this function defines
separate repositories for each platform separate repositories for each platform.
""" """
load("//dev-infra/browsers/chromium:chromium.bzl", "define_chromium_repositories") load("//dev-infra/bazel/browsers/chromium:chromium.bzl", "define_chromium_repositories")
load("//dev-infra/browsers/firefox:firefox.bzl", "define_firefox_repositories") load("//dev-infra/bazel/browsers/firefox:firefox.bzl", "define_firefox_repositories")
def browser_repositories(): def browser_repositories():
"""Load pinned rules_webtesting browser versions.""" """Load pinned rules_webtesting browser versions."""

View File

@ -1,3 +1,5 @@
load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive")
# Copyright Google LLC # Copyright Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -16,8 +18,6 @@
# #
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive")
# Override of chromium web_test_archive so that the archive is selected based on platform # Override of chromium web_test_archive so that the archive is selected based on platform
web_test_archive( web_test_archive(
name = "chromium_archive", name = "chromium_archive",
@ -33,7 +33,7 @@ web_test_archive(
"@io_bazel_rules_webtesting//common/conditions:mac": {"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/chromium"}, "@io_bazel_rules_webtesting//common/conditions:mac": {"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/chromium"},
"@io_bazel_rules_webtesting//common/conditions:windows": {"CHROMIUM": "chrome-win/chrome.exe"}, "@io_bazel_rules_webtesting//common/conditions:windows": {"CHROMIUM": "chrome-win/chrome.exe"},
}), }),
visibility = ["//dev-infra/browsers:__subpackages__"], visibility = ["//dev-infra/bazel/browsers:__subpackages__"],
) )
# Override of chromedriver web_test_archive so that the archive is selected based on platform # Override of chromedriver web_test_archive so that the archive is selected based on platform
@ -57,7 +57,7 @@ web_test_archive(
"CHROMEDRIVER": "chromedriver_win32/chromedriver.exe", "CHROMEDRIVER": "chromedriver_win32/chromedriver.exe",
}, },
}), }),
visibility = ["//dev-infra/browsers:__subpackages__"], visibility = ["//dev-infra/bazel/browsers:__subpackages__"],
) )
browser( browser(

View File

@ -1,4 +1,4 @@
load("//dev-infra/browsers:platform_http_file.bzl", "platform_http_file") load("//dev-infra/bazel/browsers:platform_http_file.bzl", "platform_http_file")
""" """
Defines repositories for Chromium that can be used inside Karma unit tests Defines repositories for Chromium that can be used inside Karma unit tests
@ -7,7 +7,7 @@ load("//dev-infra/browsers:platform_http_file.bzl", "platform_http_file")
def define_chromium_repositories(): def define_chromium_repositories():
# To update to a newer version of Chromium see instructions in # To update to a newer version of Chromium see instructions in
# https://github.com/angular/angular/blob/master/dev-infra/browsers/README.md. # https://github.com/angular/angular/blob/master/dev-infra/bazel/browsers/README.md.
platform_http_file( platform_http_file(
name = "org_chromium_chromium_amd64", name = "org_chromium_chromium_amd64",

View File

@ -1,3 +1,5 @@
load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive")
# Copyright Google LLC # Copyright Google LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
@ -16,8 +18,6 @@
# #
package(default_visibility = ["//visibility:public"]) 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. # Override of firefox web_test_archive so that the archive is selected based on platform.
web_test_archive( web_test_archive(
name = "firefox_archive", name = "firefox_archive",
@ -31,7 +31,7 @@ web_test_archive(
"@io_bazel_rules_webtesting//common/conditions:linux": {"FIREFOX": "firefox/firefox"}, "@io_bazel_rules_webtesting//common/conditions:linux": {"FIREFOX": "firefox/firefox"},
"@io_bazel_rules_webtesting//common/conditions:mac": {"FIREFOX": "Firefox.app/Contents/MacOS/firefox"}, "@io_bazel_rules_webtesting//common/conditions:mac": {"FIREFOX": "Firefox.app/Contents/MacOS/firefox"},
}), }),
visibility = ["//dev-infra/browsers:__subpackages__"], visibility = ["//dev-infra/bazel/browsers:__subpackages__"],
) )
# Override of geckodriver web_test_archive so that the archive is selected based on platform. # Override of geckodriver web_test_archive so that the archive is selected based on platform.
@ -44,7 +44,7 @@ web_test_archive(
}), }),
extract = "build", extract = "build",
named_files = {"GECKODRIVER": "geckodriver"}, named_files = {"GECKODRIVER": "geckodriver"},
visibility = ["//dev-infra/browsers:__subpackages__"], visibility = ["//dev-infra/bazel/browsers:__subpackages__"],
) )
browser( browser(

View File

@ -1,4 +1,4 @@
load("//dev-infra/browsers:platform_http_file.bzl", "platform_http_file") load("//dev-infra/bazel/browsers:platform_http_file.bzl", "platform_http_file")
""" """
Defines repositories for Firefox that can be used inside Karma unit tests Defines repositories for Firefox that can be used inside Karma unit tests

View File

@ -5,7 +5,6 @@ filegroup(
name = "files", name = "files",
srcs = glob(["*"]) + [ srcs = glob(["*"]) + [
"//dev-infra/benchmark/brotli-cli:files", "//dev-infra/benchmark/brotli-cli:files",
"//dev-infra/browsers:files",
"//dev-infra/benchmark/component_benchmark:files", "//dev-infra/benchmark/component_benchmark:files",
"//dev-infra/benchmark/ng_rollup_bundle:files", "//dev-infra/benchmark/ng_rollup_bundle:files",
], ],

View File

@ -10,7 +10,7 @@ load("@npm//@bazel/protractor:index.bzl", "protractor_web_test_suite")
def benchmark_test(name, server, tags = [], **kwargs): def benchmark_test(name, server, tags = [], **kwargs):
protractor_web_test_suite( protractor_web_test_suite(
name = name, name = name,
browsers = ["//dev-infra/browsers/chromium:chromium"], browsers = ["//dev-infra/bazel/browsers/chromium:chromium"],
configuration = "//dev-infra/benchmark/component_benchmark:protractor-perf.conf.js", configuration = "//dev-infra/benchmark/component_benchmark:protractor-perf.conf.js",
on_prepare = "//dev-infra/benchmark/component_benchmark:start-server.js", on_prepare = "//dev-infra/benchmark/component_benchmark:start-server.js",
server = server, server = server,

View File

@ -70,7 +70,7 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps,
":" + name + "_env_rollup.umd", ":" + name + "_env_rollup.umd",
] + bootstrap + ] + bootstrap +
_karma_test_required_dist_files, _karma_test_required_dist_files,
browsers = ["//dev-infra/browsers/chromium:chromium"], browsers = ["//dev-infra/bazel/browsers/chromium:chromium"],
static_files = [ static_files = [
":assets/sample.json", ":assets/sample.json",
":assets/worker.js", ":assets/worker.js",
@ -94,7 +94,7 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps,
":" + name + "_env_rollup.umd", ":" + name + "_env_rollup.umd",
"//packages/zone.js/bundles:zone-testing-bundle.umd.min.js", "//packages/zone.js/bundles:zone-testing-bundle.umd.min.js",
] + _karma_test_required_dist_files, ] + _karma_test_required_dist_files,
browsers = ["//dev-infra/browsers/chromium:chromium"], browsers = ["//dev-infra/bazel/browsers/chromium:chromium"],
config_file = "//:karma-js.conf.js", config_file = "//:karma-js.conf.js",
configuration_env_vars = ["KARMA_WEB_TEST_MODE"], configuration_env_vars = ["KARMA_WEB_TEST_MODE"],
data = [ data = [

View File

@ -267,8 +267,8 @@ def karma_web_test_suite(name, **kwargs):
bootstrap = bootstrap, bootstrap = bootstrap,
deps = deps, deps = deps,
browsers = [ browsers = [
"//dev-infra/browsers/chromium:chromium", "//dev-infra/bazel/browsers/chromium:chromium",
"//dev-infra/browsers/firefox:firefox", "//dev-infra/bazel/browsers/firefox:firefox",
], ],
data = data, data = data,
tags = tags, tags = tags,
@ -306,7 +306,7 @@ def protractor_web_test_suite(**kwargs):
"""Default values for protractor_web_test_suite""" """Default values for protractor_web_test_suite"""
_protractor_web_test_suite( _protractor_web_test_suite(
browsers = ["//dev-infra/browsers/chromium:chromium"], browsers = ["//dev-infra/bazel/browsers/chromium:chromium"],
**kwargs **kwargs
) )