Skip to content

Commit b9250d4

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

File tree

5 files changed

+665
-81
lines changed

5 files changed

+665
-81
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 || echo "plotly tests failed"
131+
timeout 600 cargo test -p plotly_static --features geckodriver,webdriver_download -- --nocapture || echo "plotly_static tests failed"
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 || echo "plotly tests failed"
135+
timeout 600 cargo test -p plotly_static --features chromedriver,webdriver_download -- --nocapture || echo "plotly_static tests failed"
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: 26 additions & 2 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; 24] = [
265266
"--headless",
266267
"--no-sandbox",
267268
"--disable-gpu-sandbox",
@@ -283,6 +284,18 @@ const DEFAULT_CAPS_ARRAY: [&str; 20] = [
283284
"--allow-file-access-from-files",
284285
"--no-first-run",
285286
"--no-default-browser-check",
287+
// Additional flags for better PDF generation support
288+
"--disable-backgrounding-occluded-windows",
289+
"--disable-ipc-flooding-protection",
290+
"--enable-logging",
291+
"--v=1",
292+
];
293+
294+
#[cfg(feature = "geckodriver")]
295+
const FIREFOX_DEFAULT_CAPS: [&str; 3] = [
296+
"-headless", // Note: single dash for Firefox
297+
"--no-remote",
298+
"--disable-gpu", // Firefox does support this flag
286299
];
287300

288301
mod template;
@@ -292,6 +305,10 @@ mod webdriver;
292305
#[cfg(target_os = "macos")]
293306
mod macos_tests;
294307

308+
#[cfg(test)]
309+
#[cfg(target_os = "windows")]
310+
mod windows_tests;
311+
295312
/// Supported image formats for static image export.
296313
///
297314
/// This enum defines all the image formats that can be exported from Plotly
@@ -438,7 +455,14 @@ impl Default for StaticExporterBuilder {
438455
webdriver_url: webdriver::WEBDRIVER_URL.to_string(),
439456
spawn_webdriver: true,
440457
offline_mode: false,
441-
webdriver_browser_caps: DEFAULT_CAPS_ARRAY.iter().map(|s| s.to_string()).collect(),
458+
webdriver_browser_caps: {
459+
#[cfg(feature = "chromedriver")]
460+
{ CHROME_DEFAULT_CAPS.iter().map(|s| s.to_string()).collect() }
461+
#[cfg(feature = "geckodriver")]
462+
{ FIREFOX_DEFAULT_CAPS.iter().map(|s| s.to_string()).collect() }
463+
#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))]
464+
{ Vec::new() }
465+
},
442466
}
443467
}
444468
}

0 commit comments

Comments
 (0)