From a16f82b851c1cf1f5ba8739e574dfbc89a662666 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 24 May 2021 16:17:27 +0200 Subject: [PATCH] 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 --- WORKSPACE | 2 +- dev-infra/bazel/BUILD.bazel | 1 + dev-infra/{ => bazel}/browsers/BUILD.bazel | 4 ++-- dev-infra/{ => bazel}/browsers/README.md | 8 ++++---- dev-infra/{ => bazel}/browsers/browser_repositories.bzl | 8 ++++---- dev-infra/{ => bazel}/browsers/chromium/BUILD.bazel | 8 ++++---- dev-infra/{ => bazel}/browsers/chromium/chromium.bzl | 4 ++-- dev-infra/{ => bazel}/browsers/chromium/chromium.json | 0 dev-infra/{ => bazel}/browsers/firefox/BUILD.bazel | 8 ++++---- dev-infra/{ => bazel}/browsers/firefox/firefox.bzl | 2 +- dev-infra/{ => bazel}/browsers/firefox/firefox.json | 0 dev-infra/{ => bazel}/browsers/platform_http_file.bzl | 0 dev-infra/benchmark/BUILD.bazel | 1 - .../benchmark/component_benchmark/benchmark_test.bzl | 2 +- packages/zone.js/test/karma_test.bzl | 4 ++-- tools/defaults.bzl | 6 +++--- 16 files changed, 29 insertions(+), 29 deletions(-) rename dev-infra/{ => bazel}/browsers/BUILD.bazel (63%) rename dev-infra/{ => bazel}/browsers/README.md (90%) rename dev-infra/{ => bazel}/browsers/browser_repositories.bzl (74%) rename dev-infra/{ => bazel}/browsers/chromium/BUILD.bazel (95%) rename dev-infra/{ => bazel}/browsers/chromium/chromium.bzl (96%) rename dev-infra/{ => bazel}/browsers/chromium/chromium.json (100%) rename dev-infra/{ => bazel}/browsers/firefox/BUILD.bazel (95%) rename dev-infra/{ => bazel}/browsers/firefox/firefox.bzl (95%) rename dev-infra/{ => bazel}/browsers/firefox/firefox.json (100%) rename dev-infra/{ => bazel}/browsers/platform_http_file.bzl (100%) diff --git a/WORKSPACE b/WORKSPACE index 19b89d7044..be059f4ed0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -49,7 +49,7 @@ load("@io_bazel_rules_webtesting//web:repositories.bzl", "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() diff --git a/dev-infra/bazel/BUILD.bazel b/dev-infra/bazel/BUILD.bazel index 6bb4f3a008..6fdb989c2b 100644 --- a/dev-infra/bazel/BUILD.bazel +++ b/dev-infra/bazel/BUILD.bazel @@ -5,6 +5,7 @@ filegroup( srcs = [ "BUILD.bazel", "expand_template.bzl", + "//dev-infra/bazel/browsers:files", "//dev-infra/bazel/remote-execution:files", ], ) diff --git a/dev-infra/browsers/BUILD.bazel b/dev-infra/bazel/browsers/BUILD.bazel similarity index 63% rename from dev-infra/browsers/BUILD.bazel rename to dev-infra/bazel/browsers/BUILD.bazel index 76f0ce6ecc..dabe4af6da 100644 --- a/dev-infra/browsers/BUILD.bazel +++ b/dev-infra/bazel/browsers/BUILD.bazel @@ -4,7 +4,7 @@ package(default_visibility = ["//visibility:public"]) filegroup( name = "files", srcs = glob(["*"]) + [ - "//dev-infra/browsers/chromium:files", - "//dev-infra/browsers/firefox:files", + "//dev-infra/bazel/browsers/chromium:files", + "//dev-infra/bazel/browsers/firefox:files", ], ) diff --git a/dev-infra/browsers/README.md b/dev-infra/bazel/browsers/README.md similarity index 90% rename from dev-infra/browsers/README.md rename to dev-infra/bazel/browsers/README.md index 4c866fcbb6..618146cbb1 100644 --- a/dev-infra/browsers/README.md +++ b/dev-infra/bazel/browsers/README.md @@ -7,8 +7,8 @@ We manually keep the configuration of these two tools in sync to create a consis ## Bazel -Bazel `karma_web_test_suite` and `protractor_web_test_suite` targets will use Chromium or Firefox provisioned by `//dev-infra/browsers`. -The version of Chrome and Firefox are specified in the `chromium.bzl` and `firefox.bzl` files in `/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/bazel/browsers`. 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 ``` -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`: ``` bash @@ -63,7 +63,7 @@ The process of updating the Chrome or Firefox version is not straightforward, bu ## 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: ```bzl diff --git a/dev-infra/browsers/browser_repositories.bzl b/dev-infra/bazel/browsers/browser_repositories.bzl similarity index 74% rename from dev-infra/browsers/browser_repositories.bzl rename to dev-infra/bazel/browsers/browser_repositories.bzl index 97df460e75..06223d0cf1 100644 --- a/dev-infra/browsers/browser_repositories.bzl +++ b/dev-infra/bazel/browsers/browser_repositories.bzl @@ -15,12 +15,12 @@ """Pinned browser versions. This function is here to make browser repositories work with cross-platform RBE. -Unlike the rules_webtesting browser_repositories, this function defines -separate repositories for each platform +Unlike the `rules_webtesting` `browser_repositories`, this function defines +separate repositories for each platform. """ -load("//dev-infra/browsers/chromium:chromium.bzl", "define_chromium_repositories") -load("//dev-infra/browsers/firefox:firefox.bzl", "define_firefox_repositories") +load("//dev-infra/bazel/browsers/chromium:chromium.bzl", "define_chromium_repositories") +load("//dev-infra/bazel/browsers/firefox:firefox.bzl", "define_firefox_repositories") def browser_repositories(): """Load pinned rules_webtesting browser versions.""" diff --git a/dev-infra/browsers/chromium/BUILD.bazel b/dev-infra/bazel/browsers/chromium/BUILD.bazel similarity index 95% rename from dev-infra/browsers/chromium/BUILD.bazel rename to dev-infra/bazel/browsers/chromium/BUILD.bazel index 7ad08fb96b..058a64b694 100644 --- a/dev-infra/browsers/chromium/BUILD.bazel +++ b/dev-infra/bazel/browsers/chromium/BUILD.bazel @@ -1,3 +1,5 @@ +load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive") + # Copyright Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,8 +18,6 @@ # 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 web_test_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: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 @@ -57,7 +57,7 @@ web_test_archive( "CHROMEDRIVER": "chromedriver_win32/chromedriver.exe", }, }), - visibility = ["//dev-infra/browsers:__subpackages__"], + visibility = ["//dev-infra/bazel/browsers:__subpackages__"], ) browser( diff --git a/dev-infra/browsers/chromium/chromium.bzl b/dev-infra/bazel/browsers/chromium/chromium.bzl similarity index 96% rename from dev-infra/browsers/chromium/chromium.bzl rename to dev-infra/bazel/browsers/chromium/chromium.bzl index 0f3747a438..e4bd8a2f2a 100644 --- a/dev-infra/browsers/chromium/chromium.bzl +++ b/dev-infra/bazel/browsers/chromium/chromium.bzl @@ -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 @@ -7,7 +7,7 @@ load("//dev-infra/browsers:platform_http_file.bzl", "platform_http_file") def define_chromium_repositories(): # 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( name = "org_chromium_chromium_amd64", diff --git a/dev-infra/browsers/chromium/chromium.json b/dev-infra/bazel/browsers/chromium/chromium.json similarity index 100% rename from dev-infra/browsers/chromium/chromium.json rename to dev-infra/bazel/browsers/chromium/chromium.json diff --git a/dev-infra/browsers/firefox/BUILD.bazel b/dev-infra/bazel/browsers/firefox/BUILD.bazel similarity index 95% rename from dev-infra/browsers/firefox/BUILD.bazel rename to dev-infra/bazel/browsers/firefox/BUILD.bazel index 9349495e3c..b1129a4ef2 100644 --- a/dev-infra/browsers/firefox/BUILD.bazel +++ b/dev-infra/bazel/browsers/firefox/BUILD.bazel @@ -1,3 +1,5 @@ +load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive") + # Copyright Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,8 +18,6 @@ # 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", @@ -31,7 +31,7 @@ web_test_archive( "@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__"], + visibility = ["//dev-infra/bazel/browsers:__subpackages__"], ) # Override of geckodriver web_test_archive so that the archive is selected based on platform. @@ -44,7 +44,7 @@ web_test_archive( }), extract = "build", named_files = {"GECKODRIVER": "geckodriver"}, - visibility = ["//dev-infra/browsers:__subpackages__"], + visibility = ["//dev-infra/bazel/browsers:__subpackages__"], ) browser( diff --git a/dev-infra/browsers/firefox/firefox.bzl b/dev-infra/bazel/browsers/firefox/firefox.bzl similarity index 95% rename from dev-infra/browsers/firefox/firefox.bzl rename to dev-infra/bazel/browsers/firefox/firefox.bzl index 7b112767be..a350561481 100644 --- a/dev-infra/browsers/firefox/firefox.bzl +++ b/dev-infra/bazel/browsers/firefox/firefox.bzl @@ -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 diff --git a/dev-infra/browsers/firefox/firefox.json b/dev-infra/bazel/browsers/firefox/firefox.json similarity index 100% rename from dev-infra/browsers/firefox/firefox.json rename to dev-infra/bazel/browsers/firefox/firefox.json diff --git a/dev-infra/browsers/platform_http_file.bzl b/dev-infra/bazel/browsers/platform_http_file.bzl similarity index 100% rename from dev-infra/browsers/platform_http_file.bzl rename to dev-infra/bazel/browsers/platform_http_file.bzl diff --git a/dev-infra/benchmark/BUILD.bazel b/dev-infra/benchmark/BUILD.bazel index 8a70bef317..d56acdbef7 100644 --- a/dev-infra/benchmark/BUILD.bazel +++ b/dev-infra/benchmark/BUILD.bazel @@ -5,7 +5,6 @@ filegroup( name = "files", srcs = glob(["*"]) + [ "//dev-infra/benchmark/brotli-cli:files", - "//dev-infra/browsers:files", "//dev-infra/benchmark/component_benchmark:files", "//dev-infra/benchmark/ng_rollup_bundle:files", ], diff --git a/dev-infra/benchmark/component_benchmark/benchmark_test.bzl b/dev-infra/benchmark/component_benchmark/benchmark_test.bzl index 450bf051ca..e0fca3dfce 100644 --- a/dev-infra/benchmark/component_benchmark/benchmark_test.bzl +++ b/dev-infra/benchmark/component_benchmark/benchmark_test.bzl @@ -10,7 +10,7 @@ load("@npm//@bazel/protractor:index.bzl", "protractor_web_test_suite") def benchmark_test(name, server, tags = [], **kwargs): protractor_web_test_suite( 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", on_prepare = "//dev-infra/benchmark/component_benchmark:start-server.js", server = server, diff --git a/packages/zone.js/test/karma_test.bzl b/packages/zone.js/test/karma_test.bzl index 611979f597..c47a7ea79c 100644 --- a/packages/zone.js/test/karma_test.bzl +++ b/packages/zone.js/test/karma_test.bzl @@ -70,7 +70,7 @@ def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, ":" + name + "_env_rollup.umd", ] + bootstrap + _karma_test_required_dist_files, - browsers = ["//dev-infra/browsers/chromium:chromium"], + browsers = ["//dev-infra/bazel/browsers/chromium:chromium"], static_files = [ ":assets/sample.json", ":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", "//packages/zone.js/bundles:zone-testing-bundle.umd.min.js", ] + _karma_test_required_dist_files, - browsers = ["//dev-infra/browsers/chromium:chromium"], + browsers = ["//dev-infra/bazel/browsers/chromium:chromium"], config_file = "//:karma-js.conf.js", configuration_env_vars = ["KARMA_WEB_TEST_MODE"], data = [ diff --git a/tools/defaults.bzl b/tools/defaults.bzl index e3c7920e97..728bdda096 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -267,8 +267,8 @@ def karma_web_test_suite(name, **kwargs): bootstrap = bootstrap, deps = deps, browsers = [ - "//dev-infra/browsers/chromium:chromium", - "//dev-infra/browsers/firefox:firefox", + "//dev-infra/bazel/browsers/chromium:chromium", + "//dev-infra/bazel/browsers/firefox:firefox", ], data = data, tags = tags, @@ -306,7 +306,7 @@ def protractor_web_test_suite(**kwargs): """Default values for protractor_web_test_suite""" _protractor_web_test_suite( - browsers = ["//dev-infra/browsers/chromium:chromium"], + browsers = ["//dev-infra/bazel/browsers/chromium:chromium"], **kwargs )