Skip to content

Commit b097c9b

Browse files
devversionprofanis
authored andcommitted
feat(dev-infra): add bazel firefox browser with RBE compatibility (angular#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 angular#38029
1 parent b5167b0 commit b097c9b

File tree

13 files changed

+372
-173
lines changed

13 files changed

+372
-173
lines changed

dev-infra/benchmark/component_benchmark/benchmark_test.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
1010
def benchmark_test(name, server, tags = [], **kwargs):
1111
protractor_web_test_suite(
1212
name = name,
13-
browsers = ["//dev-infra/browsers:chromium"],
13+
browsers = ["//dev-infra/browsers/chromium:chromium"],
1414
configuration = "//dev-infra/benchmark/component_benchmark:protractor-perf.conf.js",
1515
on_prepare = "//dev-infra/benchmark/component_benchmark:start-server.js",
1616
server = server,

dev-infra/browsers/BUILD.bazel

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,10 @@
1-
# Copyright Google LLC
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-
#
171
package(default_visibility = ["//visibility:public"])
182

19-
load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive")
20-
21-
# Override of chromium web_test_archive so that the archive is selected based on platform
22-
web_test_archive(
23-
name = "chromium_archive",
24-
testonly = True,
25-
archive = select({
26-
"@io_bazel_rules_webtesting//common/conditions:linux": "@org_chromium_chromium_amd64//file",
27-
"@io_bazel_rules_webtesting//common/conditions:mac": "@org_chromium_chromium_macos//file",
28-
"@io_bazel_rules_webtesting//common/conditions:windows": "@org_chromium_chromium_windows//file",
29-
}),
30-
extract = "build",
31-
named_files = select({
32-
"@io_bazel_rules_webtesting//common/conditions:linux": {"CHROMIUM": "chrome-linux/chrome"},
33-
"@io_bazel_rules_webtesting//common/conditions:mac": {"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/chromium"},
34-
"@io_bazel_rules_webtesting//common/conditions:windows": {"CHROMIUM": "chrome-win/chrome.exe"},
35-
}),
36-
visibility = ["//dev-infra/browsers:__subpackages__"],
37-
)
38-
39-
# Override of chromedriver web_test_archive so that the archive is selected based on platform
40-
web_test_archive(
41-
name = "chromedriver_archive",
42-
testonly = True,
43-
archive = select({
44-
"@io_bazel_rules_webtesting//common/conditions:linux": "@org_chromium_chromedriver_amd64//file",
45-
"@io_bazel_rules_webtesting//common/conditions:mac": "@org_chromium_chromedriver_macos//file",
46-
"@io_bazel_rules_webtesting//common/conditions:windows": "@org_chromium_chromedriver_windows//file",
47-
}),
48-
extract = "build",
49-
named_files = select({
50-
"@io_bazel_rules_webtesting//common/conditions:linux": {
51-
"CHROMEDRIVER": "chromedriver_linux64/chromedriver",
52-
},
53-
"@io_bazel_rules_webtesting//common/conditions:mac": {
54-
"CHROMEDRIVER": "chromedriver_mac64/chromedriver",
55-
},
56-
"@io_bazel_rules_webtesting//common/conditions:windows": {
57-
"CHROMEDRIVER": "chromedriver_win32/chromedriver.exe",
58-
},
59-
}),
60-
visibility = ["//dev-infra/browsers:__subpackages__"],
61-
)
62-
63-
browser(
64-
name = "chromium",
65-
metadata = "chromium.json",
66-
visibility = ["//visibility:public"],
67-
deps = [
68-
":chromedriver_archive",
69-
":chromium_archive",
70-
"@io_bazel_rules_webtesting//go/wsl",
71-
],
72-
)
73-
743
# Make source files available for distribution via pkg_npm
754
filegroup(
765
name = "files",
77-
srcs = glob(["*"]),
6+
srcs = glob(["*"]) + [
7+
"//dev-infra/browsers/chromium:files",
8+
"//dev-infra/browsers/firefox:files",
9+
],
7810
)

dev-infra/browsers/README.md

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,87 @@
11
# Browser configuration and versioning for testing of Angular
22

3-
Within the Angular monorepo, we use Chrome to perform most of the local testing, and rely on Sauce Labs and BrowserStack to do cross-browser testing on our CI.
3+
Within the Angular organization, we use Chrome and Firefox to perform most of the local testing,
4+
and rely on Sauce Labs and BrowserStack to do cross-browser testing on our CI.
45

5-
The version of Chrome used in tests within this monorepo is configured and controlled via `rules_webtesting` and `puppeteer`. We manually keep the configuration of these two tools in sync to create a consistent testing environment across unit, e2e, and integration tests.
6+
The version of Chrome used in tests within this monorepo is configured and controlled via
7+
Bazel and `puppeteer`. We manually keep the configuration of these two tools in sync to
8+
create a consistent testing environment across unit, e2e, and integration tests.
69

7-
## rules_webtesting
10+
## Bazel
811

9-
Bazel `karma_web_test_suite` and `protractor_web_test_suite` targets will use Chromium provisioned by rules_webtesting. The version of chrome used is specified in the `dev-infra/browsers/browser_repositories.bzl` file. The process of updating the Chrome version in that file consists of several steps:
12+
Bazel `karma_web_test_suite` and `protractor_web_test_suite` targets will use Chromium
13+
or Firefox provisioned by `//dev-infra/browsers`. The version of Chrome and Firefox are
14+
specified in the `chromium.bzl` and `firefox.bzl` files in `/dev-infra/browsers`.
1015

11-
1) Visit https://chromium.woolyss.com/ and note the version (commit position) of the latest stable version.
16+
The process of updating the Chrome or Firefox version is not straightforward, but below
17+
are dedicated sections for each browser.
1218

13-
For example, "Google Chrome 83.0.4103.97 (756066) • Wednesday, 3 Jun 2020". Alternately, you can look in https://omahaproxy.appspot.com/.
19+
## Updating Chromium
1420

15-
1) Find the closest commit position number available for each platform in chromium-browser-snapshots:
16-
https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html
21+
1) Visit https://chromium.woolyss.com/ and note the version (commit position) of the latest
22+
stable version.
23+
24+
For example, "Google Chrome 83.0.4103.97 (756066) • Wednesday, 3 Jun 2020". Alternatively, you
25+
can look in https://omahaproxy.appspot.com/.
1726

18-
For example,
27+
1) Find the closest commit position number available for each platform in chromium-browser-snapshots:
28+
https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html
1929

30+
For example:
2031
* https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/756066/
2132
* https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/756053/
2233
* https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win/756065/
2334

24-
You can download the Chromium for your local platform and double check that the --version matches up with
25-
what you expect.
26-
27-
For example,
35+
You can download Chromium for your local platform and double check that the `--version` matches
36+
up with what you expect.
2837

29-
``` bash
30-
$ ~/Downloads/chrome-mac/Chromium.app/Contents/MacOS/Chromium --version
31-
Chromium 83.0.4103.0
32-
```
33-
34-
1) Update the chrome & chrome driver build numbers in `dev-infra/browsers/browser_repositories.bzl` and run 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.
38+
For example:
39+
``` bash
40+
$ ~/Downloads/chrome-mac/Chromium.app/Contents/MacOS/Chromium --version
41+
Chromium 83.0.4103.0
42+
```
3543

36-
For example, with curl & shasum
44+
2) Update the chrome & chrome driver build numbers in `dev-infra/browsers/chromium/chromium.bzl`
45+
and run either run `bazel query @org_chromium_chromium_amd64//...` to prompt Bazel to calculate
46+
the new `sha256` for each platform binary or determine the new `sha256` values manually.
3747

38-
``` bash
39-
curl https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/756066/chrome-linux.zip | shasum -a 256
40-
```
48+
Here is an example with `curl` & `shasum`:
49+
``` bash
50+
curl https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/756066/chrome-linux.zip | shasum -a 256
51+
```
4152

42-
## puppeteer
53+
## Puppeteer
4354

44-
Visit https://github.com/puppeteer/puppeteer/blob/master/docs/api.md to determine which version of puppeteer corresponds to the version of Chrome desired. Then update `scripts/puppeteer-chrome-versions.js` and all of the puppeteer versions throughout the repo,
55+
Visit https://github.com/puppeteer/puppeteer/blob/master/docs/api.md to determine which version
56+
of puppeteer corresponds to the version of Chrome desired. Then update
57+
`scripts/puppeteer-chrome-versions.js` and all of the puppeteer versions throughout the repo,
4558

4659
* `package.json`
4760
* `aio/package.json`
4861
* `aio/tools/examples/shared/package.json`
4962

5063
and their corresponding `yarn.lock` files.
64+
65+
## Firefox
66+
67+
In order to update Firefox, open the `dev-infra/browsers/firefox/firefox.bzl` file and update
68+
the repository URLs to the desired version. e.g.
69+
70+
```bzl
71+
platform_http_file(
72+
name = "org_mozilla_firefox_amd64",
73+
licenses = ["reciprocal"], # MPL 2.0
74+
sha256 = "bde6e020556a21561e4b8d7aaecf8db7077951f179b98ca5d0305435bc6802c9",
75+
# Firefox v78.0
76+
urls = ["https://ftp.mozilla.org/pub/firefox/releases/78.0/linux-x86_64/en-US/firefox-78.0.tar.bz2"],
77+
)
78+
```
79+
80+
Go to the `urls` property and update the URL by replacing all `78.0` occurrences with the
81+
version you intend to use. Once done, do the same change for other platforms (such as `macos`).
82+
83+
Finally, update the `sha256`checksum of the browser archives. You can do this by downloading the
84+
artifacts from the URLs you just updated, and then running on those files: `sha256 <path>`.
85+
86+
87+

dev-infra/browsers/browser_repositories.bzl

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -19,78 +19,11 @@ Unlike the rules_webtesting browser_repositories, this function defines
1919
separate repositories for each platform
2020
"""
2121

22-
load("@io_bazel_rules_webtesting//web/internal:platform_http_file.bzl", _platform_http_file = "platform_http_file")
23-
24-
def platform_http_file(name, licenses, sha256, urls):
25-
"""Platform spepcific browser repository.
26-
27-
This works around a dificiency in io_bazel_rules_webtesting platform_http_file in that
28-
it selects the platform when the repository rule is executed. This limits browsers
29-
tests to run on the local user platform only. For cross-platform RBE we want a repository
30-
to be defined per platform so the correct one can be selected.
31-
"""
32-
33-
_platform_http_file(
34-
name = name,
35-
amd64_sha256 = sha256,
36-
amd64_urls = urls,
37-
licenses = licenses,
38-
macos_sha256 = sha256,
39-
macos_urls = urls,
40-
windows_sha256 = sha256,
41-
windows_urls = urls,
42-
)
22+
load("//dev-infra/browsers/chromium:chromium.bzl", "define_chromium_repositories")
23+
load("//dev-infra/browsers/firefox:firefox.bzl", "define_firefox_repositories")
4324

4425
def browser_repositories():
4526
"""Load pinned rules_webtesting browser versions."""
4627

47-
# To update to a newer version of Chromium see instructions in
48-
# https://github.com/angular/angular/blob/master/dev-infra/browsers/README.md.
49-
50-
platform_http_file(
51-
name = "org_chromium_chromium_amd64",
52-
licenses = ["notice"], # BSD 3-clause (maybe more?)
53-
sha256 = "2cfd74ee58c79d8b7aada05c899a930967e2fd8bb0186582cde02c7340863f64",
54-
# 83.0.4103
55-
urls = ["https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/756066/chrome-linux.zip"],
56-
)
57-
58-
platform_http_file(
59-
name = "org_chromium_chromium_macos",
60-
licenses = ["notice"], # BSD 3-clause (maybe more?)
61-
sha256 = "b841ec5ad03b08422d97593fc719f1c5b038703388ad65e6cd8cc8272d58958c",
62-
# 83.0.4103
63-
urls = ["https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/756053/chrome-mac.zip"],
64-
)
65-
66-
platform_http_file(
67-
name = "org_chromium_chromium_windows",
68-
licenses = ["notice"], # BSD 3-clause (maybe more?)
69-
sha256 = "4683d7ac88dfec4b98d1da3012ecc8e42cc8c1a560a7b95589ad4cc96bf90fcb",
70-
# 83.0.4103
71-
urls = ["https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/756065/chrome-win.zip"],
72-
)
73-
74-
platform_http_file(
75-
name = "org_chromium_chromedriver_amd64",
76-
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
77-
sha256 = "95dded16000b82e31445361da7d251ed707e027a4b61e9a3ec5fbd1cc2f62bb1",
78-
# 83.0.4103
79-
urls = ["https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/756066/chromedriver_linux64.zip"],
80-
)
81-
82-
platform_http_file(
83-
name = "org_chromium_chromedriver_macos",
84-
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
85-
sha256 = "17260e9b2222b0c905a1861285210192baef830f4281778903e7cebb8db683cc",
86-
# 83.0.4103
87-
urls = ["https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/756053/chromedriver_mac64.zip"],
88-
)
89-
90-
platform_http_file(
91-
name = "org_chromium_chromedriver_windows",
92-
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
93-
sha256 = "de1423b2d69f96e451e902d686e8d471610d786c345a8de59dd1a5a436e45fc2",
94-
# 83.0.4103
95-
urls = ["https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/756065/chromedriver_win32.zip"],
96-
)
28+
define_chromium_repositories()
29+
define_firefox_repositories()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright Google LLC
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+
package(default_visibility = ["//visibility:public"])
18+
19+
load("@io_bazel_rules_webtesting//web:web.bzl", "browser", "web_test_archive")
20+
21+
# Override of chromium web_test_archive so that the archive is selected based on platform
22+
web_test_archive(
23+
name = "chromium_archive",
24+
testonly = True,
25+
archive = select({
26+
"@io_bazel_rules_webtesting//common/conditions:linux": "@org_chromium_chromium_amd64//file",
27+
"@io_bazel_rules_webtesting//common/conditions:mac": "@org_chromium_chromium_macos//file",
28+
"@io_bazel_rules_webtesting//common/conditions:windows": "@org_chromium_chromium_windows//file",
29+
}),
30+
extract = "build",
31+
named_files = select({
32+
"@io_bazel_rules_webtesting//common/conditions:linux": {"CHROMIUM": "chrome-linux/chrome"},
33+
"@io_bazel_rules_webtesting//common/conditions:mac": {"CHROMIUM": "chrome-mac/Chromium.app/Contents/MacOS/chromium"},
34+
"@io_bazel_rules_webtesting//common/conditions:windows": {"CHROMIUM": "chrome-win/chrome.exe"},
35+
}),
36+
visibility = ["//dev-infra/browsers:__subpackages__"],
37+
)
38+
39+
# Override of chromedriver web_test_archive so that the archive is selected based on platform
40+
web_test_archive(
41+
name = "chromedriver_archive",
42+
testonly = True,
43+
archive = select({
44+
"@io_bazel_rules_webtesting//common/conditions:linux": "@org_chromium_chromedriver_amd64//file",
45+
"@io_bazel_rules_webtesting//common/conditions:mac": "@org_chromium_chromedriver_macos//file",
46+
"@io_bazel_rules_webtesting//common/conditions:windows": "@org_chromium_chromedriver_windows//file",
47+
}),
48+
extract = "build",
49+
named_files = select({
50+
"@io_bazel_rules_webtesting//common/conditions:linux": {
51+
"CHROMEDRIVER": "chromedriver_linux64/chromedriver",
52+
},
53+
"@io_bazel_rules_webtesting//common/conditions:mac": {
54+
"CHROMEDRIVER": "chromedriver_mac64/chromedriver",
55+
},
56+
"@io_bazel_rules_webtesting//common/conditions:windows": {
57+
"CHROMEDRIVER": "chromedriver_win32/chromedriver.exe",
58+
},
59+
}),
60+
visibility = ["//dev-infra/browsers:__subpackages__"],
61+
)
62+
63+
browser(
64+
name = "chromium",
65+
metadata = "chromium.json",
66+
visibility = ["//visibility:public"],
67+
deps = [
68+
":chromedriver_archive",
69+
":chromium_archive",
70+
"@io_bazel_rules_webtesting//go/wsl",
71+
],
72+
)
73+
74+
# Make source files available for distribution via pkg_npm
75+
filegroup(
76+
name = "files",
77+
srcs = glob(["*"]),
78+
)

0 commit comments

Comments
 (0)