Skip to content

Commit 36c788c

Browse files
committed
Overhaul CI in GitHub Actions [dotnet][java][js][py][rb][rust]
This commit introduces few major changes to the Selenium CI, overhauling the current implementation to make it a bit more usable and maintainable. 1. Introduces high-level orchestrating "CI" workflow that is run on every push to the main branch, every 12 hours, every pull request, and manually. This workflow checks which bindings are affected by the pushed changes and calls individual CI workflows, presenting all of the results on a single page - https://github.com/SeleniumHQ/selenium/actions/workflows/ci.yml. 2. Reworks every "CI - <Bindings>" workflow to be callable from other workflows or run manually. The former is important for the "CI" workflow, the latter is matter of convenience so that individual bindings CI workflow can be run. 3. Individual bindings CI workflow are also implemented in a similar manner with the following pipeline: Build -> Documentation / Lint / Unit Tests -> Integration Tests This allows to better balance the load across the CI runners queue, preventing an immediate burst of queued runs. 4. Almost every CI pipeline step is implemented via a callable bazel.yml workflow. It is responsible for setting up the whole environment (browsers, Bazel caches) and greatly simplifies the individual bindings workflow. The only exceptions not using it are few JavaScript/Python tasks not migrated to Bazel and Rust pipeline. 6. Removes unnecessary installation of JDK because it's already taken care of by Bazel. 7. Allows to start interacting SSH session inside CI upon failure. This can be done by re-running a failed build with "Enable debug logging" on. 8. Allows to force-run CI on pull requests if the title includes [<bindings>] text. We could also fetch commits on this PR, but it needs extra code and can be done later.
1 parent 5752775 commit 36c788c

12 files changed

Lines changed: 549 additions & 898 deletions

File tree

.github/actions/sonar-cloud/action.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/bazel.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Bazel
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
name:
7+
description: Name of workflow
8+
required: false
9+
type: string
10+
run:
11+
description: Bazel command to run
12+
required: true
13+
type: string
14+
os:
15+
description: One of ubuntu, windows or macos
16+
required: false
17+
type: string
18+
default: ubuntu
19+
browser:
20+
description: One of chrome, firefox, or edge
21+
required: false
22+
type: string
23+
default: ''
24+
browser-version:
25+
description: One of stable, latest, latest-beta or latest-devedition
26+
required: false
27+
type: string
28+
default: ''
29+
cache-key:
30+
description: Bazel disk cache key
31+
required: false
32+
type: string
33+
default: ''
34+
java-version:
35+
description: Custom Java version to install
36+
required: false
37+
type: string
38+
default: ''
39+
ruby-version:
40+
description: Custom Ruby version to use
41+
required: false
42+
type: string
43+
default: ''
44+
45+
jobs:
46+
bazel:
47+
name: ${{ inputs.name }}
48+
runs-on: ${{ inputs.os }}-latest
49+
steps:
50+
- name: Checkout source tree
51+
uses: actions/checkout@v3
52+
- name: Set Ruby version
53+
if: inputs.ruby-version != ''
54+
run: echo 'RUBY_VERSION = "${{ inputs.ruby-version }}"' > rb/ruby_version.bzl
55+
- name: Setup Java
56+
if: inputs.java-version != ''
57+
uses: actions/setup-java@v3
58+
with:
59+
java-version: ${{ inputs.java-version }}
60+
distribution: 'temurin'
61+
- name: Setup Bazel
62+
uses: p0deje/[email protected]
63+
with:
64+
bazelisk-cache: true
65+
disk-cache: ${{ inputs.cache-key }}
66+
external-cache: |
67+
name: ${{ inputs.cache-key }}
68+
manifest:
69+
crates: rust/Cargo.Bazel.lock
70+
npm: package-lock.json
71+
pypi__pip: py/requirements_lock.txt
72+
rules_ruby_dist: rb/ruby_version.bzl
73+
repository-cache: true
74+
- name: Setup Fluxbox and Xvfb
75+
if: inputs.os == 'ubuntu' && inputs.browser != ''
76+
run: |
77+
sudo apt-get -y install fluxbox
78+
Xvfb :99 &
79+
fluxbox -display :99 &
80+
echo "DISPLAY=:99" >> $GITHUB_ENV
81+
- name: Set resolution
82+
if: inputs.os == 'windows' && inputs.browser != ''
83+
run: Set-DisplayResolution -Width 1920 -Height 1080 -Force
84+
- name: Setup Chrome
85+
if: inputs.browser == 'chrome'
86+
uses: browser-actions/setup-chrome@latest
87+
with:
88+
chrome-version: ${{ inputs.browser-version || 'stable' }}
89+
- name: Setup Firefox
90+
if: inputs.browser == 'firefox'
91+
uses: abhi1693/[email protected]
92+
with:
93+
browser: firefox
94+
version: ${{ inputs.browser-version || 'latest' }}
95+
- name: Setup Edge
96+
if: inputs.browser == 'edge'
97+
uses: browser-actions/setup-edge@latest
98+
with:
99+
edge-version: ${{ inputs.browser-version || 'stable' }}
100+
- name: Run Bazel
101+
run: ${{ inputs.run }}
102+
env:
103+
SELENIUM_BROWSER: ${{ inputs.browser }}
104+
- name: Start SSH session
105+
if: failure() && runner.debug == '1'
106+
uses: mxschmitt/action-tmate@v3

.github/workflows/ci-dotnet.yml

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,49 @@
1-
name: 'CI - .NET'
1+
name: CI - .NET
22

33
on:
4+
workflow_call:
45
workflow_dispatch:
56

6-
schedule:
7-
- cron: '10 9,21 * * *'
8-
9-
push:
10-
11-
pull_request:
12-
137
jobs:
14-
check_workflow:
15-
permissions:
16-
contents: none
17-
uses: ./.github/workflows/should-workflow-run.yml
8+
build:
9+
name: Build
10+
uses: ./.github/workflows/bazel.yml
1811
with:
19-
bazel-target-prefix: '//dotnet'
12+
name: Build
13+
cache-key: dotnet-build
14+
os: windows
15+
run: bazel build //dotnet/src/webdriver:package //dotnet/src/support:package
2016

21-
browser:
22-
if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[dotnet]') == true }}
23-
needs: check_workflow
24-
runs-on: 'windows-latest'
17+
integration-tests:
18+
name: Browser Tests
19+
needs: build
20+
uses: ./.github/workflows/bazel.yml
2521
strategy:
2622
fail-fast: false
2723
matrix:
28-
driver: [ Chrome, Firefox ]
29-
framework: [ net6.0, net48, netcoreapp3.1 ]
24+
driver:
25+
- Chrome
26+
- Firefox
27+
framework:
28+
- net48
29+
- net6.0
30+
- netcoreapp3.1
3031
include:
3132
- driver: Chrome
32-
location: 'C:\SeleniumWebDrivers\ChromeDriver'
33+
browser: chrome
34+
location: C:\SeleniumWebDrivers\ChromeDriver
3335
- driver: Firefox
34-
location: 'C:\SeleniumWebDrivers\GeckoDriver'
35-
steps:
36-
- name: Checkout source tree
37-
uses: actions/checkout@v3
38-
- name: Setup Java
39-
uses: actions/setup-java@v3
40-
with:
41-
java-version: 11
42-
distribution: 'temurin'
43-
- name: Setup Bazel
44-
uses: p0deje/[email protected]
45-
with:
46-
bazelisk-cache: true
47-
disk-cache: dotnet-${{ matrix.driver }}-${{ matrix.framework }}
48-
external-cache: |
49-
name: dotnet-${{ matrix.driver }}-${{ matrix.framework }}
50-
manifest:
51-
crates: rust/Cargo.Bazel.lock
52-
npm: package-lock.json
53-
pypi__pip: py/requirements_lock.txt
54-
rules_ruby_dist: rb/ruby_version.bzl
55-
repository-cache: true
56-
- name: Setup dotnet tests
57-
run: bazel build //dotnet/test/common:chrome
58-
- name: Run ${{ matrix.driver }} tests
59-
working-directory: dotnet
60-
run: dotnet test test/common/WebDriver.Common.Tests.csproj --framework ${{ matrix.framework }}
61-
env:
62-
ACTIVE_DRIVER_CONFIG: ${{ matrix.driver }}
63-
DRIVER_SERVICE_LOCATION: ${{ matrix.location }}
36+
browser: chrome
37+
location: C:\SeleniumWebDrivers\GeckoDriver
38+
with:
39+
name: Browser Tests (${{ matrix.driver }}, ${{ matrix.framework }})
40+
browser: ${{ matrix.browser }}
41+
cache-key: dotnet-${{ matrix.browser }}-${{ matrix.framework }}
42+
java-version: 11
43+
os: windows
44+
run: |
45+
bazel build //dotnet/test/common:${{ matrix.browser }}
46+
$env:ACTIVE_DRIVER_CONFIG = '${{ matrix.driver }}'
47+
$env:DRIVER_SERVICE_LOCATION = '${{ matrix.location }}'
48+
cd dotnet
49+
dotnet test test/common/WebDriver.Common.Tests.csproj --framework ${{ matrix.framework }}

0 commit comments

Comments
 (0)