Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
67 changes: 61 additions & 6 deletions .github/workflows/ci-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 18 additions & 3 deletions dotnet/private/dotnet_nunit_test_suite.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@nvborisenko nvborisenko Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, can we temporary remove this arg? Classic tests cannot be executed in parallel, but BiDi tests are designed to be parallelizable. AFAIK NUnit doesn't utilize parallelization if not requested explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's 4 by default. Let me see if we can set it so it only applies to RBE.

]
Expand Down Expand Up @@ -139,21 +150,25 @@ 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,
srcs = lib_srcs + [src] + ["@rules_dotnet//dotnet/private/rules/common/nunit:shim.cs"],
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(
Expand All @@ -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
)
Expand Down
2 changes: 0 additions & 2 deletions dotnet/test/common/AssemblyFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions dotnet/test/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ csharp_library(

dotnet_nunit_test_suite(
name = "AllTests",
size = "small",
size = "large",
srcs = glob([
"**/*Test.cs",
"**/*Tests.cs",
Expand All @@ -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",
Expand Down