Skip to content

Commit 694e9ad

Browse files
sonesukeclaude
andauthored
fix: set CHROME_BIN for Chrome in CI (#44)
* fix: set CHROME_BIN for Chrome in CI * revert: CI workflow to original simple configuration - Remove unnecessary Chrome setup steps (ubuntu-latest has Chrome pre-installed) - Remove CHROME_BIN environment variable setup - Remove SKIP_BROWSER_TESTS (browser tests should run) - Revert browser.rs --no-sandbox changes This restores the CI configuration that was working in commit 7ba3223 (v0.1.0). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: properly configure Chrome path in CI using config file - Add Chrome setup step that verifies Chrome/Chromium existence - Create config file with browser_path pointing to pre-installed Chrome - Increase Chrome startup timeout from 10s to 30s for slower CI environments - Update troubleshooting message to suggest using config command Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: apply Chrome config setup to release workflow as well Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 6b2c2e3 commit 694e9ad

4 files changed

Lines changed: 53 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,29 @@ jobs:
2323
with:
2424
components: rustfmt, clippy
2525

26-
- name: Setup Chrome
27-
uses: browser-actions/setup-chrome@v1
26+
- name: Setup Chrome configuration
27+
run: |
28+
# Check if Chrome exists in standard locations
29+
if [ -f "/usr/bin/google-chrome" ]; then
30+
CHROME_PATH="/usr/bin/google-chrome"
31+
elif [ -f "/usr/bin/chromium-browser" ]; then
32+
CHROME_PATH="/usr/bin/chromium-browser"
33+
else
34+
echo "ERROR: Chrome/Chromium not found"
35+
exit 1
36+
fi
37+
38+
echo "Found Chrome at: $CHROME_PATH"
39+
$CHROME_PATH --version
40+
41+
# Create config directory and set browser path
42+
mkdir -p ~/.config/google-patent-cli
43+
cat > ~/.config/google-patent-cli/config.toml << EOF
44+
browser_path = "$CHROME_PATH"
45+
EOF
46+
47+
echo "Config file created:"
48+
cat ~/.config/google-patent-cli/config.toml
2849
2950
- name: Check formatting
3051
run: cargo fmt -- --check

.github/workflows/release.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,29 @@ jobs:
2121
with:
2222
components: rustfmt, clippy
2323

24-
- name: Setup Chrome
25-
uses: browser-actions/setup-chrome@v1
24+
- name: Setup Chrome configuration
25+
run: |
26+
# Check if Chrome exists in standard locations
27+
if [ -f "/usr/bin/google-chrome" ]; then
28+
CHROME_PATH="/usr/bin/google-chrome"
29+
elif [ -f "/usr/bin/chromium-browser" ]; then
30+
CHROME_PATH="/usr/bin/chromium-browser"
31+
else
32+
echo "ERROR: Chrome/Chromium not found"
33+
exit 1
34+
fi
35+
36+
echo "Found Chrome at: $CHROME_PATH"
37+
$CHROME_PATH --version
38+
39+
# Create config directory and set browser path
40+
mkdir -p ~/.config/google-patent-cli
41+
cat > ~/.config/google-patent-cli/config.toml << EOF
42+
browser_path = "$CHROME_PATH"
43+
EOF
44+
45+
echo "Config file created:"
46+
cat ~/.config/google-patent-cli/config.toml
2647
2748
- name: Check formatting
2849
run: cargo fmt -- --check

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/cdp/browser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ impl CdpBrowser {
8686
// Spawn a thread to read stderr and look for the port
8787
tokio::spawn(async move {
8888
let start = std::time::Instant::now();
89-
// Try for up to 10 seconds
90-
while start.elapsed().as_secs() < 10 {
89+
// Try for up to 30 seconds (CI environments may be slower)
90+
while start.elapsed().as_secs() < 30 {
9191
if let Ok(content) = std::fs::read_to_string(&stderr_path) {
9292
for line in content.lines() {
9393
if debug_flag {
@@ -113,9 +113,9 @@ impl CdpBrowser {
113113

114114
let stderr_path_for_error = stderr_file.clone();
115115
let process_ext = process.clone();
116-
// Wait for the port to be discovered (up to 10 seconds)
116+
// Wait for the port to be discovered (up to 30 seconds for slower CI environments)
117117
let discovered_port = tokio::task::spawn_blocking(move || {
118-
for _ in 0..100 {
118+
for _ in 0..300 {
119119
let port_val = port.lock().map_or(None, |guard| *guard);
120120

121121
if let Some(p) = port_val {
@@ -157,12 +157,12 @@ impl CdpBrowser {
157157
err_msg = format!("{}\n\nChrome process exited early with status: {}", err_msg, status);
158158
} else {
159159
err_msg = format!(
160-
"{}\n\nChrome process is still running but debugging port was not found after 10 seconds.\n\n\
160+
"{}\n\nChrome process is still running but debugging port was not found after 30 seconds.\n\n\
161161
Troubleshooting:\n\
162162
- If running in CI, ensure Chrome/Chromium is installed and accessible\n\
163163
- Check if Chrome requires additional flags (e.g., --no-sandbox for Linux CI)\n\
164164
- Verify the temp directory is writable\n\
165-
- Try running with CHROME_BIN=/usr/bin/google-chrome-stable (or appropriate path)",
165+
- Try using 'config --set-browser' to specify the correct Chrome path",
166166
err_msg
167167
);
168168
}

0 commit comments

Comments
 (0)