Skip to content

Commit fa8e695

Browse files
committed
Separate Github Action changes from Travis code
1 parent 25e762e commit fa8e695

5 files changed

Lines changed: 85 additions & 25 deletions

File tree

.github/workflows/test.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
name: Selenium Testing
1+
name: Tests
22

33
on:
44
push:
55
branches:
66
- master
77
- travis-github-action
8+
- travis-github-action-mv3
89
pull_request:
910
workflow_dispatch:
1011

1112
jobs:
1213
test:
1314
runs-on: ubuntu-22.04
15+
continue-on-error: ${{ matrix.job != 'lint' }}
1416
strategy:
1517
matrix:
16-
job: [lint, firefox, firefox-beta, firefox-nightly, firefox-esr, edge-beta]
17-
# job: [lint, firefox, edge-beta]
18+
job: [lint, firefox, firefox-beta, firefox-nightly, firefox-esr, edge-beta, chrome, chrome-beta]
1819
include:
1920
- job: lint
2021
INFO: "lint"
@@ -37,7 +38,6 @@ jobs:
3738
- job: edge-beta
3839
INFO: "Edge Beta"
3940
BROWSER: "microsoft-edge-beta"
40-
# Move Chrome tests into mv3 repo after testing:
4141
- job: chrome
4242
INFO: "Chrome"
4343
BROWSER: "google-chrome-stable"
@@ -79,7 +79,6 @@ jobs:
7979
uses: browser-actions/setup-edge@v1
8080
with:
8181
edge-version: beta
82-
# Why do we test with Edge Beta but not Edge?
8382

8483
- name: Set up Chrome
8584
if: ${{ contains(matrix.BROWSER, 'chrome') }}
@@ -88,6 +87,7 @@ jobs:
8887
chrome-version: ${{ matrix.CHROME_VERSION }}
8988
install-chromedriver: true
9089
id: setup-chrome
90+
9191
- name: Verify Chrome Installation
9292
if: ${{ contains(matrix.BROWSER, 'chrome') }}
9393
run: |
@@ -102,21 +102,15 @@ jobs:
102102
sudo rm -f /usr/bin/${{ matrix.BROWSER }}
103103
sudo ln -s ${{ steps.setup-chrome.outputs.chrome-path }} /usr/bin/google-chrome
104104
sudo ln -s ${{ steps.setup-chrome.outputs.chrome-path }} /usr/bin/${{ matrix.BROWSER }}
105-
106105
- name: Check Chrome Installation after overwriting system Chrome
107106
if: ${{ contains(matrix.BROWSER, 'chrome') }}
108107
run: |
109108
${{ steps.setup-chrome.outputs.chrome-path }} --version
110109
${{ matrix.BROWSER }} --version
111110
chrome --version
112111
google-chrome --version
113-
114-
# - name: Install Chrome Driver
115-
# if: ${{ contains(matrix.BROWSER, 'chrome') }}
116-
# uses: browser-actions/setup-geckodriver@latest
117-
118112
- name: Run Setup Script
119-
run: ./scripts/setup_travis.sh
113+
run: ./scripts/setup_ga_tests.sh
120114

121115
- name: Run Tests
122116
run: ./scripts/run_travis.sh

scripts/run_travis.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ else
2222
case $BROWSER in
2323
*chrome*)
2424
echo "Running tests on Chrome"
25-
# check that chromedriver is now present
26-
type chromedriver >/dev/null 2>&1 || {
27-
echo "Failed to install ChromeDriver!"
28-
exit 1
29-
}
30-
chromedriver --version
3125
run_selenium
3226
;;
3327
*firefox*)

scripts/setup_ga_tests.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
3+
toplevel=$(git rev-parse --show-toplevel)
4+
5+
install_edge_webdriver() {
6+
edge_version_major=$(microsoft-edge-beta --product-version | cut -d . -f 1)
7+
edgedriver_version_url="https://msedgedriver.azureedge.net/LATEST_RELEASE_${edge_version_major}_LINUX"
8+
edgedriver_version=$(curl -s "$edgedriver_version_url" | tr -d "\0\r\n" | cut -c 3-)
9+
if [ -z "$edgedriver_version" ]; then
10+
echo "Failed to retrieve Edge WebDriver version!"
11+
exit 1
12+
fi
13+
14+
echo "Installing Edge WebDriver version $edgedriver_version ..."
15+
wget "https://msedgedriver.azureedge.net/${edgedriver_version}/edgedriver_linux64.zip"
16+
unzip edgedriver_linux64.zip
17+
sudo mv msedgedriver /usr/local/bin/
18+
sudo chmod a+x /usr/local/bin/msedgedriver
19+
20+
# check that Edge WebDriver is now present
21+
type msedgedriver >/dev/null 2>&1 || {
22+
echo "Failed to install Edge WebDriver!"
23+
exit 1
24+
}
25+
}
26+
27+
install_python_deps() {
28+
pip install -r "$toplevel"/tests/requirements.txt
29+
}
30+
31+
install_node_deps() {
32+
# "--production" to skip installing devDependencies modules
33+
npm ci --production || exit 1
34+
}
35+
36+
# check that the desired browser is present as it might fail to install
37+
# for example: https://travis-ci.org/EFForg/privacybadger/jobs/362381214
38+
check_browser() {
39+
type "$BROWSER" >/dev/null 2>&1 || {
40+
echo "$BROWSER seems to be missing!"
41+
exit 1
42+
}
43+
44+
# print the version
45+
echo "Found $("$BROWSER" --version)"
46+
}
47+
48+
case $INFO in
49+
*Chrome*)
50+
check_browser
51+
# check that chromedriver is present
52+
type chromedriver >/dev/null 2>&1 || {
53+
echo "Failed to install ChromeDriver!"
54+
exit 1
55+
}
56+
chromedriver --version
57+
install_python_deps
58+
;;
59+
*Firefox*)
60+
check_browser
61+
install_geckodriver
62+
install_python_deps
63+
;;
64+
*Edge*)
65+
check_browser
66+
install_python_deps
67+
;;
68+
*lint*)
69+
install_node_deps
70+
;;
71+
*)
72+
echo "bad INFO variable, got $INFO"
73+
exit 1
74+
;;
75+
esac

scripts/setup_travis.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,12 @@ check_browser() {
7979
case $INFO in
8080
*Chrome*)
8181
check_browser
82-
# "$toplevel"/scripts/chromedriver.sh "$BROWSER" || exit 1
82+
"$toplevel"/scripts/chromedriver.sh "$BROWSER" || exit 1
8383
install_python_deps
8484
;;
8585
*Firefox*)
8686
check_browser
87-
# sudo apt-get install -y xvfb
88-
# install_geckodriver
87+
install_geckodriver
8988
install_python_deps
9089
;;
9190
*Edge*)

tests/selenium/pbtest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def edge_manager(self):
191191
opts = EdgeOptions()
192192
opts.add_argument("--load-extension=" + self.extension_path)
193193
opts.add_argument("--headless")
194-
# opts.add_argument("--edge-skip-compat-layer-relaunch") # https://github.com/SeleniumHQ/selenium/issues/15340#issuecomment-2689372248
195194
opts.binary_location = self.browser_path
196195

197196
for i in range(5):
@@ -239,10 +238,9 @@ def firefox_manager(self):
239238
# to produce a trace-level geckodriver.log,
240239
# remove the log_output argument to FirefoxService()
241240
# and uncomment the line below
242-
opts.log.level = "trace"
243-
service = FirefoxService()
241+
# opts.log.level = "trace"
244242

245-
# service = FirefoxService(log_output=os.path.devnull)
243+
service = FirefoxService(log_output=os.path.devnull)
246244
driver = webdriver.Firefox(options=opts, service=service)
247245

248246
except WebDriverException as e:

0 commit comments

Comments
 (0)