Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/core/cdp/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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
);
}
Expand Down