Skip to content

Commit 0d4f16f

Browse files
authored
Merge pull request #12 from ArchiveBox/chrome-remote-providers
Allow Chrome to support remote browser providers and one-chrome-per-snapshot mode
2 parents cfb3f34 + 2d38e91 commit 0d4f16f

174 files changed

Lines changed: 3831 additions & 2473 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-parallel.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
needs: discover-tests
7575
env:
7676
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
77+
ABX_PYTEST_TEE_SUBPROCESS_OUTPUT: "1"
7778

7879
strategy:
7980
fail-fast: false
@@ -135,7 +136,7 @@ jobs:
135136

136137
- name: Run test - ${{ matrix.test.name }}
137138
run: |
138-
uv run pytest -xvs "${{ matrix.test.path }}" --basetemp="$RUNNER_TEMP/pytest-out"
139+
uv run pytest -xvs -rA "${{ matrix.test.path }}" --basetemp="$RUNNER_TEMP/pytest-out"
139140
env:
140141
TWOCAPTCHA_API_KEY: ${{ secrets.TWOCAPTCHA_API_KEY }}
141142
CHROME_SANDBOX: "false"

abx_plugins/plugins/__init__.py

100644100755
File mode changed.

abx_plugins/plugins/accessibility/on_Snapshot__39_accessibility.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ const {
2626
} = require('../base/utils.js');
2727
ensureNodeModuleResolution(module);
2828
const puppeteer = require('puppeteer-core');
29-
const {
30-
waitForChromeSession,
31-
connectToPage,
32-
waitForPageLoaded,
33-
} = require('../chrome/chrome_utils.js');
29+
const { connectToPage } = require('../chrome/chrome_utils.js');
3430

3531
// Extractor metadata
3632
const PLUGIN_NAME = 'accessibility';
@@ -52,18 +48,15 @@ async function extractAccessibility(url, timeoutMs) {
5248
let browser = null;
5349

5450
try {
55-
if (!(await waitForChromeSession(CHROME_SESSION_DIR, Math.min(timeoutMs, 1000), true))) {
56-
return { success: false, error: 'No Chrome session found (chrome plugin must run first)' };
57-
}
58-
5951
const connection = await connectToPage({
6052
chromeSessionDir: CHROME_SESSION_DIR,
6153
timeoutMs,
54+
waitForNavigationComplete: true,
55+
postLoadDelayMs: 200,
6256
puppeteer,
6357
});
6458
browser = connection.browser;
6559
const page = connection.page;
66-
await waitForPageLoaded(CHROME_SESSION_DIR, timeoutMs * 4, 200);
6760

6861
// Get accessibility snapshot
6962
const accessibilityTree = await page.accessibility.snapshot({ interestingOnly: true });

abx_plugins/plugins/accessibility/tests/__init__.py

100644100755
File mode changed.

abx_plugins/plugins/accessibility/tests/test_accessibility.py

100644100755
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def test_accessibility_extracts_page_outline(self, chrome_test_url):
7878

7979
# Run accessibility hook with the active Chrome session
8080
result = subprocess.run(
81-
[
82-
"node",
83-
str(ACCESSIBILITY_HOOK),
81+
[str(ACCESSIBILITY_HOOK),
8482
f"--url={test_url}",
8583
f"--snapshot-id={snapshot_id}",
8684
],
@@ -133,9 +131,7 @@ def test_accessibility_disabled_skips(self, chrome_test_url):
133131
env["ACCESSIBILITY_ENABLED"] = "False"
134132

135133
result = subprocess.run(
136-
[
137-
"node",
138-
str(ACCESSIBILITY_HOOK),
134+
[str(ACCESSIBILITY_HOOK),
139135
f"--url={test_url}",
140136
f"--snapshot-id={snapshot_id}",
141137
],
@@ -158,7 +154,7 @@ def test_accessibility_missing_url_argument(self):
158154
snapshot_id = "test-missing-url"
159155

160156
result = subprocess.run(
161-
["node", str(ACCESSIBILITY_HOOK), f"--snapshot-id={snapshot_id}"],
157+
[str(ACCESSIBILITY_HOOK), f"--snapshot-id={snapshot_id}"],
162158
cwd=str(self.temp_dir),
163159
capture_output=True,
164160
text=True,
@@ -174,7 +170,7 @@ def test_accessibility_missing_snapshot_id_argument(self, chrome_test_url):
174170
test_url = chrome_test_url
175171

176172
result = subprocess.run(
177-
["node", str(ACCESSIBILITY_HOOK), f"--url={test_url}"],
173+
[str(ACCESSIBILITY_HOOK), f"--url={test_url}"],
178174
cwd=str(self.temp_dir),
179175
capture_output=True,
180176
text=True,
@@ -191,9 +187,7 @@ def test_accessibility_with_no_chrome_session(self, chrome_test_url):
191187
snapshot_id = "test-no-chrome"
192188

193189
result = subprocess.run(
194-
[
195-
"node",
196-
str(ACCESSIBILITY_HOOK),
190+
[str(ACCESSIBILITY_HOOK),
197191
f"--url={test_url}",
198192
f"--snapshot-id={snapshot_id}",
199193
],

abx_plugins/plugins/apt/on_Binary__13_apt_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# /// script
33
# requires-python = ">=3.12"
44
# dependencies = [
5-
# "click",
5+
# "rich-click",
66
# "abx-pkg",
77
# ]
88
# ///

abx_plugins/plugins/apt/tests/__init__.py

100644100755
File mode changed.

abx_plugins/plugins/apt/tests/test_apt_provider.py

100644100755
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ def test_hook_script_exists(self):
5252
def test_hook_skips_when_apt_not_allowed(self):
5353
"""Hook should skip when apt not in allowed binproviders."""
5454
result = subprocess.run(
55-
[
56-
sys.executable,
57-
str(INSTALL_HOOK),
55+
[str(INSTALL_HOOK),
5856
"--name=wget",
5957
"--binary-id=test-uuid",
6058
"--machine-id=test-machine",
@@ -74,9 +72,7 @@ def test_hook_detects_apt(self):
7472
"""Hook should detect apt binary when available."""
7573
assert apt_available(), "apt not installed"
7674
result = subprocess.run(
77-
[
78-
sys.executable,
79-
str(INSTALL_HOOK),
75+
[str(INSTALL_HOOK),
8076
"--name=nonexistent-pkg-xyz123",
8177
"--binary-id=test-uuid",
8278
"--machine-id=test-machine",
@@ -94,9 +90,7 @@ def test_hook_handles_overrides(self):
9490
overrides = json.dumps({"apt": {"install_args": ["custom-package-name"]}})
9591

9692
result = subprocess.run(
97-
[
98-
sys.executable,
99-
str(INSTALL_HOOK),
93+
[str(INSTALL_HOOK),
10094
"--name=test-pkg",
10195
"--binary-id=test-uuid",
10296
"--machine-id=test-machine",
@@ -120,9 +114,7 @@ def test_detect_existing_binary(self):
120114
assert apt_available(), "apt not installed"
121115
# Check for a binary that's almost certainly installed (like 'ls' or 'bash')
122116
result = subprocess.run(
123-
[
124-
sys.executable,
125-
str(INSTALL_HOOK),
117+
[str(INSTALL_HOOK),
126118
"--name=bash",
127119
"--binary-id=test-uuid",
128120
"--machine-id=test-machine",

abx_plugins/plugins/archivedotorg/tests/__init__.py

100644100755
File mode changed.

abx_plugins/plugins/archivedotorg/tests/test_archivedotorg.py

100644100755
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def test_submits_to_archivedotorg():
3636
env["ARCHIVEDOTORG_TIMEOUT"] = "45"
3737

3838
result = subprocess.run(
39-
[
40-
sys.executable,
41-
str(ARCHIVEDOTORG_HOOK),
39+
[str(ARCHIVEDOTORG_HOOK),
4240
"--url",
4341
TEST_URL,
4442
"--snapshot-id",
@@ -77,9 +75,7 @@ def test_config_save_archivedotorg_false_skips():
7775
env["ARCHIVEDOTORG_ENABLED"] = "False"
7876

7977
result = subprocess.run(
80-
[
81-
sys.executable,
82-
str(ARCHIVEDOTORG_HOOK),
78+
[str(ARCHIVEDOTORG_HOOK),
8379
"--url",
8480
TEST_URL,
8581
"--snapshot-id",
@@ -115,9 +111,7 @@ def test_handles_timeout():
115111
env["TIMEOUT"] = "1"
116112

117113
result = subprocess.run(
118-
[
119-
sys.executable,
120-
str(ARCHIVEDOTORG_HOOK),
114+
[str(ARCHIVEDOTORG_HOOK),
121115
"--url",
122116
TEST_URL,
123117
"--snapshot-id",

0 commit comments

Comments
 (0)