Skip to content

Commit fe7e7c7

Browse files
authored
[js + bazel]: Run Node browser tests on the RBE (#14194)
If you `cd` into `javascript/node/selenium-webdriver` a `pnpm`-based workflow should still work. This PR also removes a now unused ci-javascript.yml file: everything that this used to do is now handled by the RBE.
1 parent 164bf79 commit fe7e7c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+433
-306
lines changed

.bazelrc

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ build --nobuild_runfile_links
3939

4040
# More JS magic
4141
build --experimental_allow_unresolved_symlinks
42+
# Avoid a warning about directory tracking being unsound
43+
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1
4244

4345
# Required for faster TS builds
4446
build --@aspect_rules_ts//ts:skipLibCheck=always

.github/workflows/ci-javascript.yml

-35
This file was deleted.

.github/workflows/ci.yml

-11
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ jobs:
5959
contains(join(github.event.commits.*.message), '[java]') ||
6060
contains(github.event.pull_request.title, '[java]')
6161
62-
javascript:
63-
name: JavaScript
64-
needs: check
65-
uses: ./.github/workflows/ci-javascript.yml
66-
if: >
67-
github.event_name == 'schedule' ||
68-
github.event_name == 'workflow_dispatch' ||
69-
contains(needs.check.outputs.targets, '//javascript') ||
70-
contains(join(github.event.commits.*.message), '[js]') ||
71-
contains(github.event.pull_request.title, '[js]')
72-
7362
python:
7463
name: Python
7564
needs: check

.skipped-tests

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
-//javascript/atoms:test-chrome
2020
-//javascript/atoms:test-edge
2121
-//javascript/atoms:test-firefox-beta
22+
-//javascript/node/selenium-webdriver:test-bidi-network-test.js-chrome
23+
-//javascript/node/selenium-webdriver:test-builder-test.js-chrome
24+
-//javascript/node/selenium-webdriver:test-builder-test.js-firefox
25+
-//javascript/node/selenium-webdriver:test-chrome-devtools-test.js-chrome
26+
-//javascript/node/selenium-webdriver:test-chrome-options-test.js-chrome
27+
-//javascript/node/selenium-webdriver:test-chrome-service-test.js-chrome
28+
-//javascript/node/selenium-webdriver:test-firefox-options-test.js-firefox
29+
-//javascript/node/selenium-webdriver:test-lib-capabilities-test.js-chrome
2230
-//py:test-chrome-test/selenium/webdriver/chrome/chrome_launcher_tests.py
2331
-//py:test-chrome-test/selenium/webdriver/chrome/chrome_service_tests.py
2432
-//py:test-chrome-test/selenium/webdriver/chrome/proxy_tests.py

MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ linter.configure(
3939
linter.register(name = "rust-rustfmt")
4040

4141
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
42-
node.toolchain(node_version = "18.17.0")
42+
node.toolchain(node_version = "20.9.0")
4343

4444
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm", dev_dependency = True)
4545
use_repo(pnpm, "pnpm")

common/repositories.bzl

+12-12
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ js_library(
202202
url = "https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.62/linux64/chrome-linux64.zip",
203203
sha256 = "6f42045c9134bdd3cfcea03fb54876ad061da998cabd624c92a25ac6811cd737",
204204
build_file_content = """
205-
load("@aspect_rules_js//js:defs.bzl", "js_library")
205+
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
206206
package(default_visibility = ["//visibility:public"])
207207
208208
filegroup(
@@ -212,9 +212,9 @@ filegroup(
212212
213213
exports_files(["chrome-linux64/chrome"])
214214
215-
js_library(
215+
copy_to_bin(
216216
name = "chrome-js",
217-
data = [":files"],
217+
srcs = [":files"],
218218
)
219219
""",
220220
)
@@ -229,14 +229,14 @@ js_library(
229229
"mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
230230
],
231231
build_file_content = """
232-
load("@aspect_rules_js//js:defs.bzl", "js_library")
232+
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
233233
package(default_visibility = ["//visibility:public"])
234234
235235
exports_files(["Chrome.app"])
236236
237-
js_library(
237+
copy_to_bin(
238238
name = "chrome-js",
239-
data = glob(["Chrome.app/**/*"]),
239+
srcs = glob(["Chrome.app/**/*"]),
240240
)
241241
""",
242242
)
@@ -247,14 +247,14 @@ js_library(
247247
sha256 = "a304e692480c726bae846bf6dee36316305d0b8f4826dfafeab8d6bbbc6e7214",
248248
strip_prefix = "chromedriver-linux64",
249249
build_file_content = """
250-
load("@aspect_rules_js//js:defs.bzl", "js_library")
250+
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
251251
package(default_visibility = ["//visibility:public"])
252252
253253
exports_files(["chromedriver"])
254254
255-
js_library(
255+
copy_to_bin(
256256
name = "chromedriver-js",
257-
data = ["chromedriver"],
257+
srcs = ["chromedriver"],
258258
)
259259
""",
260260
)
@@ -265,14 +265,14 @@ js_library(
265265
sha256 = "05665a6b5fb71141b5d519998e36f01b650f661942a56dd7f6b929896ae38333",
266266
strip_prefix = "chromedriver-mac-x64",
267267
build_file_content = """
268-
load("@aspect_rules_js//js:defs.bzl", "js_library")
268+
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
269269
package(default_visibility = ["//visibility:public"])
270270
271271
exports_files(["chromedriver"])
272272
273-
js_library(
273+
copy_to_bin(
274274
name = "chromedriver-js",
275-
data = ["chromedriver"],
275+
srcs = ["chromedriver"],
276276
)
277277
""",
278278
)

java/test/org/openqa/selenium/bidi/browsingcontext/LocateNodesTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void canLocateNodesInAGivenSandbox() {
242242

243243
String sharedId = (String) ((RemoteValue) sharedIdMap.get("sharedId")).getValue().get();
244244
assertThat(sharedId).isEqualTo(nodeId);
245-
}
245+
}
246246

247247
@AfterEach
248248
public void quitDriver() {

javascript/node/selenium-webdriver/BUILD.bazel

+11-16
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ load("@npm//javascript/node/selenium-webdriver:prettier/package_json.bzl", prett
77
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
88
load("//common:defs.bzl", "copy_file")
99
load("//javascript:defs.bzl", "mocha_test")
10+
load("//javascript/private:browsers.bzl", "BROWSERS")
1011

1112
npm_link_all_packages(name = "node_modules")
1213

@@ -39,6 +40,7 @@ js_library(
3940
"bidi/*.js",
4041
]),
4142
deps = [
43+
":node_modules/@bazel/runfiles",
4244
":node_modules/jszip",
4345
":node_modules/tmp",
4446
":node_modules/ws",
@@ -117,6 +119,9 @@ js_library(
117119
"test/**/*_test.js",
118120
],
119121
),
122+
deps = [
123+
":node_modules/@bazel/runfiles",
124+
],
120125
)
121126

122127
mocha_test(
@@ -152,41 +157,31 @@ mocha_test(
152157
],
153158
chdir = package_name(),
154159
data = [
155-
"test-data",
156160
":large-test-srcs",
157-
":node_modules/@bazel/runfiles",
158161
":node_modules/express",
159-
":node_modules/jszip",
162+
":node_modules/mocha",
163+
":node_modules/mocha-junit-reporter",
160164
":node_modules/multer",
161165
":node_modules/serve-index",
162166
":node_modules/sinon",
163-
":node_modules/tmp",
164-
":node_modules/ws",
167+
":test-data",
165168
"//:node_modules/selenium-webdriver",
166169
"//common/extensions:js-lib",
167170
"//common/src/web:js-lib",
168-
"//javascript/node/selenium-webdriver/lib/atoms:find-elements",
169-
"//javascript/node/selenium-webdriver/lib/atoms:get_attribute",
170-
"//javascript/node/selenium-webdriver/lib/atoms:is_displayed",
171-
"//javascript/node/selenium-webdriver/lib/atoms:mutation-listener",
172-
],
171+
] + BROWSERS[browser]["data"],
173172
env = {
174173
"SELENIUM_BROWSER": browser,
175-
},
174+
} | BROWSERS[browser]["env"],
176175
tags = [
177176
browser,
178177
"browser-test",
179178
"no-sandbox",
180179
"requires-network",
181-
"skip-remote",
182180
],
183181
),
184182
]
185183
for test in LARGE_TESTS
186-
for browser in [
187-
"chrome",
188-
"firefox",
189-
]
184+
for browser in BROWSERS.keys()
190185
]
191186

192187
# npm_package does not pick up filegroup sources.

javascript/node/selenium-webdriver/jsdoc_conf.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"destination": "../../../build/docs/api/javascript/",
1212
"recurse": true,
1313
"verbose": true,
14-
"template": "../../../node_modules/clean-jsdoc-theme",
14+
"template": "./node_modules/clean-jsdoc-theme",
1515
"theme_opts": {
1616
"default_theme": "dark",
1717
"displayModuleHeader": true,

javascript/node/selenium-webdriver/lib/pinnedScript.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const crypto = require('node:crypto')
2020
class PinnedScript {
2121
constructor(script) {
2222
this.scriptSource_ = script
23+
// eslint-disable-next-line
2324
this.scriptHandle_ = crypto.randomUUID().replace(/-/gi, '')
2425
}
2526

javascript/node/selenium-webdriver/lib/test/httpserver.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const assert = require('node:assert')
2121
const http = require('node:http')
2222
const url = require('node:url')
2323

24-
const net = require('../../net')
25-
const portprober = require('../../net/portprober')
26-
const promise = require('../..').promise
24+
const net = require('selenium-webdriver/net')
25+
const portprober = require('selenium-webdriver/net/portprober')
26+
const promise = require('selenium-webdriver').promise
2727

2828
/**
2929
* Encapsulates a simple HTTP server for testing. The {@code onrequest}

javascript/node/selenium-webdriver/lib/test/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
//const build = require('./build')
2121
const fileserver = require('./fileserver')
22-
const logging = require('../../lib/logging')
23-
const testing = require('../../testing')
22+
const logging = require('selenium-webdriver/lib/logging')
23+
const testing = require('selenium-webdriver/testing')
2424

2525
//const NO_BUILD = /^1|true$/i.test(process.env['SELENIUM_NO_BUILD'])
2626

javascript/node/selenium-webdriver/lib/test/resources.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
const fs = require('node:fs')
2121
const path = require('node:path')
22+
const runfiles = require('@bazel/runfiles')
2223
const { projectRoot } = require('./build')
2324

2425
// PUBLIC API
@@ -31,8 +32,15 @@ const { projectRoot } = require('./build')
3132
*/
3233
exports.locate = function (filePath) {
3334
const fullPath = path.normalize(path.join(projectRoot(), filePath))
34-
if (!fs.existsSync(fullPath)) {
35-
throw Error('File does not exist: ' + filePath)
35+
if (fs.existsSync(fullPath)) {
36+
return fullPath
3637
}
37-
return fullPath
38+
39+
try {
40+
return runfiles.resolve(filePath)
41+
} catch {
42+
// Fall through
43+
}
44+
45+
throw Error('File does not exist: ' + filePath)
3846
}

javascript/node/selenium-webdriver/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"node": ">= 14.21.0"
2424
},
2525
"dependencies": {
26+
"@bazel/runfiles": "^5.8.1",
2627
"jszip": "^3.10.1",
2728
"tmp": "^0.2.3",
2829
"ws": "^8.17.1"
2930
},
3031
"devDependencies": {
31-
"@bazel/runfiles": "^5.8.1",
3232
"@eslint/js": "^9.5.0",
3333
"clean-jsdoc-theme": "^4.3.0",
3434
"eslint": "^9.5.0",
@@ -39,19 +39,20 @@
3939
"eslint-plugin-prettier": "^5.1.3",
4040
"express": "^4.19.2",
4141
"globals": "^15.6.0",
42+
"has-flag": "^4.0.0",
4243
"jsdoc": "^4.0.3",
4344
"mocha": "^10.5.1",
4445
"mocha-junit-reporter": "^2.2.1",
4546
"multer": "1.4.5-lts.1",
4647
"prettier": "^3.3.2",
4748
"serve-index": "^1.9.1",
48-
"sinon": "^17.0.1"
49+
"sinon": "^17.0.1",
50+
"supports-color": "^9.4.0"
4951
},
5052
"scripts": {
5153
"lint": "eslint .",
5254
"lint:fix": "eslint . --fix",
53-
"test": "npm run lint && mocha -t 600000 --recursive test",
54-
"test-jasmine": "bazel test //javascript/node/selenium-webdriver:tests",
55+
"test": "bazel test //javascript/node/selenium-webdriver/...",
5556
"generate-docs": "jsdoc --configure jsdoc_conf.json --verbose"
5657
},
5758
"mocha": {

javascript/node/selenium-webdriver/test/actions_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
const assert = require('node:assert')
2121
const fileServer = require('../lib/test/fileserver')
2222
const { ignore, Pages, suite } = require('../lib/test')
23-
const { Key, Origin } = require('../lib/input')
24-
const { Browser, By, until } = require('..')
23+
const { Key, Origin } = require('selenium-webdriver/lib/input')
24+
const { Browser, By, until } = require('selenium-webdriver')
2525

2626
suite(function (env) {
2727
describe('WebDriver.actions()', function () {

javascript/node/selenium-webdriver/test/bidi/add_intercept_parameters_test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
'use strict'
1919

2020
const assert = require('node:assert')
21-
const { Browser } = require('../../')
21+
const { Browser } = require('selenium-webdriver')
2222
const { suite } = require('../../lib/test')
23-
const Network = require('../../bidi/network')
24-
const { AddInterceptParameters } = require('../../bidi/addInterceptParameters')
25-
const { InterceptPhase } = require('../../bidi/interceptPhase')
26-
const { UrlPattern } = require('../../bidi/urlPattern')
23+
const Network = require('selenium-webdriver/bidi/network')
24+
const { AddInterceptParameters } = require('selenium-webdriver/bidi/addInterceptParameters')
25+
const { InterceptPhase } = require('selenium-webdriver/bidi/interceptPhase')
26+
const { UrlPattern } = require('selenium-webdriver/bidi/urlPattern')
2727

2828
suite(
2929
function (env) {

javascript/node/selenium-webdriver/test/bidi/bidi_session_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'use strict'
1919

2020
const assert = require('node:assert')
21-
const { Browser } = require('../../')
21+
const { Browser } = require('selenium-webdriver')
2222
const { suite } = require('../../lib/test')
2323

2424
suite(

0 commit comments

Comments
 (0)