Skip to content

Commit 76ac154

Browse files
authored
Add CI for MacOS and Windows (#128)
* add a workflow * trigger on push for this branch * python 3.11 * python 3.11 * rerun basic test * tweak win deps script * tweak win deps script * skip tests in win gha if unstable there * macos gha the cheaty way * macos gha the hard way * figure out why mac runs zombie * mark zombie test * mark mute tabs * actually check for gha env * check if driver is inited in main conftest finally block * add artifacts and try all macos tests * sleep before moving geckodriver * save executables in separate folders * fix artifacts gha * why can't we match gecko binary * remove debug, try to find broken arch * hard wait in GHA * figure out the wd exception * log the exception, announce collection * what shell does win use * try forcing bash for win * deflake clear cookies, test * continue to debug gecko download failure * force win to download correctly in MinGW, bash in mac * try to unzip properly * debug collector again * debug collector again * debug collector again * debug collector again * really wait for geckodriver * remove one debug line * stop running all tests on this branch * run checks on PR edit * switch selector * run on all pr * comment and import
1 parent cb6d613 commit 76ac154

12 files changed

+125
-22
lines changed

.github/workflows/smoke.yml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,62 @@
1+
---
12
name: Mac and Windows Smoke
23

34
run-name: ${{ github.actor }} is running smoke tests
45
on:
5-
push:
6-
branches: ["bc/gha"]
76
pull_request:
8-
types:
9-
- created
7+
108
jobs:
119
Smoke-Windows:
1210
runs-on: windows-latest
1311
steps:
1412
- name: Checkout repository
1513
uses: actions/checkout@v4
16-
- name: Set up Python 3.13
17-
uses: actions/setup-python@v3
14+
- name: Set up Python 3.11
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.11"
18+
- name: Install dependencies
19+
run: |
20+
mkdir -p artifacts;
21+
pip3 install 'pipenv==2023.11.15';
22+
pip3 install 'ruff>=0.4.8,<0.5';
23+
bash collect_executables.sh;
24+
rm ./pyproject.toml;
25+
mv ./ci_pyproject.toml ./pyproject.toml;
26+
pipenv install;
27+
- name: Run Smoke Tests in Win
28+
run: |
29+
pipenv run pytest --fx-executable ./firefox/firefox -n 4 .
30+
mv artifacts artifacts-win
31+
- name: Upload artifacts
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: artifacts-win
35+
path: artifacts-win
36+
Smoke-MacOS:
37+
runs-on: macos-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
- name: Set up Python 3.11
42+
uses: actions/setup-python@v5
1843
with:
1944
python-version: "3.11"
45+
- name: Install dependencies
46+
run: |
47+
mkdir -p artifacts;
48+
pip3 install 'pipenv==2023.11.15';
49+
pip3 install 'ruff>=0.4.8,<0.5';
50+
bash collect_executables.sh;
51+
rm ./pyproject.toml;
52+
mv ./ci_pyproject.toml ./pyproject.toml;
53+
pipenv install;
54+
- name: Run Smoke Tests in MacOS
55+
run: |
56+
pipenv run pytest --fx-executable ./firefox/firefox -n 4 tests
57+
mv artifacts artifacts-mac
58+
- name: Upload artifacts
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: artifacts-mac
62+
path: artifacts-mac

collect_executables.sh

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#!/bin/bash
2+
echo "~~collect executables~~"
23

34
# Usage: ./collect_executables.sh [channel]
45
# Collects geckodriver and Fx, default channel is Beta.
56

67
## Determine OS and arch
78
UNAME_A=$(uname -a)
8-
if [ -n "$WSL_DISTRO_NAME" ]
9+
## Save the system arch info
10+
echo "uname -a: ${UNAME_A}"
11+
if [ -n "$WSL_DISTRO_NAME" ] || [[ $UNAME_A == *"MINGW"* ]]
912
then
1013
SYSTEM_NAME="win"
14+
if [[ $UNAME_A == *"x86_64"* ]]
15+
then
16+
BITS="64"
17+
else
18+
BITS="32"
19+
fi
1120
else
1221
if [[ $UNAME_A == *"Darwin"* ]]
1322
then
@@ -29,11 +38,6 @@ else
2938
fi
3039
fi
3140

32-
if [[ "$SYSTEM_NAME" == "win" ]] && [[ -z $ARCH ]] && [[ $BITS = "64" ]]
33-
then
34-
BITS=32
35-
fi
36-
3741
if [[ $SYSTEM_NAME == "win" ]]
3842
then
3943
EXT="zip"
@@ -43,14 +47,13 @@ fi
4347

4448
# Find the version of Geckodriver that matches arch
4549
FILENAME="-${SYSTEM_NAME}${BITS}${ARCH}.${EXT}"
46-
50+
echo "FILENAME ${FILENAME}"
4751
# 20 is arbitrary and may break if future releases of Geckodriver have more than 20 channels
4852
for i in {0..20}
4953
do
5054
GECKO_LINK=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq ".[\"assets\"][${i}][\"browser_download_url\"]" | tr -d '"')
5155
if [[ $GECKO_LINK == *"${FILENAME}"* ]] && [[ $GECKO_LINK != *".asc" ]]
5256
then
53-
echo "$GECKO_LINK"
5457
curl -OL "$GECKO_LINK"
5558
fi
5659
done
@@ -83,8 +86,24 @@ FX_LOC=$(echo "$FX_LINK_HTML" | awk -F '"' '{print $2}')
8386

8487
curl -O "$FX_LOC"
8588

86-
mv geckodriver*.tar.gz geckodriver.tar.gz
87-
tar -xvzf geckodriver.tar.gz
89+
GD_FILE=$(ls geckodriver*)
90+
mv "$GD_FILE" "geckodriver.${EXT}"
91+
if [[ $EXT == "zip" ]]
92+
then
93+
unzip geckodriver.zip
94+
else
95+
tar -xvzf geckodriver.tar.gz
96+
fi
97+
98+
# Wait up to 10 seconds for geckodriver to exist
99+
for ((i=0; i<200; i++))
100+
do
101+
if [ -f geckodriver ]
102+
then
103+
break
104+
fi
105+
sleep 0.2
106+
done
88107
chmod +x geckodriver
89108

90109
if [[ $SYSTEM_NAME == "linux" ]]

conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77
from selenium import webdriver
8+
from selenium.common.exceptions import WebDriverException
89
from selenium.webdriver.firefox.options import Options
910

1011

@@ -180,9 +181,11 @@ def driver(
180181
timeout = 30 if opt_ci else opt_implicit_timeout
181182
driver.implicitly_wait(timeout)
182183
yield driver
183-
184+
except WebDriverException as e:
185+
logging.warning(f"DRIVER exception: {e}")
184186
finally:
185-
driver.quit()
187+
if "driver" in locals() or "driver" in globals():
188+
driver.quit()
186189

187190

188191
@pytest.fixture()

modules/data/about_prefs.components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
},
7979

8080
"prefs-button": {
81-
"selectorData": "button[label='{name}']",
81+
"selectorData": "button[label^='{name}']",
8282
"strategy": "css",
8383
"groups": []
8484
},

modules/data/generic_page.components.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
},
2525

2626
"wiki-search-bar": {
27-
"selectorData": "searchInput",
28-
"strategy": "id",
27+
"selectorData": "cdx-text-input__input",
28+
"strategy": "class",
2929
"groups": []
3030
},
3131

tests/address_bar_and_search/test_google_search_counts_us.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import sys
2+
from os import environ
13
from time import sleep
24

5+
import pytest
36
from selenium.webdriver import Firefox
47

58
from modules.browser_object import Navigation
69
from modules.page_object import AboutTelemetry
710
from modules.util import Utilities
811

12+
MAC_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin")
913

14+
15+
@pytest.mark.skipif(MAC_GHA, reason="Test unstable in MacOS Github Actions")
1016
def test_google_search_counts_us(driver: Firefox):
1117
"""
1218
C1365026, Test Google Search counts - urlbar US

tests/address_bar_and_search/test_google_withads_url_bar_us.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
from os import environ
13
from time import sleep
24

35
import pytest
@@ -13,6 +15,10 @@ def add_prefs():
1315
return [("cookiebanners.service.mode", 1)]
1416

1517

18+
MAC_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("darwin")
19+
20+
21+
@pytest.mark.skipif(MAC_GHA, reason="Test unstable in MacOS Github Actions")
1622
def test_google_withads_url_bar_us(driver: Firefox):
1723
"""
1824
C1365070, verify that Google withads URL bar - US is recorder into telemetry

tests/language_packs/test_language_pack_install_preferences.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import sys
2+
from os import environ
3+
14
import pytest
25
from selenium.webdriver import Firefox
36

@@ -7,6 +10,10 @@
710
LANGUAGES = [("it", "Imposta alternative…")]
811

912

13+
WIN_GHA = environ.get("GITHUB_ACTIONS") == "true" and sys.platform.startswith("win")
14+
15+
16+
@pytest.mark.skipif(WIN_GHA, reason="Test unstable in Windows Github Actions")
1017
@pytest.mark.parametrize("shortform, localized_text", LANGUAGES)
1118
def test_language_pack_install_about_preferences(
1219
driver: Firefox, shortform: str, localized_text: str

tests/preferences/test_clear_cookie_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_clear_cookie_data(driver: Firefox):
1515
def open_clear_cookies_data_dialog():
1616
about_prefs.open()
1717
clear_data_popup = about_prefs.press_button_get_popup_dialog_iframe(
18-
"Clear Data"
18+
"Clear Data"
1919
)
2020
ba.switch_to_iframe_context(clear_data_popup)
2121

tests/tabs/test_mute_tabs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
from os import environ
2+
13
import pytest
24
from selenium.webdriver import Firefox
35
from selenium.webdriver.common.by import By
46

57
from modules.browser_object import TabBar
68

9+
GHA = environ.get("GITHUB_ACTIONS") == "true"
10+
711

12+
@pytest.mark.skipif(GHA, reason="Test unstable in Github Actions")
813
@pytest.mark.audio
914
def test_mute_unmute_tab(screenshot, driver: Firefox, video_url: str):
1015
"""C134719, test that tabs can be muted and unmuted"""

0 commit comments

Comments
 (0)