Skip to content

Commit e265693

Browse files
fix: make CI tests cross-platform and fix docs deployment
1 parent 0141508 commit e265693

4 files changed

Lines changed: 22 additions & 27 deletions

File tree

.github/workflows/docs.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,15 @@ on:
55
branches: [main]
66

77
permissions:
8-
contents: read
9-
pages: write
10-
id-token: write
11-
12-
concurrency:
13-
group: "pages"
14-
cancel-in-progress: true
8+
contents: write
159

1610
jobs:
1711
docs:
1812
runs-on: ubuntu-latest
19-
environment:
20-
name: github-pages
21-
url: ${{ steps.deployment.outputs.page_url }}
2213
steps:
2314
- uses: actions/checkout@v4
2415
- uses: actions/setup-python@v5
2516
with:
2617
python-version: "3.12"
2718
- run: pip install -e ".[docs]"
28-
- run: mkdocs build --strict
29-
- uses: actions/upload-pages-artifact@v3
30-
with:
31-
path: site
32-
- id: deployment
33-
uses: actions/deploy-pages@v4
19+
- run: mkdocs gh-deploy --force

browserget/system.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ def _detect_windows(self, name: str) -> SystemBrowser | None:
117117
if sys.platform != "win32":
118118
return None
119119

120-
import winreg
120+
try:
121+
import winreg
122+
except ModuleNotFoundError:
123+
return None
121124

122125
for exe_path_str in _WINDOWS_PATHS.get(name, []):
123126
exe_path = Path(exe_path_str)

tests/unit/test_regression_phase4.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from __future__ import annotations
3737

3838
import hashlib
39+
import sys
3940
from datetime import UTC, datetime
4041
from pathlib import Path
4142

@@ -1290,6 +1291,7 @@ def test_macos_arm64_not_mac64_m1(self) -> None:
12901291
# ---------------------------------------------------------------------------
12911292

12921293

1294+
@pytest.mark.skipif(sys.platform != "win32", reason="Edge system detection tests require Windows")
12931295
class TestBug56EdgeForceRemovesOldEntry:
12941296
"""Bug 56: Edge installer must remove old registry entry on force reinstall.
12951297
@@ -1360,6 +1362,7 @@ async def fake_install_windows(resolved_ver, force_flag):
13601362
assert result.version == "131.0.0.0"
13611363

13621364

1365+
@pytest.mark.skipif(sys.platform != "win32", reason="Edge system detection tests require Windows")
13631366
class TestBug57EdgeForceRemovesAllStaleEntries:
13641367
"""Bug 57: Edge installer force=True must remove ALL stale entries.
13651368
@@ -1549,7 +1552,7 @@ class TestBug59NoPrematureDeletion:
15491552
installation but the registry still pointed to the now-deleted path.
15501553
"""
15511554

1552-
def test_firefox_install_preserves_dir_on_download_failure(self) -> None:
1555+
def test_firefox_install_preserves_dir_on_download_failure(self, tmp_path: Path) -> None:
15531556
"""Firefox installer must not remove old dir before download."""
15541557
from unittest.mock import AsyncMock, MagicMock, patch
15551558

@@ -1562,12 +1565,12 @@ def test_firefox_install_preserves_dir_on_download_failure(self) -> None:
15621565
registry.find.return_value = InstalledArtifact(
15631566
name="firefox",
15641567
version="131.0",
1565-
path=Path("/fake/firefox/131.0"),
1568+
path=tmp_path / "firefox" / "131.0",
15661569
installed_at=datetime.now(UTC),
15671570
checksum=None,
15681571
)
15691572

1570-
config = Config(cache_dir=Path("/fake/cache"))
1573+
config = Config(cache_dir=tmp_path / "cache")
15711574
http = MagicMock(spec=HttpClient)
15721575
http.download = AsyncMock(side_effect=RuntimeError("download failed"))
15731576
installer = FirefoxInstaller(http, registry, config)
@@ -1587,8 +1590,8 @@ def test_firefox_install_preserves_dir_on_download_failure(self) -> None:
15871590
patch("browserget.installers.firefox.get_download_dir") as mock_download_dir,
15881591
patch("browserget.installers.firefox.safe_download_path") as mock_safe_dl,
15891592
):
1590-
mock_download_dir.return_value = Path("/fake/downloads")
1591-
mock_safe_dl.return_value = Path("/fake/downloads/firefox.exe")
1593+
mock_download_dir.return_value = tmp_path / "downloads"
1594+
mock_safe_dl.return_value = tmp_path / "downloads" / "firefox.exe"
15921595

15931596
import asyncio
15941597

@@ -1598,7 +1601,7 @@ def test_firefox_install_preserves_dir_on_download_failure(self) -> None:
15981601
# safe_rmtree must NOT be called before the download succeeds
15991602
mock_rmtree.assert_not_called()
16001603

1601-
def test_chrome_install_preserves_dir_on_download_failure(self) -> None:
1604+
def test_chrome_install_preserves_dir_on_download_failure(self, tmp_path: Path) -> None:
16021605
"""Chrome installer must not remove old dir before download."""
16031606
from unittest.mock import AsyncMock, MagicMock, patch
16041607

@@ -1611,12 +1614,12 @@ def test_chrome_install_preserves_dir_on_download_failure(self) -> None:
16111614
registry.find.return_value = InstalledArtifact(
16121615
name="chrome",
16131616
version="131.0.6778.87",
1614-
path=Path("/fake/chrome/131.0.6778.87"),
1617+
path=tmp_path / "chrome" / "131.0.6778.87",
16151618
installed_at=datetime.now(UTC),
16161619
checksum=None,
16171620
)
16181621

1619-
config = Config(cache_dir=Path("/fake/cache"))
1622+
config = Config(cache_dir=tmp_path / "cache")
16201623
http = MagicMock(spec=HttpClient)
16211624
http.download = AsyncMock(side_effect=RuntimeError("download failed"))
16221625
installer = ChromeInstaller(http, registry, config)
@@ -1636,8 +1639,8 @@ def test_chrome_install_preserves_dir_on_download_failure(self) -> None:
16361639
patch("browserget.installers.chrome.get_download_dir") as mock_download_dir,
16371640
patch("browserget.installers.chrome.safe_download_path") as mock_safe_dl,
16381641
):
1639-
mock_download_dir.return_value = Path("/fake/downloads")
1640-
mock_safe_dl.return_value = Path("/fake/downloads/chrome.zip")
1642+
mock_download_dir.return_value = tmp_path / "downloads"
1643+
mock_safe_dl.return_value = tmp_path / "downloads" / "chrome.zip"
16411644

16421645
import asyncio
16431646

@@ -1654,6 +1657,7 @@ def test_chrome_install_preserves_dir_on_download_failure(self) -> None:
16541657
# ---------------------------------------------------------------------------
16551658

16561659

1660+
@pytest.mark.skipif(sys.platform != "win32", reason="Edge system detection tests require Windows")
16571661
class TestBug60EdgeNoPrematureRegistryCleanup:
16581662
"""Tests that the Edge installer does not remove registry entries before
16591663
the installation succeeds when force=True.

tests/unit/test_system.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import subprocess
6+
import sys
67
from pathlib import Path
78
from unittest.mock import MagicMock, patch
89

@@ -187,6 +188,7 @@ def test_detect_chrome_not_found(self) -> None:
187188
assert result is None
188189

189190

191+
@pytest.mark.skipif(sys.platform != "win32", reason="winreg is only available on Windows")
190192
class TestDetectWindows:
191193
"""Tests for Windows browser detection."""
192194

0 commit comments

Comments
 (0)