Skip to content

Commit 34a7fb5

Browse files
committed
test windows ci
Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent d6f822f commit 34a7fb5

File tree

2 files changed

+302
-2
lines changed

2 files changed

+302
-2
lines changed

.github/workflows/ci.yml

Lines changed: 291 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73-
os: [ubuntu-latest, windows-latest, macos-latest]
73+
# os: [ubuntu-latest, windows-latest, macos-latest]
74+
os: [ubuntu-latest, macos-latest]
7475
runs-on: ${{ matrix.os }}
7576
steps:
7677
- name: Setup Chrome
@@ -145,6 +146,295 @@ jobs:
145146
targets: wasm32-unknown-unknown
146147
- run: cd ${{ github.workspace }}/examples/wasm-yew/${{ matrix.example }} && cargo build --target wasm32-unknown-unknown
147148

149+
test_static_export_chrome:
150+
name: Test Static Export with Chrome (Windows)
151+
runs-on: windows-latest
152+
timeout-minutes: 30
153+
steps:
154+
- uses: actions/checkout@v4
155+
156+
- name: Setup Chrome and chromedriver
157+
id: setup-chrome
158+
uses: browser-actions/setup-chrome@v1
159+
with:
160+
chrome-version: 'latest'
161+
install-chromedriver: true
162+
163+
- uses: dtolnay/rust-toolchain@stable
164+
165+
- name: Cache cargo registry
166+
uses: actions/cache@v4
167+
with:
168+
path: |
169+
~/.cargo/registry/index/
170+
~/.cargo/registry/cache/
171+
~/.cargo/git/db/
172+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
173+
restore-keys: |
174+
${{ runner.os }}-cargo-registry-
175+
176+
- name: Debug - Show setup-chrome outputs
177+
run: |
178+
Write-Host "=== Setup Chrome Action Outputs ==="
179+
Write-Host "chrome-version: ${{ steps.setup-chrome.outputs.chrome-version }}"
180+
Write-Host "chrome-path: ${{ steps.setup-chrome.outputs.chrome-path }}"
181+
Write-Host "chromedriver-version: ${{ steps.setup-chrome.outputs.chromedriver-version }}"
182+
Write-Host "chromedriver-path: ${{ steps.setup-chrome.outputs.chromedriver-path }}"
183+
Write-Host "================================"
184+
185+
- name: Debug - System information
186+
run: |
187+
Write-Host "=== System Information ==="
188+
Write-Host "OS Version: $(Get-ComputerInfo | Select-Object -ExpandProperty WindowsProductName)"
189+
Write-Host "Architecture: $(Get-ComputerInfo | Select-Object -ExpandProperty OsArchitecture)"
190+
Write-Host "Available memory: $((Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory / 1MB) MB"
191+
Write-Host "=========================="
192+
193+
- name: Debug - Check Chrome and chromedriver installation
194+
run: |
195+
Write-Host "=== Chrome and Chromedriver Check ==="
196+
197+
# Check if Chrome is in PATH
198+
try {
199+
$chromeVersion = & chrome.exe --version 2>$null
200+
Write-Host "Chrome in PATH: $chromeVersion"
201+
} catch {
202+
Write-Host "Chrome not found in PATH"
203+
}
204+
205+
# Check if chromedriver is in PATH
206+
try {
207+
$chromedriverVersion = & chromedriver.exe --version 2>$null
208+
Write-Host "Chromedriver in PATH: $chromedriverVersion"
209+
} catch {
210+
Write-Host "Chromedriver not found in PATH"
211+
}
212+
213+
# Check specific paths from action outputs
214+
$chromePath = "${{ steps.setup-chrome.outputs.chrome-path }}"
215+
$chromedriverPath = "${{ steps.setup-chrome.outputs.chromedriver-path }}"
216+
217+
Write-Host "Chrome path from action: $chromePath"
218+
Write-Host "Chromedriver path from action: $chromedriverPath"
219+
220+
if (Test-Path $chromePath) {
221+
Write-Host "Chrome file exists: $(Get-Item $chromePath | Select-Object -ExpandProperty FullName)"
222+
Write-Host "Chrome file size: $((Get-Item $chromePath).Length) bytes"
223+
} else {
224+
Write-Host "Chrome file does not exist at specified path"
225+
}
226+
227+
if (Test-Path $chromedriverPath) {
228+
Write-Host "Chromedriver file exists: $(Get-Item $chromedriverPath | Select-Object -ExpandProperty FullName)"
229+
Write-Host "Chromedriver file size: $((Get-Item $chromedriverPath).Length) bytes"
230+
231+
# Test if chromedriver is executable
232+
try {
233+
$testResult = & $chromedriverPath --version 2>&1
234+
Write-Host "Chromedriver executable test: $testResult"
235+
} catch {
236+
Write-Host "Chromedriver executable test failed: $_"
237+
}
238+
} else {
239+
Write-Host "Chromedriver file does not exist at specified path"
240+
}
241+
242+
# Try to find chromedriver in common locations
243+
Write-Host "=== Searching for chromedriver in common locations ==="
244+
$commonPaths = @(
245+
"C:\Program Files\Google\Chrome\Application\chromedriver.exe",
246+
"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe",
247+
"$env:USERPROFILE\AppData\Local\Google\Chrome\Application\chromedriver.exe",
248+
"$env:PROGRAMFILES\Google\Chrome\Application\chromedriver.exe",
249+
"$env:PROGRAMFILES(X86)\Google\Chrome\Application\chromedriver.exe"
250+
)
251+
252+
foreach ($path in $commonPaths) {
253+
if (Test-Path $path) {
254+
Write-Host "Found chromedriver at: $path"
255+
try {
256+
$version = & $path --version 2>&1
257+
Write-Host " Version: $version"
258+
} catch {
259+
Write-Host " Version check failed: $_"
260+
}
261+
}
262+
}
263+
264+
Write-Host "================================"
265+
266+
- name: Debug - Check Rust toolchain and dependencies
267+
run: |
268+
Write-Host "=== Rust Toolchain Check ==="
269+
rustc --version
270+
cargo --version
271+
Write-Host "Current directory: $(Get-Location)"
272+
Write-Host "Workspace contents:"
273+
Get-ChildItem -Name | Sort-Object
274+
Write-Host "=========================="
275+
276+
- name: Debug - Check plotly_static package
277+
run: |
278+
Write-Host "=== Plotly Static Package Check ==="
279+
cd plotly_static
280+
Write-Host "Package contents:"
281+
Get-ChildItem -Name | Sort-Object
282+
Write-Host "Cargo.toml contents:"
283+
Get-Content Cargo.toml
284+
Write-Host "================================"
285+
286+
- name: Debug - Test chromedriver functionality
287+
run: |
288+
Write-Host "=== Testing Chromedriver Functionality ==="
289+
290+
# Test if chromedriver is in PATH and working
291+
try {
292+
$chromedriverVersion = & chromedriver.exe --version 2>&1
293+
Write-Host "Chromedriver in PATH: $chromedriverVersion"
294+
295+
# Try to start chromedriver in background
296+
Write-Host "Testing chromedriver startup..."
297+
$process = Start-Process -FilePath "chromedriver.exe" -ArgumentList "--port=4444" -PassThru -WindowStyle Hidden
298+
Start-Sleep -Seconds 3
299+
300+
# Check if it's running
301+
$isRunning = Get-Process -Name "chromedriver" -ErrorAction SilentlyContinue
302+
if ($isRunning) {
303+
Write-Host "Chromedriver started successfully, PID: $($process.Id)"
304+
305+
# Test WebDriver status endpoint
306+
try {
307+
$response = Invoke-WebRequest -Uri "http://localhost:4444/status" -TimeoutSec 5
308+
Write-Host "WebDriver status response: $($response.StatusCode)"
309+
Write-Host "Response content: $($response.Content)"
310+
} catch {
311+
Write-Host "WebDriver status check failed: $_"
312+
}
313+
314+
# Stop the process
315+
Stop-Process -Id $process.Id -Force
316+
Write-Host "Chromedriver stopped"
317+
} else {
318+
Write-Host "Chromedriver failed to start"
319+
}
320+
} catch {
321+
Write-Host "Chromedriver test failed: $_"
322+
}
323+
324+
Write-Host "================================"
325+
326+
- name: Debug - Pre-update cargo index
327+
run: |
328+
Write-Host "=== Pre-update Cargo Index Check ==="
329+
Write-Host "Current cargo index status:"
330+
cargo search --limit 1 plotly 2>&1 | Select-String -Pattern "Updating|Downloading|error" || Write-Host "Index seems up to date"
331+
Write-Host "================================"
332+
333+
- name: Update cargo index (if needed)
334+
run: |
335+
Write-Host "=== Updating Cargo Index ==="
336+
# Force update the index with a timeout
337+
$timeout = 300 # 5 minutes
338+
$job = Start-Job -ScriptBlock {
339+
cargo update --dry-run
340+
}
341+
342+
try {
343+
Wait-Job $job -Timeout $timeout
344+
$result = Receive-Job $job
345+
Write-Host "Cargo update result: $result"
346+
if ($job.State -eq "Completed") {
347+
Write-Host "Cargo index updated successfully"
348+
} else {
349+
Write-Host "Cargo index update timed out, continuing anyway"
350+
Stop-Job $job
351+
}
352+
} catch {
353+
Write-Host "Cargo index update failed: $_"
354+
Write-Host "Continuing with test anyway..."
355+
} finally {
356+
if ($job) {
357+
Remove-Job $job -Force -ErrorAction SilentlyContinue
358+
}
359+
}
360+
Write-Host "================================"
361+
362+
- name: Pre-compile dependencies
363+
run: |
364+
Write-Host "=== Pre-compiling Dependencies ==="
365+
366+
# Set environment variables
367+
$env:WEBDRIVER_PATH = "${{ steps.setup-chrome.outputs.chromedriver-path }}"
368+
$env:CHROME_PATH = "${{ steps.setup-chrome.outputs.chrome-path }}"
369+
$env:RUST_LOG = "debug"
370+
$env:RUST_BACKTRACE = "1"
371+
372+
Write-Host "Pre-compiling plotly_static with features..."
373+
# Note: We don't need webdriver_download feature since chromedriver is already installed
374+
cargo check --verbose --package plotly_static --features chromedriver
375+
376+
Write-Host "Dependencies pre-compiled successfully"
377+
378+
- name: Run PNG export test with Chrome
379+
run: |
380+
Write-Host "=== Starting PNG Export Test ==="
381+
382+
# Try to find chromedriver if action output path doesn't work
383+
$chromedriverPath = "${{ steps.setup-chrome.outputs.chromedriver-path }}"
384+
if (-not (Test-Path $chromedriverPath)) {
385+
Write-Host "Action output chromedriver path not found, searching for alternatives..."
386+
387+
# Try common locations
388+
$commonPaths = @(
389+
"C:\Program Files\Google\Chrome\Application\chromedriver.exe",
390+
"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe",
391+
"$env:USERPROFILE\AppData\Local\Google\Chrome\Application\chromedriver.exe",
392+
"$env:PROGRAMFILES\Google\Chrome\Application\chromedriver.exe",
393+
"$env:PROGRAMFILES(X86)\Google\Chrome\Application\chromedriver.exe"
394+
)
395+
396+
foreach ($path in $commonPaths) {
397+
if (Test-Path $path) {
398+
Write-Host "Using chromedriver from: $path"
399+
$chromedriverPath = $path
400+
break
401+
}
402+
}
403+
}
404+
405+
# Set environment variables
406+
$env:WEBDRIVER_PATH = $chromedriverPath
407+
$env:CHROME_PATH = "${{ steps.setup-chrome.outputs.chrome-path }}"
408+
$env:RUST_LOG = "debug"
409+
$env:RUST_BACKTRACE = "1"
410+
411+
Write-Host "Environment variables set:"
412+
Write-Host "WEBDRIVER_PATH: $env:WEBDRIVER_PATH"
413+
Write-Host "CHROME_PATH: $env:CHROME_PATH"
414+
Write-Host "RUST_LOG: $env:RUST_LOG"
415+
Write-Host "RUST_BACKTRACE: $env:RUST_BACKTRACE"
416+
417+
# Verify the paths exist
418+
if (-not (Test-Path $env:WEBDRIVER_PATH)) {
419+
Write-Error "Chromedriver not found at: $env:WEBDRIVER_PATH"
420+
Write-Host "Available chromedriver locations:"
421+
Get-ChildItem -Path "C:\Program Files\Google\Chrome\Application\" -Name "chromedriver*" -ErrorAction SilentlyContinue
422+
Get-ChildItem -Path "C:\Program Files (x86)\Google\Chrome\Application\" -Name "chromedriver*" -ErrorAction SilentlyContinue
423+
exit 1
424+
}
425+
if (-not (Test-Path $env:CHROME_PATH)) {
426+
Write-Error "Chrome not found at: $env:CHROME_PATH"
427+
exit 1
428+
}
429+
430+
Write-Host "All paths verified, starting cargo test..."
431+
432+
# Run the test directly without PowerShell job complexity
433+
# Note: We don't need webdriver_download feature since chromedriver is already installed
434+
cargo test --verbose --package plotly_static --features chromedriver tests::save_png -- --nocapture
435+
436+
Write-Host "=== PNG Export Test Completed ==="
437+
148438
build_book:
149439
name: Build Book
150440
runs-on: ubuntu-latest

plotly_static/build.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ use webdriver_downloader::prelude::*;
1212
#[cfg(all(feature = "geckodriver", feature = "chromedriver"))]
1313
compile_error!("Only one of 'geckodriver' or 'chromedriver' features can be enabled at a time.");
1414

15+
// Enforce that at least one driver feature is enabled
16+
#[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))]
17+
compile_error!("At least one of 'geckodriver' or 'chromedriver' features must be enabled.");
18+
1519
// Define the WEBDRIVER_BIN constant based on the enabled feature
1620
#[cfg(feature = "geckodriver")]
1721
const WEBDRIVER_BIN: &str = "geckodriver";
@@ -64,7 +68,7 @@ fn user_bin_dir() -> PathBuf {
6468
fn is_webdriver_available(env_var: &str, executable_name: &str) -> bool {
6569
// First check environment variable path
6670
if let Ok(path) = env::var(env_var) {
67-
let exe_path = if cfg!(windows) && !path.to_lowercase().ends_with(".exe") {
71+
let exe_path = if cfg!(target_os = "windows") && !path.to_lowercase().ends_with(".exe") {
6872
format!("{path}{DRIVER_EXT}")
6973
} else {
7074
path
@@ -332,6 +336,12 @@ fn main() -> Result<()> {
332336
};
333337
setup_driver(&config)?;
334338
}
339+
340+
// Handle case where no specific driver feature is enabled
341+
#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))]
342+
{
343+
println!("cargo::warning=No specific driver feature enabled, skipping driver setup");
344+
}
335345
} else {
336346
let msg = format!("'webdriver_download' feature disabled. Please install a {GECKODRIVER_PATH_ENV} or {CHROMEDRIVER_PATH_ENV} version manually and make the environment variable 'WEBDRIVER_PATH' point to it.");
337347
println!("cargo::warning={msg}");

0 commit comments

Comments
 (0)