diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index b8e9ea372fb34..40033757084fd 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -46,6 +46,11 @@ on: required: false type: string default: '' + nodejs-version: + description: Custom NodeJS version to use + required: false + type: string + default: '' python-version: description: Custom Python version to use required: false @@ -89,18 +94,21 @@ jobs: if: contains(github.ref, 'renovate/') run: git pull origin ${{ github.ref }} - name: Free space - if: inputs.os != 'windows' + if: ${{ !startsWith(inputs.os, 'windows') }} run: ./scripts/github-actions/free-disk-space.sh - name: Remove driver directories Windows - if: inputs.os == 'windows' + if: startsWith(inputs.os, 'windows') run: | rm "$env:ChromeWebDriver" -r -v rm "$env:EdgeWebDriver" -r -v rm "$env:GeckoWebDriver" -r -v - name: Remove driver directories Non-Windows - if: inputs.os != 'windows' + if: ${{ !startsWith(inputs.os, 'windows') }} run: | sudo rm -rf "$CHROMEWEBDRIVER" "$EDGEWEBDRIVER" "$GECKOWEBDRIVER" + - name: Set NodeJS version + if: inputs.nodejs-version != '' + run: echo '${{ inputs.nodejs-version }}' > javascript/selenium-webdriver/.nvmrc - name: Set Python version if: inputs.python-version != '' run: echo '${{ inputs.python-version }}' > py/.python-version @@ -172,10 +180,10 @@ jobs: fluxbox -display :99 & echo "DISPLAY=:99" >> "$GITHUB_ENV" - name: Set resolution - if: inputs.os == 'windows' && inputs.browser != '' + if: startsWith(inputs.os, 'windows') && inputs.browser != '' run: Set-DisplayResolution -Width 1920 -Height 1080 -Force - name: Disable 8dot3 short names - if: inputs.os == 'windows' + if: startsWith(inputs.os, 'windows') run: fsutil 8dot3name set 0 - name: Setup Safari if: inputs.browser == 'safari' diff --git a/.github/workflows/ci-javascript.yml b/.github/workflows/ci-javascript.yml new file mode 100644 index 0000000000000..7061d5e2eb07f --- /dev/null +++ b/.github/workflows/ci-javascript.yml @@ -0,0 +1,87 @@ +name: CI - JavaScript + +on: + workflow_call: + inputs: + targets: + required: false + type: string + default: '' + run-full-suite: + required: false + type: boolean + default: true + workflow_dispatch: + +permissions: + contents: read + +jobs: + unit-tests: + name: Unit Tests + if: ${{ github.event_name == 'workflow_dispatch' || inputs.run-full-suite }} + uses: ./.github/workflows/bazel.yml + strategy: + fail-fast: false + matrix: + nodejs-version: ['20.19.5', '24.11.1'] + os: [macos, windows] + with: + name: Unit Tests (node ${{ matrix.node-version }}, ${{ matrix.os }}) + os: ${{ matrix.os }} + node-version: ${{ matrix.node-version }} + run: > + bazel test + --keep_going + --build_tests_only + --test_size_filters=small + //javascript/selenium-webdriver/... + + filter-targets: + name: Filter Targets + runs-on: ubuntu-latest + outputs: + targets: ${{ steps.filter.outputs.targets }} + steps: + - name: Filter JavaScript targets + id: filter + shell: bash + run: | + targets="${{ inputs.targets }}" + filtered=() + + for t in $targets; do + [[ "$t" == //javascript/selenium-webdriver* ]] && filtered+=("$t") + done + + if [ ${#filtered[@]} -eq 0 ]; then + echo "targets=//javascript/selenium-webdriver/..." >> "$GITHUB_OUTPUT" + else + echo "targets=${filtered[*]}" >> "$GITHUB_OUTPUT" + fi + + browser-tests: + name: Browser Tests + needs: filter-targets + uses: ./.github/workflows/bazel.yml + strategy: + fail-fast: false + matrix: + browser: [chrome, firefox, chrome-bidi, firefox-bidi] + os: [windows-2022] + with: + name: Browser Tests (${{ matrix.browser }}, ${{ matrix.os }}) + os: ${{ matrix.os }} + browser: ${{ matrix.browser }} + run: > + bazel test + --keep_going + --build_tests_only + --flaky_test_attempts 3 + --local_test_jobs 1 + --test_size_filters=large + --test_tag_filters=${{ matrix.browser }} + --pin_browsers=false + --test_env=SE_FORCE_BROWSER_DOWNLOAD=true + --test_env=SE_SKIP_DRIVER_IN_PATH=true + ${{ needs.filter-targets.outputs.targets }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab0f535c85c66..8f3e40faf4c90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -109,3 +109,23 @@ jobs: contains(needs.check.outputs.targets, '//rust') || contains(join(github.event.commits.*.message), '[rust]') || contains(github.event.pull_request.title, '[rust]') + + javascript: + name: JavaScript + needs: check + uses: ./.github/workflows/ci-javascript.yml + with: + targets: ${{ needs.check.outputs.targets }} + run-full-suite: >- + ${{ + github.event_name == 'schedule' || + github.event_name == 'workflow_dispatch' || + github.event_name == 'workflow_call' || + contains(github.event.pull_request.title, '[js]') + }} + if: > + github.event_name == 'schedule' || + github.event_name == 'workflow_dispatch' || + github.event_name == 'workflow_call' || + contains(needs.check.outputs.targets, '//javascript/selenium-webdriver/') || + contains(github.event.pull_request.title, '[js]') diff --git a/MODULE.bazel b/MODULE.bazel index 72cff21ba9565..f31c083c18234 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -20,7 +20,7 @@ bazel_dep(name = "rules_dotnet", version = "0.20.5") bazel_dep(name = "rules_java", version = "8.7.1") bazel_dep(name = "rules_jvm_external", version = "6.8") bazel_dep(name = "rules_multitool", version = "1.3.0") -bazel_dep(name = "rules_nodejs", version = "6.3.2") +bazel_dep(name = "rules_nodejs", version = "6.6.2") bazel_dep(name = "rules_pkg", version = "1.0.1") bazel_dep(name = "rules_python", version = "1.7.0") bazel_dep(name = "rules_proto", version = "7.0.2") @@ -50,7 +50,12 @@ linter.configure( linter.register(name = "rust-rustfmt") node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") -node.toolchain(node_version = "20.9.0") +node.toolchain( + node_version_from_nvmrc = "//javascript/selenium-webdriver:.nvmrc", +) +use_repo(node, "nodejs_toolchains") + +register_toolchains("@nodejs_toolchains//:all") pnpm = use_extension( "@aspect_rules_js//npm:extensions.bzl", diff --git a/javascript/private/browsers.bzl b/javascript/private/browsers.bzl index 15cfac500264b..de387e27b58fd 100644 --- a/javascript/private/browsers.bzl +++ b/javascript/private/browsers.bzl @@ -10,10 +10,10 @@ BROWSERS = { "@linux_chrome//:chrome-js", "@linux_chromedriver//:chromedriver-js", ], - # "@selenium//common:use_pinned_macos_chrome": [ - # "@mac_chrome//:chrome-js", - # "@mac_chromedriver//:chromedriver-js", - # ], + "@selenium//common:use_pinned_macos_chrome": [ + "@mac_chrome//:chrome-js", + "@mac_chromedriver//:chromedriver-js", + ], "//conditions:default": [], }), "env": select({ @@ -21,10 +21,10 @@ BROWSERS = { "SE_CHROMEDRIVER": "linux_chromedriver/chromedriver", "SE_CHROME": "linux_chrome/chrome-linux64/chrome", }, - # "@selenium//common:use_pinned_macos_chrome": { - # "SE_CHROMEDRIVER": "mac_chromedriver/chromedriver", - # "SE_CHROME": "mac_chrome/Chrome.app)/Contents/MacOS/Chrome", - # }, + "@selenium//common:use_pinned_macos_chrome": { + "SE_CHROMEDRIVER": "mac_chromedriver/chromedriver", + "SE_CHROME": "mac_chrome/Chrome.app/Contents/MacOS/Chrome", + }, "//conditions:default": {}, }), }, @@ -34,10 +34,10 @@ BROWSERS = { "@linux_geckodriver//:geckodriver-js", "@linux_firefox//:firefox-js", ], - # "@selenium//common:use_pinned_macos_firefox": [ - # "@mac_geckodriver//:geckodriver-js", - # "@mac_firefox//:firefox-js", - # ], + "@selenium//common:use_pinned_macos_firefox": [ + "@mac_geckodriver//:geckodriver-js", + "@mac_firefox//:firefox-js", + ], "//conditions:default": [], }), "env": select({ @@ -45,10 +45,10 @@ BROWSERS = { "SE_GECKODRIVER": "linux_geckodriver/geckodriver", "SE_FIREFOX": "linux_firefox/firefox/firefox", }, - # "@selenium//common:use_pinned_macos_firefox": { - # "SE_GECKODRIVER": "mac_geckodriver/geckodriver", - # "SE_FIREFOX": "mac_firefox/Firefox.app/Contents/MacOS/firefox", - # }, + "@selenium//common:use_pinned_macos_firefox": { + "SE_GECKODRIVER": "mac_geckodriver/geckodriver", + "SE_FIREFOX": "mac_firefox/Firefox.app/Contents/MacOS/firefox", + }, "//conditions:default": {}, }), }, diff --git a/javascript/selenium-webdriver/.nvmrc b/javascript/selenium-webdriver/.nvmrc new file mode 100644 index 0000000000000..f6773770565ad --- /dev/null +++ b/javascript/selenium-webdriver/.nvmrc @@ -0,0 +1 @@ +24.11.1 \ No newline at end of file diff --git a/javascript/selenium-webdriver/BUILD.bazel b/javascript/selenium-webdriver/BUILD.bazel index 59561045fd141..03858a9fc4c12 100644 --- a/javascript/selenium-webdriver/BUILD.bazel +++ b/javascript/selenium-webdriver/BUILD.bazel @@ -104,6 +104,30 @@ LARGE_TESTS = glob( exclude = SMALL_TESTS, ) +CHROME_SPECIFIC = glob(["test/chrome/**/*_test.js"]) + +EDGE_SPECIFIC = glob(["test/edge/**/*_test.js"]) + +FIREFOX_SPECIFIC = glob(["test/firefox/**/*_test.js"]) + +IE_SPECIFIC = glob(["test/ie/**/*_test.js"]) + +SAFARI_SPECIFIC = glob(["test/safari_test.js"]) + +COMMON_TESTS = glob( + LARGE_TESTS, + exclude = CHROME_SPECIFIC + + EDGE_SPECIFIC + + FIREFOX_SPECIFIC + + IE_SPECIFIC + + SAFARI_SPECIFIC, +) + +BROWSER_TESTS = { + "chrome": COMMON_TESTS + CHROME_SPECIFIC, + "firefox": COMMON_TESTS + FIREFOX_SPECIFIC, +} + js_library( name = "small-test-srcs", srcs = SMALL_TESTS, @@ -178,16 +202,17 @@ mocha_test( env = { "SELENIUM_BROWSER": browser, } | BROWSERS[browser]["env"], - tags = [ - browser, + tags = ( + ["%s-bidi" % browser] if test.startswith("test/bidi/") else [browser] + ) + [ "browser-test", "no-sandbox", "requires-network", ], ), ] - for test in LARGE_TESTS for browser in BROWSERS.keys() + for test in BROWSER_TESTS[browser] ] # npm_package does not pick up filegroup sources.