Skip to content

Commit 84bc272

Browse files
committed
change how python tests are filtered
1 parent 332979c commit 84bc272

File tree

2 files changed

+54
-24
lines changed

2 files changed

+54
-24
lines changed

.github/workflows/ci-python.yml

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ name: CI - Python
22

33
on:
44
workflow_call:
5+
inputs:
6+
targets:
7+
required: false
8+
type: string
9+
default: ''
10+
run-full-suite:
11+
required: false
12+
type: boolean
13+
default: true
514
workflow_dispatch:
615

716
permissions:
817
contents: read
918

1019
jobs:
11-
build:
12-
name: Build
13-
uses: ./.github/workflows/bazel.yml
14-
with:
15-
name: Build
16-
run: |
17-
bazel build //py:selenium-wheel //py:selenium-sdist
18-
1920
docs:
2021
name: Documentation
22+
if: ${{ inputs.run-full-suite }}
2123
runs-on: ubuntu-latest
2224
steps:
2325
- name: Checkout source tree
@@ -38,6 +40,7 @@ jobs:
3840

3941
typing:
4042
name: Type Checker
43+
if: ${{ inputs.run-full-suite }}
4144
runs-on: ubuntu-latest
4245
steps:
4346
- name: Checkout source tree
@@ -58,7 +61,7 @@ jobs:
5861

5962
unit-tests:
6063
name: Unit Tests
61-
needs: build
64+
if: ${{ inputs.run-full-suite }}
6265
uses: ./.github/workflows/bazel.yml
6366
strategy:
6467
fail-fast: false
@@ -71,31 +74,50 @@ jobs:
7174
python-version: ${{ matrix.python-version }}
7275
run: bazel test --local_test_jobs 1 //py:unit
7376

74-
remote-tests:
75-
name: Remote Tests
76-
needs: build
77-
uses: ./.github/workflows/bazel.yml
78-
with:
79-
name: Integration Tests Remote
80-
browser: yes
81-
run: |
82-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-remote
77+
filter-targets:
78+
name: Filter Targets
79+
runs-on: ubuntu-latest
80+
outputs:
81+
targets: ${{ steps.filter.outputs.targets }}
82+
steps:
83+
- name: Filter Python targets
84+
id: filter
85+
shell: bash
86+
run: |
87+
targets="${{ inputs.targets }}"
88+
filtered=()
89+
90+
for t in $targets; do
91+
[[ "$t" == //py* ]] && filtered+=("$t")
92+
done
93+
94+
if [ ${#filtered[@]} -eq 0 ]; then
95+
echo "targets=//py/..." >> "$GITHUB_OUTPUT"
96+
else
97+
echo "targets=${filtered[*]}" >> "$GITHUB_OUTPUT"
98+
fi
8399
84100
browser-tests:
85101
name: Browser Tests
86-
needs: build
102+
needs: filter-targets
87103
uses: ./.github/workflows/bazel.yml
88104
strategy:
89105
fail-fast: false
90106
matrix:
91-
browser: [chrome, firefox, chrome-bidi, edge]
107+
browser: [chrome, firefox, chrome-bidi, chrome-remote]
92108
os: [windows]
93109
include:
94110
- browser: safari
95111
os: macos
96112
with:
97-
name: Integration Tests (${{ matrix.browser }})
113+
name: Browser Tests (${{ matrix.browser }}, ${{ matrix.os }})
98114
browser: ${{ matrix.browser }}
99115
os: ${{ matrix.os }}
100-
run: |
101-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
116+
run: >
117+
bazel test
118+
--keep_going
119+
--build_tests_only
120+
--flaky_test_attempts 3
121+
--local_test_jobs 1
122+
--test_tag_filters=${{ matrix.browser }}
123+
${{ needs.filter-targets.outputs.targets }}

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,20 @@ jobs:
7676
name: Python
7777
needs: check
7878
uses: ./.github/workflows/ci-python.yml
79+
with:
80+
targets: ${{ needs.check.outputs.targets }}
81+
run-full-suite: >-
82+
${{
83+
github.event_name == 'schedule' ||
84+
github.event_name == 'workflow_dispatch' ||
85+
github.event_name == 'workflow_call' ||
86+
contains(github.event.pull_request.title, '[py]')
87+
}}
7988
if: >
8089
github.event_name == 'schedule' ||
8190
github.event_name == 'workflow_dispatch' ||
8291
github.event_name == 'workflow_call' ||
8392
contains(needs.check.outputs.targets, '//py') ||
84-
contains(join(github.event.commits.*.message), '[py]') ||
8593
contains(github.event.pull_request.title, '[py]')
8694
8795
ruby:

0 commit comments

Comments
 (0)