Skip to content

Commit f655e5a

Browse files
committed
debug ci failures
Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent c39a177 commit f655e5a

File tree

6 files changed

+1031
-82
lines changed

6 files changed

+1031
-82
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,33 @@ jobs:
113113
- name: Test plotly and plotly_static
114114
shell: bash
115115
run: |
116+
echo "=== Platform Information ==="
117+
echo "OS: $(uname -a)"
118+
echo "Architecture: $(uname -m)"
119+
echo "Current directory: $(pwd)"
120+
121+
echo "=== Checking for existing processes ==="
122+
ps aux | grep -E "(chromedriver|geckodriver|firefox|chrome)" || echo "No browser processes found"
123+
124+
echo "=== Checking port availability ==="
125+
netstat -an | grep -E ":(4444|4445|4446|4447|4448|4449|4450)" || echo "No WebDriver ports in use"
126+
127+
echo "=== Running tests ==="
116128
if [ "${{ matrix.browser }}" = "firefox" ]; then
117-
cargo test -p plotly --features static_export_default --lib
118-
cargo test -p plotly_static --features geckodriver,webdriver_download
129+
echo "Testing with Firefox/geckodriver..."
130+
timeout 600 cargo test -p plotly --features static_export_default --lib -- --nocapture
131+
timeout 600 cargo test -p plotly_static --features geckodriver,webdriver_download -- --nocapture
119132
else
120-
cargo test -p plotly --features static_export_chromedriver,static_export_downloader --lib
121-
cargo test -p plotly_static --features chromedriver,webdriver_download
133+
echo "Testing with Chrome/chromedriver..."
134+
timeout 600 cargo test -p plotly --features static_export_chromedriver,static_export_downloader --lib -- --nocapture
135+
timeout 600 cargo test -p plotly_static --features chromedriver,webdriver_download -- --nocapture
122136
fi
137+
138+
echo "=== Cleanup after tests ==="
139+
pkill -f chromedriver || echo "No chromedriver processes to kill"
140+
pkill -f geckodriver || echo "No geckodriver processes to kill"
141+
pkill -f firefox || echo "No firefox processes to kill"
142+
pkill -f chrome || echo "No chrome processes to kill"
123143
124144
test-macos-compatibility:
125145
name: Test macOS Compatibility
@@ -186,6 +206,15 @@ jobs:
186206
187207
echo "=== Testing user data directory management ==="
188208
cargo test -p plotly_static --features chromedriver,webdriver_download --lib macos_tests::macos_tests::test_user_data_directory_management -- --nocapture || echo "User data directory management test failed"
209+
210+
echo "=== Testing PDF debugging ==="
211+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib macos_tests::macos_tests::test_pdf_debugging_macos -- --nocapture || echo "PDF debugging test failed"
212+
213+
echo "=== Testing PDF with alternative flags ==="
214+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib macos_tests::macos_tests::test_pdf_with_alternative_flags -- --nocapture || echo "PDF alternative flags test failed"
215+
216+
echo "=== Testing html2pdf library availability ==="
217+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib macos_tests::macos_tests::test_html2pdf_library_loading -- --nocapture || echo "html2pdf library test failed"
189218
190219
- name: Run all plotly_static tests on macOS
191220
run: |

plotly_static/src/lib.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ use webdriver::WebDriver;
261261

262262
use crate::template::{IMAGE_EXPORT_JS_SCRIPT, PDF_EXPORT_JS_SCRIPT};
263263

264-
const DEFAULT_CAPS_ARRAY: [&str; 20] = [
264+
#[cfg(feature = "chromedriver")]
265+
const CHROME_DEFAULT_CAPS: [&str; 23] = [
265266
"--headless",
266267
"--no-sandbox",
267268
"--disable-gpu-sandbox",
@@ -280,9 +281,19 @@ const DEFAULT_CAPS_ARRAY: [&str; 20] = [
280281
"--password-store=basic",
281282
"--disable-web-security",
282283
"--disable-breakpad",
283-
"--allow-file-access-from-files",
284284
"--no-first-run",
285285
"--no-default-browser-check",
286+
// Additional flags for better PDF generation support
287+
"--disable-backgrounding-occluded-windows",
288+
"--disable-ipc-flooding-protection",
289+
"--enable-logging",
290+
"--v=1",
291+
];
292+
293+
#[cfg(feature = "geckodriver")]
294+
const FIREFOX_DEFAULT_CAPS: [&str; 2] = [
295+
"-headless", // Essential for headless operation (single dash for Firefox)
296+
"--no-remote", // Prevents connecting to existing Firefox instances
286297
];
287298

288299
mod template;
@@ -292,6 +303,10 @@ mod webdriver;
292303
#[cfg(target_os = "macos")]
293304
mod macos_tests;
294305

306+
#[cfg(test)]
307+
#[cfg(target_os = "windows")]
308+
mod windows_tests;
309+
295310
/// Supported image formats for static image export.
296311
///
297312
/// This enum defines all the image formats that can be exported from Plotly
@@ -438,7 +453,14 @@ impl Default for StaticExporterBuilder {
438453
webdriver_url: webdriver::WEBDRIVER_URL.to_string(),
439454
spawn_webdriver: true,
440455
offline_mode: false,
441-
webdriver_browser_caps: DEFAULT_CAPS_ARRAY.iter().map(|s| s.to_string()).collect(),
456+
webdriver_browser_caps: {
457+
#[cfg(feature = "chromedriver")]
458+
{ CHROME_DEFAULT_CAPS.iter().map(|s| s.to_string()).collect() }
459+
#[cfg(feature = "geckodriver")]
460+
{ FIREFOX_DEFAULT_CAPS.iter().map(|s| s.to_string()).collect() }
461+
#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))]
462+
{ Vec::new() }
463+
},
442464
}
443465
}
444466
}

0 commit comments

Comments
 (0)