From eb7cf50e3b5933b46c8837643d19eb960a2311d9 Mon Sep 17 00:00:00 2001 From: Titus Fortner Date: Fri, 5 Jun 2026 14:04:26 -0500 Subject: [PATCH] [py] run affected python tests per-browser on PR, full suite on schedule --- .github/workflows/ci-python.yml | 38 +++++++++++++++++------- .github/workflows/ci.yml | 8 +++-- scripts/github-actions/rerun-failures.sh | 3 +- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 1940e479e52f9..99e4521671096 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -2,6 +2,10 @@ name: CI - Python on: workflow_call: + inputs: + targets: + required: true + type: string workflow_dispatch: permissions: @@ -10,6 +14,7 @@ permissions: jobs: build: name: Build + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' uses: ./.github/workflows/bazel.yml with: name: Build @@ -42,7 +47,7 @@ jobs: unit-tests: name: Unit Tests - needs: build + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' uses: ./.github/workflows/bazel.yml strategy: fail-fast: false @@ -57,18 +62,20 @@ jobs: remote-tests: name: Remote Tests - needs: build uses: ./.github/workflows/bazel.yml with: name: Integration Tests Remote needs-display: true rerun-with-debug: true - run: | - bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-remote + run: > + ./scripts/github-actions/bazel-test-if-targets.sh + --keep_going + --flaky_test_attempts 3 + --local_test_jobs 1 + $(bazel query "tests(//py:test-remote) intersect set(${{ inputs.targets || '//py/...' }})" --output=label 2>/dev/null) browser-tests: name: Browser Tests - needs: build uses: ./.github/workflows/bazel.yml strategy: fail-fast: false @@ -83,12 +90,16 @@ jobs: needs-display: true os: ${{ matrix.os }} rerun-with-debug: true - run: | - bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }} + run: > + ./scripts/github-actions/bazel-test-if-targets.sh + --keep_going + --flaky_test_attempts 3 + --local_test_jobs 1 + --skip_incompatible_explicit_targets + $(bazel query "tests(//py:test-${{ matrix.browser }}) intersect set(${{ inputs.targets || '//py/...' }})" --output=label 2>/dev/null) selenium-manager-tests: name: Selenium Manager Tests - needs: build uses: ./.github/workflows/bazel.yml strategy: fail-fast: false @@ -99,5 +110,12 @@ jobs: needs-display: true os: ${{ matrix.os }} rerun-with-debug: true - run: | - bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=false --build_tests_only --test_tag_filters=se-manager //py/... + run: > + ./scripts/github-actions/bazel-test-if-targets.sh + --local_test_jobs 1 + --flaky_test_attempts 3 + --pin_browsers=false + --build_tests_only + --skip_incompatible_explicit_targets + --test_tag_filters=se-manager + ${{ inputs.targets || '//py/...' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 304461decd699..f70e66f5b6953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: outputs: java: ${{ steps.read.outputs.java }} grid: ${{ steps.read.outputs.grid }} - py: ${{ steps.read.outputs.py }} + py_targets: ${{ steps.read.outputs.py_targets }} rb_targets: ${{ steps.read.outputs.rb_targets }} dotnet: ${{ steps.read.outputs.dotnet }} rust: ${{ steps.read.outputs.rust }} @@ -96,10 +96,10 @@ jobs: } check_binding "//java" "java" check_binding "openqa/selenium/grid" "grid" - check_binding "//py" "py" check_binding "//dotnet" "dotnet" check_binding "//rust" "rust" process_binding "//rb" "rb" + process_binding "//py" "py" dotnet: name: .NET needs: read-targets @@ -122,7 +122,9 @@ jobs: name: Python needs: read-targets uses: ./.github/workflows/ci-python.yml - if: needs.read-targets.outputs.py != '' + if: needs.read-targets.outputs.py_targets != '' + with: + targets: ${{ needs.read-targets.outputs.py_targets }} ruby: name: Ruby diff --git a/scripts/github-actions/rerun-failures.sh b/scripts/github-actions/rerun-failures.sh index 3b4388254003e..28e18078a1dd6 100755 --- a/scripts/github-actions/rerun-failures.sh +++ b/scripts/github-actions/rerun-failures.sh @@ -32,7 +32,8 @@ fi if [[ "$RUN_CMD" == *"/ci-build.sh"* ]]; then base_cmd="bazel test --config=rbe-ci --build_tests_only --keep_going" else - base_cmd=$(echo "$RUN_CMD" | sed 's| //[^ ]*||g') + # Strip the targets (literal `//...` or a trailing `$(...)` query) to get the base command. + base_cmd=$(echo "$RUN_CMD" | sed -E 's| \$\(.*$||; s| //[^ ]*||g') fi targets=$(tr '\n' ' ' < build/failures/_run1.txt) echo "Rerunning tests: $base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets"