diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index e74df2a8bc865..5ddb39a05e4f4 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -2,45 +2,35 @@ name: CI - Ruby on: workflow_call: + inputs: + targets: + required: false + type: string + default: '//rb/...' workflow_dispatch: permissions: contents: read jobs: - build: - name: Build - uses: ./.github/workflows/bazel.yml - with: - name: Build - run: bazel build //rb:selenium-devtools //rb:selenium-webdriver - lint: name: Lint - needs: build uses: ./.github/workflows/bazel.yml with: name: Lint run: ./go rb:lint + # jruby is exercised on RBE; minimum MRI is exercised by os-tests. This matrix + # covers the alternate interpreter (truffleruby) and the most recent MRI release. unit-tests: name: Unit Tests - needs: build uses: ./.github/workflows/bazel.yml strategy: fail-fast: false matrix: include: - - ruby-version: 3.3.11 - os: ubuntu - - ruby-version: 3.3.11 - os: windows - - ruby-version: 3.3.11 - os: macos - ruby-version: 4.0.4 os: ubuntu - - ruby-version: jruby-10.1.0.0 - os: ubuntu - ruby-version: truffleruby-34.0.1 os: ubuntu with: @@ -51,38 +41,38 @@ jobs: run: > bazel test --keep_going - --build_tests_only --test_size_filters small //rb/spec/... - integration-tests-local: - name: Local Tests - needs: build + os-tests: + name: ${{ matrix.os }}-tests uses: ./.github/workflows/bazel.yml strategy: fail-fast: false matrix: - browser: - - chrome - - edge - - firefox - os: - - windows - - macos - exclude: - - browser: edge - os: macos + include: + - os: ubuntu + browser: yes + tag-filters: unit,os-sensitive + - os: windows + browser: yes + tag-filters: edge,edge-bidi,unit,os-sensitive + - os: macos + browser: safari + tag-filters: safari,unit,os-sensitive with: - name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }}) + name: ${{ matrix.os }}-tests browser: ${{ matrix.browser }} os: ${{ matrix.os }} rerun-with-debug: true run: > - bazel test + ./scripts/github-actions/bazel-test-if-targets.sh --keep_going - --build_tests_only --flaky_test_attempts 2 --local_test_jobs 1 - --test_size_filters large - --test_tag_filters ${{ matrix.browser }} - //rb/spec/... + --pin_browsers=false + --skip_incompatible_explicit_targets + --test_env=SE_FORCE_BROWSER_DOWNLOAD=true + --test_env=SE_SKIP_DRIVER_IN_PATH=true + --test_tag_filters=${{ matrix.tag-filters }} + ${{ inputs.targets || '//rb/...' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 294b3596fa62d..928af9ba3407a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,7 +65,7 @@ jobs: java: ${{ steps.read.outputs.java }} grid: ${{ steps.read.outputs.grid }} py: ${{ steps.read.outputs.py }} - rb: ${{ steps.read.outputs.rb }} + rb_targets: ${{ steps.read.outputs.rb_targets }} dotnet: ${{ steps.read.outputs.dotnet }} rust: ${{ steps.read.outputs.rust }} steps: @@ -86,12 +86,20 @@ jobs: echo "$tag=true" >> "$GITHUB_OUTPUT" fi } + process_binding() { + local pattern=$1 tag=$2 + local lang_targets + lang_targets=$(echo "$targets" | tr ' ' '\n' | awk -v p="^${pattern}[:/]" '$0 ~ p' | tr '\n' ' ' | sed 's/ *$//') + if [ -n "$lang_targets" ]; then + echo "${tag}_targets=$lang_targets" >> "$GITHUB_OUTPUT" + fi + } check_binding "//java" "java" check_binding "openqa/selenium/grid" "grid" check_binding "//py" "py" - check_binding "//rb" "rb" check_binding "//dotnet" "dotnet" check_binding "//rust" "rust" + process_binding "//rb" "rb" dotnet: name: .NET needs: read-targets @@ -120,7 +128,9 @@ jobs: name: Ruby needs: read-targets uses: ./.github/workflows/ci-ruby.yml - if: needs.read-targets.outputs.rb != '' + if: needs.read-targets.outputs.rb_targets != '' + with: + targets: ${{ needs.read-targets.outputs.rb_targets }} rust: name: Rust diff --git a/.skipped-tests b/.skipped-tests index 4814fe97ca671..166cc85ed9143 100644 --- a/.skipped-tests +++ b/.skipped-tests @@ -23,4 +23,3 @@ -//java/test/org/openqa/selenium/bidi/browsingcontext:BrowsingContextTest-firefox-beta-remote -//java/test/org/openqa/selenium/bidi/emulation:SetNetworkConditionsTest-firefox-beta -//java/test/org/openqa/selenium/bidi/emulation:SetNetworkConditionsTest-firefox-beta-remote --//rb/spec/integration/selenium/webdriver/bidi:browsing_context-firefox-beta-bidi diff --git a/rb/BUILD.bazel b/rb/BUILD.bazel index 71405d5db74be..abd2dba9eda84 100644 --- a/rb/BUILD.bazel +++ b/rb/BUILD.bazel @@ -4,7 +4,6 @@ load( "rb_binary", "rb_gem_build", "rb_gem_push", - "rb_test", ) load("//common:defs.bzl", "copy_file") @@ -212,18 +211,6 @@ _LINT_DEPS = [ "@bundle", ] -rb_test( - name = "lint", - args = ["--autocorrect"] + _LINT_ARGS, - data = _LINT_DATA, - main = "@bundle//bin:rubocop", - tags = [ - "no-sandbox", - "skip-rbe", - ], - deps = _LINT_DEPS, -) - rb_binary( name = "rubocop", testonly = True, diff --git a/rb/spec/integration/selenium/webdriver/network_spec.rb b/rb/spec/integration/selenium/webdriver/network_spec.rb index ae1b2bfa347b6..15e195f92a419 100644 --- a/rb/spec/integration/selenium/webdriver/network_spec.rb +++ b/rb/spec/integration/selenium/webdriver/network_spec.rb @@ -21,8 +21,7 @@ module Selenium module WebDriver - describe Network, exclude: {version: 'beta'}, - exclusive: {bidi: true, reason: 'only executed when bidi is enabled'}, + describe Network, exclusive: {bidi: true, reason: 'only executed when bidi is enabled'}, only: {browser: %i[chrome edge firefox]} do let(:username) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.first } let(:password) { SpecSupport::RackServer::TestApp::BASIC_AUTH_CREDENTIALS.last } diff --git a/rb/spec/integration/selenium/webdriver/window_spec.rb b/rb/spec/integration/selenium/webdriver/window_spec.rb index 593e7d43b89ff..b70b666f8ab00 100644 --- a/rb/spec/integration/selenium/webdriver/window_spec.rb +++ b/rb/spec/integration/selenium/webdriver/window_spec.rb @@ -127,7 +127,7 @@ module WebDriver it 'can minimize the window', except: [{browser: %i[chrome edge], headless: true}, {browser: %i[safari safari_preview]}], - flaky: {browser: :chrome, platform: %i[macosx linux], ci: :github} do + flaky: {browser: %i[chrome edge], platform: %i[macosx linux], ci: :github} do window.minimize expect { wait.until { driver.execute_script('return document.hidden;') } diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index 4982c605209dd..4a9c8e1657f95 100644 --- a/rb/spec/tests.bzl +++ b/rb/spec/tests.bzl @@ -246,7 +246,7 @@ def rb_integration_test( data = BROWSERS[browser]["data"] + data + ["//common/src/web"], env = BROWSERS[browser]["env"] | {"WEBDRIVER_BIDI": "true"}, main = "@bundle//bin:rspec", - tags = COMMON_TAGS + BROWSERS[browser]["tags"] + universal_tags + ["{}-bidi".format(browser)], + tags = COMMON_TAGS + BROWSERS[browser]["tags"] + universal_tags + ["bidi", "{}-bidi".format(browser)], deps = {d: True for d in ( ["//rb/spec/integration/selenium/webdriver:spec_helper", "//rb/lib/selenium/webdriver:bidi"] + BROWSERS[browser]["deps"] + diff --git a/rust/BUILD.bazel b/rust/BUILD.bazel index 4125c84fe00dc..dda6225a468dc 100644 --- a/rust/BUILD.bazel +++ b/rust/BUILD.bazel @@ -16,10 +16,7 @@ rustfmt_config( # Start with the variants for each platform alias( name = "selenium-manager-windows", - actual = select({ - "//common:windows": ":selenium-manager", - "//conditions:default": "@download_sm_windows//file", - }), + actual = "@download_sm_windows//file", tags = [ "manual", ], diff --git a/scripts/github-actions/bazel-test-if-targets.sh b/scripts/github-actions/bazel-test-if-targets.sh new file mode 100755 index 0000000000000..5fdbbc983baa6 --- /dev/null +++ b/scripts/github-actions/bazel-test-if-targets.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Wrap `bazel test` so that exit code 4 (no test targets matched the +# configured filters) is reported as a notice and treated as success. +# Keeps `inputs.run` a single command word so rerun-failures.sh can +# strip ` //...` targets and re-append failed ones without mangling +# shell control characters. + +set -uo pipefail + +code=0 +bazel test "$@" || code=$? + +case "$code" in + 0) exit 0 ;; + 4) + echo "::notice::No test targets matched the configured filters" + exit 0 + ;; + *) exit "$code" ;; +esac