diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd65da0..ca5b825 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,29 @@ jobs: with: components: rustfmt, clippy - - name: Setup Chrome - uses: browser-actions/setup-chrome@v1 + - name: Setup Chrome configuration + run: | + # Check if Chrome exists in standard locations + if [ -f "/usr/bin/google-chrome" ]; then + CHROME_PATH="/usr/bin/google-chrome" + elif [ -f "/usr/bin/chromium-browser" ]; then + CHROME_PATH="/usr/bin/chromium-browser" + else + echo "ERROR: Chrome/Chromium not found" + exit 1 + fi + + echo "Found Chrome at: $CHROME_PATH" + $CHROME_PATH --version + + # Create config directory and set browser path + mkdir -p ~/.config/google-patent-cli + cat > ~/.config/google-patent-cli/config.toml << EOF + browser_path = "$CHROME_PATH" + EOF + + echo "Config file created:" + cat ~/.config/google-patent-cli/config.toml - name: Check formatting run: cargo fmt -- --check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2843bee..1fb78d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,8 +21,29 @@ jobs: with: components: rustfmt, clippy - - name: Setup Chrome - uses: browser-actions/setup-chrome@v1 + - name: Setup Chrome configuration + run: | + # Check if Chrome exists in standard locations + if [ -f "/usr/bin/google-chrome" ]; then + CHROME_PATH="/usr/bin/google-chrome" + elif [ -f "/usr/bin/chromium-browser" ]; then + CHROME_PATH="/usr/bin/chromium-browser" + else + echo "ERROR: Chrome/Chromium not found" + exit 1 + fi + + echo "Found Chrome at: $CHROME_PATH" + $CHROME_PATH --version + + # Create config directory and set browser path + mkdir -p ~/.config/google-patent-cli + cat > ~/.config/google-patent-cli/config.toml << EOF + browser_path = "$CHROME_PATH" + EOF + + echo "Config file created:" + cat ~/.config/google-patent-cli/config.toml - name: Check formatting run: cargo fmt -- --check diff --git a/Cargo.lock b/Cargo.lock index c2dec32..1b78eff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -560,7 +560,7 @@ dependencies = [ [[package]] name = "google-patent-cli" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "assert_cmd", diff --git a/src/core/cdp/browser.rs b/src/core/cdp/browser.rs index 4c02fb0..1e1b0c2 100644 --- a/src/core/cdp/browser.rs +++ b/src/core/cdp/browser.rs @@ -86,8 +86,8 @@ impl CdpBrowser { // Spawn a thread to read stderr and look for the port tokio::spawn(async move { let start = std::time::Instant::now(); - // Try for up to 10 seconds - while start.elapsed().as_secs() < 10 { + // Try for up to 30 seconds (CI environments may be slower) + while start.elapsed().as_secs() < 30 { if let Ok(content) = std::fs::read_to_string(&stderr_path) { for line in content.lines() { if debug_flag { @@ -113,9 +113,9 @@ impl CdpBrowser { let stderr_path_for_error = stderr_file.clone(); let process_ext = process.clone(); - // Wait for the port to be discovered (up to 10 seconds) + // Wait for the port to be discovered (up to 30 seconds for slower CI environments) let discovered_port = tokio::task::spawn_blocking(move || { - for _ in 0..100 { + for _ in 0..300 { let port_val = port.lock().map_or(None, |guard| *guard); if let Some(p) = port_val { @@ -157,12 +157,12 @@ impl CdpBrowser { err_msg = format!("{}\n\nChrome process exited early with status: {}", err_msg, status); } else { err_msg = format!( - "{}\n\nChrome process is still running but debugging port was not found after 10 seconds.\n\n\ + "{}\n\nChrome process is still running but debugging port was not found after 30 seconds.\n\n\ Troubleshooting:\n\ - If running in CI, ensure Chrome/Chromium is installed and accessible\n\ - Check if Chrome requires additional flags (e.g., --no-sandbox for Linux CI)\n\ - Verify the temp directory is writable\n\ - - Try running with CHROME_BIN=/usr/bin/google-chrome-stable (or appropriate path)", + - Try using 'config --set-browser' to specify the correct Chrome path", err_msg ); }