Skip to content

Commit 79bfb73

Browse files
committed
[py] run affected python tests per-browser on PR, full suite on schedule
1 parent d09fd3b commit 79bfb73

3 files changed

Lines changed: 26 additions & 11 deletions

File tree

.github/workflows/ci-python.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: CI - Python
22

33
on:
44
workflow_call:
5+
inputs:
6+
targets:
7+
required: true
8+
type: string
59
workflow_dispatch:
610

711
permissions:
@@ -10,6 +14,7 @@ permissions:
1014
jobs:
1115
build:
1216
name: Build
17+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
1318
uses: ./.github/workflows/bazel.yml
1419
with:
1520
name: Build
@@ -42,7 +47,7 @@ jobs:
4247
4348
unit-tests:
4449
name: Unit Tests
45-
needs: build
50+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
4651
uses: ./.github/workflows/bazel.yml
4752
strategy:
4853
fail-fast: false
@@ -57,18 +62,20 @@ jobs:
5762

5863
remote-tests:
5964
name: Remote Tests
60-
needs: build
6165
uses: ./.github/workflows/bazel.yml
6266
with:
6367
name: Integration Tests Remote
6468
needs-display: true
6569
rerun-with-debug: true
66-
run: |
67-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-remote
70+
run: >
71+
./scripts/github-actions/bazel-test-if-targets.sh
72+
--keep_going
73+
--flaky_test_attempts 3
74+
--local_test_jobs 1
75+
$(bazel query "tests(//py:test-remote) intersect set(${{ inputs.targets || '//py/...' }})" --output=label 2>/dev/null)
6876
6977
browser-tests:
7078
name: Browser Tests
71-
needs: build
7279
uses: ./.github/workflows/bazel.yml
7380
strategy:
7481
fail-fast: false
@@ -83,5 +90,10 @@ jobs:
8390
needs-display: true
8491
os: ${{ matrix.os }}
8592
rerun-with-debug: true
86-
run: |
87-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
93+
run: >
94+
./scripts/github-actions/bazel-test-if-targets.sh
95+
--keep_going
96+
--flaky_test_attempts 3
97+
--local_test_jobs 1
98+
--skip_incompatible_explicit_targets
99+
$(bazel query "tests(//py:test-${{ matrix.browser }}) intersect set(${{ inputs.targets || '//py/...' }})" --output=label 2>/dev/null)

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
outputs:
6565
java: ${{ steps.read.outputs.java }}
6666
grid: ${{ steps.read.outputs.grid }}
67-
py: ${{ steps.read.outputs.py }}
67+
py_targets: ${{ steps.read.outputs.py_targets }}
6868
rb_targets: ${{ steps.read.outputs.rb_targets }}
6969
dotnet: ${{ steps.read.outputs.dotnet }}
7070
rust: ${{ steps.read.outputs.rust }}
@@ -96,10 +96,10 @@ jobs:
9696
}
9797
check_binding "//java" "java"
9898
check_binding "openqa/selenium/grid" "grid"
99-
check_binding "//py" "py"
10099
check_binding "//dotnet" "dotnet"
101100
check_binding "//rust" "rust"
102101
process_binding "//rb" "rb"
102+
process_binding "//py" "py"
103103
dotnet:
104104
name: .NET
105105
needs: read-targets
@@ -122,7 +122,9 @@ jobs:
122122
name: Python
123123
needs: read-targets
124124
uses: ./.github/workflows/ci-python.yml
125-
if: needs.read-targets.outputs.py != ''
125+
if: needs.read-targets.outputs.py_targets != ''
126+
with:
127+
targets: ${{ needs.read-targets.outputs.py_targets }}
126128

127129
ruby:
128130
name: Ruby

scripts/github-actions/rerun-failures.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ fi
2222
if [[ "$RUN_CMD" == *"/ci-build.sh"* ]]; then
2323
base_cmd="bazel test --config=rbe-ci --build_tests_only --keep_going"
2424
else
25-
base_cmd=$(echo "$RUN_CMD" | sed 's| //[^ ]*||g')
25+
# Strip the targets (literal `//...` or a trailing `$(...)` query) to get the base command.
26+
base_cmd=$(echo "$RUN_CMD" | sed -E 's| \$\(.*$||; s| //[^ ]*||g')
2627
fi
2728
targets=$(tr '\n' ' ' < build/failures/_run1.txt)
2829
echo "Rerunning tests: $base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets"

0 commit comments

Comments
 (0)