diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index ee7df60deb54f..d7b92430b0549 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -83,6 +83,7 @@ jobs: TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SE_CACHE_PATH: ${{ runner.temp }}/selenium steps: - name: Checkout source tree uses: actions/checkout@v4 diff --git a/.github/workflows/ci-dotnet.yml b/.github/workflows/ci-dotnet.yml index c98d969d72bf2..bc66e1e7254bd 100644 --- a/.github/workflows/ci-dotnet.yml +++ b/.github/workflows/ci-dotnet.yml @@ -2,6 +2,15 @@ name: CI - .NET on: workflow_call: + inputs: + targets: + required: false + type: string + default: '' + run-full-suite: + required: false + type: boolean + default: true workflow_dispatch: permissions: @@ -10,18 +19,64 @@ permissions: jobs: build: name: Build + if: ${{ inputs.run-full-suite }} uses: ./.github/workflows/bazel.yml with: name: Build os: windows run: bazel build //dotnet:all - integration-tests: + filter-targets: + name: Filter Targets + runs-on: ubuntu-latest + outputs: + targets: ${{ steps.filter.outputs.targets }} + steps: + - name: Filter .NET targets + id: filter + shell: bash + run: | + targets="${{ inputs.targets }}" + filtered=() + + for t in $targets; do + [[ "$t" == //dotnet/* ]] && filtered+=("$t") + done + + if [ ${#filtered[@]} -eq 0 ]; then + echo "targets=//dotnet/..." >> "$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] + protocol: [classic, bidi] + os: [windows] + include: + - browser: safari + os: macos + protocol: classic with: - name: Browser Tests - java-version: 17 - os: windows - run: | - bazel test //dotnet/test/common:ElementFindingTest-firefox //dotnet/test/common:ElementFindingTest-chrome + name: Browser Tests - ${{ matrix.browser }} ${{ matrix.protocol }}, ${{ matrix.os }} + os: ${{ matrix.os }} + browser: ${{ matrix.browser }} + rerun-with-debug: true + run: > + bazel test + --keep_going + --build_tests_only + --flaky_test_attempts 3 + --local_test_jobs 1 + --test_tag_filters="${{ matrix.browser }},${{ matrix.protocol == 'bidi' && 'bidi' || '-bidi' }}" + --test_size_filters=large + --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 11c63ce93ed71..48550dd11b7cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,12 +52,20 @@ jobs: name: .NET needs: check uses: ./.github/workflows/ci-dotnet.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, '[dotnet]') + }} if: > github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || contains(needs.check.outputs.targets, '//dotnet') || - contains(join(github.event.commits.*.message), '[dotnet]') || contains(github.event.pull_request.title, '[dotnet]') java: diff --git a/dotnet/private/dotnet_nunit_test_suite.bzl b/dotnet/private/dotnet_nunit_test_suite.bzl index a4e80d5486a90..5f870508b1a7c 100644 --- a/dotnet/private/dotnet_nunit_test_suite.bzl +++ b/dotnet/private/dotnet_nunit_test_suite.bzl @@ -101,12 +101,23 @@ _HEADLESS_ARGS = select({ "//conditions:default": [], }) +_BIDI_BROWSERS = ["chrome", "edge", "firefox"] + def _is_test(src, test_suffixes): for suffix in test_suffixes: if src.endswith(suffix): return True return False +def _browser_variant_name(test_name, browser): + return "%s-%s" % (test_name, browser) + +def _browser_variant_tags(browser, is_bidi): + tags = [browser] + COMMON_TAGS + _BROWSERS[browser]["tags"] + if is_bidi: + tags.append("bidi") + return tags + _NUNIT_ARGS = [ "--workers=1", # Bazel tests share a single driver instance; prevent NUnit parallelism ] @@ -139,6 +150,8 @@ def dotnet_nunit_test_suite( suffix = src.rfind(".") test_name = src[:suffix] + is_bidi = "BiDi/" in src + if not browsers or not len(browsers): csharp_test( name = test_name, @@ -146,14 +159,16 @@ def dotnet_nunit_test_suite( deps = deps + extra_deps, target_frameworks = target_frameworks, data = data, - tags = tags, + tags = tags + (["bidi"] if is_bidi else []), size = size, **kwargs ) tests.append(test_name) else: for browser in browsers: - browser_test_name = "%s-%s" % (test_name, browser) + if is_bidi and browser not in _BIDI_BROWSERS: + continue + browser_test_name = _browser_variant_name(test_name, browser) if browser == default_browser: native.test_suite( @@ -168,7 +183,7 @@ def dotnet_nunit_test_suite( target_frameworks = target_frameworks, args = _NUNIT_ARGS + _BROWSERS[browser]["args"] + _HEADLESS_ARGS, data = data + _BROWSERS[browser]["data"], - tags = tags + [browser] + COMMON_TAGS + _BROWSERS[browser]["tags"], + tags = tags + _browser_variant_tags(browser, is_bidi), size = size, **kwargs ) diff --git a/dotnet/test/common/AssemblyFixture.cs b/dotnet/test/common/AssemblyFixture.cs index d8605f5f4203e..842b7d166640b 100644 --- a/dotnet/test/common/AssemblyFixture.cs +++ b/dotnet/test/common/AssemblyFixture.cs @@ -34,8 +34,6 @@ public AssemblyFixture() [OneTimeSetUp] public async Task RunBeforeAnyTestAsync() { - Internal.Logging.Log.SetLevel(Internal.Logging.LogEventLevel.Trace); - await EnvironmentManager.Instance.WebServer.StartAsync(); if (EnvironmentManager.Instance.Browser == Browser.Remote) { diff --git a/dotnet/test/common/BUILD.bazel b/dotnet/test/common/BUILD.bazel index 2ec48afa81136..80a0896f81efd 100644 --- a/dotnet/test/common/BUILD.bazel +++ b/dotnet/test/common/BUILD.bazel @@ -65,7 +65,7 @@ csharp_library( dotnet_nunit_test_suite( name = "AllTests", - size = "small", + size = "large", srcs = glob([ "**/*Test.cs", "**/*Tests.cs", @@ -77,7 +77,7 @@ dotnet_nunit_test_suite( # The first browser in this list is assumed to be the one that should # be used by default. "firefox", - # "safari", # Skipping safari for now + "safari", "ie", "edge", "chrome",