Skip to content

Commit 200e24f

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

File tree

6 files changed

+1165
-95
lines changed

6 files changed

+1165
-95
lines changed

.github/workflows/ci.yml

Lines changed: 146 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,46 @@ 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+
echo "=== Firefox Environment Check ==="
131+
echo "Firefox version: $(firefox --version 2>/dev/null || echo 'Firefox not found in PATH')"
132+
echo "geckodriver version: $(geckodriver --version 2>/dev/null || echo 'geckodriver not found in PATH')"
133+
echo "Available memory: $(free -h 2>/dev/null || echo 'free command not available')"
134+
echo "Available disk space: $(df -h . 2>/dev/null || echo 'df command not available')"
135+
136+
echo "=== Testing plotly with Firefox ==="
137+
timeout 600 cargo test -p plotly --features static_export_default --lib -- --nocapture
138+
139+
echo "=== Testing plotly_static with Firefox ==="
140+
timeout 600 cargo test -p plotly_static --features geckodriver,webdriver_download -- --nocapture
119141
else
120-
cargo test -p plotly --features static_export_chromedriver,static_export_downloader --lib
121-
cargo test -p plotly_static --features chromedriver,webdriver_download
142+
echo "Testing with Chrome/chromedriver..."
143+
echo "=== Chrome Environment Check ==="
144+
echo "Chrome version: $(google-chrome --version 2>/dev/null || echo 'Chrome not found in PATH')"
145+
echo "chromedriver version: $(chromedriver --version 2>/dev/null || echo 'chromedriver not found in PATH')"
146+
147+
timeout 600 cargo test -p plotly --features static_export_chromedriver,static_export_downloader --lib -- --nocapture
148+
timeout 600 cargo test -p plotly_static --features chromedriver,webdriver_download -- --nocapture
122149
fi
150+
151+
echo "=== Cleanup after tests ==="
152+
pkill -f chromedriver || echo "No chromedriver processes to kill"
153+
pkill -f geckodriver || echo "No geckodriver processes to kill"
154+
pkill -f firefox || echo "No firefox processes to kill"
155+
pkill -f chrome || echo "No chrome processes to kill"
123156
124157
test-macos-compatibility:
125158
name: Test macOS Compatibility
@@ -186,6 +219,15 @@ jobs:
186219
187220
echo "=== Testing user data directory management ==="
188221
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"
222+
223+
echo "=== Testing PDF debugging ==="
224+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib macos_tests::macos_tests::test_pdf_debugging_macos -- --nocapture || echo "PDF debugging test failed"
225+
226+
echo "=== Testing PDF with alternative flags ==="
227+
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"
228+
229+
echo "=== Testing html2pdf library availability ==="
230+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib macos_tests::macos_tests::test_html2pdf_library_loading -- --nocapture || echo "html2pdf library test failed"
189231
190232
- name: Run all plotly_static tests on macOS
191233
run: |
@@ -214,6 +256,106 @@ jobs:
214256
pkill -f chromedriver || echo "No chromedriver processes to kill"
215257
pkill -f "Google Chrome" || echo "No Chrome processes to kill"
216258
259+
test-windows-compatibility:
260+
name: Test Windows Compatibility
261+
runs-on: windows-latest
262+
steps:
263+
- uses: actions/checkout@v4
264+
265+
- name: Setup Chrome
266+
uses: browser-actions/setup-chrome@v1
267+
with:
268+
chrome-version: 'latest'
269+
install-chromedriver: true
270+
271+
- uses: dtolnay/rust-toolchain@stable
272+
273+
- name: Test Chrome and chromedriver installation
274+
shell: cmd
275+
run: |
276+
echo "=== System Information ==="
277+
echo "OS: %OS%"
278+
echo "Architecture: %PROCESSOR_ARCHITECTURE%"
279+
echo "PATH: %PATH%"
280+
echo "Current user: %USERNAME%"
281+
echo "Home directory: %USERPROFILE%"
282+
283+
echo "=== Chrome Installation Check ==="
284+
dir "C:\Program Files\Google\Chrome\Application\chrome.exe" 2>nul || echo "Chrome not found in Program Files"
285+
where google-chrome 2>nul || echo "Chrome not found in PATH"
286+
google-chrome --version 2>nul || echo "Chrome version check failed"
287+
288+
echo "=== chromedriver Installation Check ==="
289+
chromedriver --version 2>nul || echo "chromedriver not found in PATH"
290+
dir "C:\Program Files\Google\Chrome\Application\chromedriver.exe" 2>nul || echo "chromedriver not found in Program Files"
291+
292+
echo "=== Environment Variables ==="
293+
echo "WEBDRIVER_PATH: %WEBDRIVER_PATH%"
294+
echo "CHROMEDRIVER_PATH: %CHROMEDRIVER_PATH%"
295+
echo "CHROME_PATH: %CHROME_PATH%"
296+
297+
- name: Run Windows-specific tests
298+
shell: cmd
299+
run: |
300+
echo "Running Windows compatibility tests..."
301+
echo "Current directory: %CD%"
302+
echo "Rust version: %RUST_VERSION%"
303+
echo "Cargo version: %CARGO_VERSION%"
304+
305+
echo "=== Testing Chrome installation ==="
306+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_chrome_installation -- --nocapture
307+
308+
echo "=== Testing chromedriver installation ==="
309+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_chromedriver_installation -- --nocapture
310+
311+
echo "=== Testing static exporter creation ==="
312+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_static_exporter_creation_windows -- --nocapture
313+
314+
echo "=== Testing basic PNG export ==="
315+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_basic_png_export_windows -- --nocapture
316+
317+
echo "=== Testing Windows Chrome flags ==="
318+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_windows_chrome_flags -- --nocapture
319+
320+
echo "=== Testing user data directory management ==="
321+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_user_data_directory_management -- --nocapture
322+
323+
echo "=== Testing PDF debugging ==="
324+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_pdf_debugging_windows -- --nocapture
325+
326+
echo "=== Testing PDF with alternative flags ==="
327+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib windows_tests::windows_tests::test_pdf_with_alternative_flags -- --nocapture
328+
329+
- name: Run all plotly_static tests on Windows
330+
shell: cmd
331+
run: |
332+
echo "Running all plotly_static tests on Windows..."
333+
echo "Checking for existing chromedriver processes before tests..."
334+
tasklist /FI "IMAGENAME eq chromedriver.exe" 2>nul || echo "No chromedriver processes found"
335+
336+
echo "=== Running tests ==="
337+
cargo test -p plotly_static --features chromedriver,webdriver_download --lib -- --nocapture
338+
339+
echo "Checking for chromedriver processes after tests..."
340+
tasklist /FI "IMAGENAME eq chromedriver.exe" 2>nul || echo "No chromedriver processes found"
341+
342+
- name: Test plotly with static export on Windows
343+
shell: cmd
344+
run: |
345+
echo "Testing plotly with static export on Windows..."
346+
echo "Checking for port conflicts before tests..."
347+
netstat -an | findstr ":4444" || echo "Port 4444 is free"
348+
netstat -an | findstr ":4445" || echo "Port 4445 is free"
349+
netstat -an | findstr ":4446" || echo "Port 4446 is free"
350+
netstat -an | findstr ":4447" || echo "Port 4447 is free"
351+
352+
echo "=== Running plotly static export tests ==="
353+
cargo test -p plotly --features static_export_chromedriver,static_export_downloader --lib -- --nocapture
354+
355+
echo "Cleaning up after tests..."
356+
taskkill /F /IM chromedriver.exe 2>nul || echo "No chromedriver processes to kill"
357+
taskkill /F /IM chrome.exe 2>nul || echo "No Chrome processes to kill"
358+
217359
code-coverage:
218360
name: Code Coverage
219361
runs-on: ubuntu-latest

plotly_static/src/lib.rs

Lines changed: 37 additions & 4 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,20 @@ 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+
{
459+
CHROME_DEFAULT_CAPS.iter().map(|s| s.to_string()).collect()
460+
}
461+
#[cfg(feature = "geckodriver")]
462+
{
463+
FIREFOX_DEFAULT_CAPS.iter().map(|s| s.to_string()).collect()
464+
}
465+
#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))]
466+
{
467+
Vec::new()
468+
}
469+
},
442470
}
443471
}
444472
}
@@ -995,7 +1023,12 @@ impl StaticExporter {
9951023
.as_ref()
9961024
.expect("user_data_dir should be set");
9971025
let mut browser_args = self.webdriver_browser_caps.clone();
998-
browser_args.push(format!("--user-data-dir={}", user_data_dir.display()));
1026+
1027+
// Only add --user-data-dir for Chrome (Firefox doesn't support this flag)
1028+
#[cfg(feature = "chromedriver")]
1029+
{
1030+
browser_args.push(format!("--user-data-dir={}", user_data_dir.display()));
1031+
}
9991032

10001033
browser_opts.insert("args".to_string(), serde_json::json!(browser_args));
10011034

0 commit comments

Comments
 (0)