|
70 | 70 | strategy: |
71 | 71 | fail-fast: false |
72 | 72 | matrix: |
73 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
| 73 | + # os: [ubuntu-latest, windows-latest, macos-latest] |
| 74 | + os: [ubuntu-latest, macos-latest] |
74 | 75 | runs-on: ${{ matrix.os }} |
75 | 76 | steps: |
76 | 77 | - name: Setup Chrome |
@@ -145,6 +146,344 @@ jobs: |
145 | 146 | targets: wasm32-unknown-unknown |
146 | 147 | - run: cd ${{ github.workspace }}/examples/wasm-yew/${{ matrix.example }} && cargo build --target wasm32-unknown-unknown |
147 | 148 |
|
| 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 - Test Rust WebDriver spawning |
| 327 | + run: | |
| 328 | + Write-Host "=== Testing Rust WebDriver Spawning ===" |
| 329 | + |
| 330 | + # Set environment variables |
| 331 | + $env:WEBDRIVER_PATH = "${{ steps.setup-chrome.outputs.chromedriver-path }}" |
| 332 | + $env:CHROME_PATH = "${{ steps.setup-chrome.outputs.chrome-path }}" |
| 333 | + $env:RUST_LOG = "debug" |
| 334 | + $env:RUST_BACKTRACE = "1" |
| 335 | + |
| 336 | + Write-Host "Environment variables:" |
| 337 | + Write-Host "WEBDRIVER_PATH: $env:WEBDRIVER_PATH" |
| 338 | + Write-Host "CHROME_PATH: $env:CHROME_PATH" |
| 339 | + |
| 340 | + # Try to compile and run a simple test |
| 341 | + Write-Host "Compiling simple WebDriver test..." |
| 342 | + cd plotly_static |
| 343 | + |
| 344 | + # Create a simple test that just tries to create a WebDriver instance |
| 345 | + Set-Content -Path "test_webdriver_simple.rs" -Value @' |
| 346 | +use plotly_static::StaticExporterBuilder; |
| 347 | + |
| 348 | +fn main() { |
| 349 | + println!("Testing WebDriver creation..."); |
| 350 | + match StaticExporterBuilder::default() |
| 351 | + .spawn_webdriver(true) |
| 352 | + .webdriver_port(4446) |
| 353 | + .build() { |
| 354 | + Ok(mut exporter) => { |
| 355 | + println!("WebDriver created successfully!"); |
| 356 | + println!("Diagnostics: {}", exporter.get_webdriver_diagnostics()); |
| 357 | + } |
| 358 | + Err(e) => { |
| 359 | + println!("WebDriver creation failed: {}", e); |
| 360 | + eprintln!("Error: {}", e); |
| 361 | + } |
| 362 | + } |
| 363 | +} |
| 364 | +'@ |
| 365 | + |
| 366 | + # Try to run the test |
| 367 | + try { |
| 368 | + cargo run --features chromedriver test_webdriver_simple.rs |
| 369 | + } catch { |
| 370 | + Write-Host "Simple WebDriver test failed: $_" |
| 371 | + } |
| 372 | + |
| 373 | + Write-Host "================================" |
| 374 | + |
| 375 | + - name: Debug - Pre-update cargo index |
| 376 | + run: | |
| 377 | + Write-Host "=== Pre-update Cargo Index Check ===" |
| 378 | + Write-Host "Current cargo index status:" |
| 379 | + cargo search --limit 1 plotly 2>&1 | Select-String -Pattern "Updating|Downloading|error" || Write-Host "Index seems up to date" |
| 380 | + Write-Host "================================" |
| 381 | + |
| 382 | + - name: Update cargo index (if needed) |
| 383 | + run: | |
| 384 | + Write-Host "=== Updating Cargo Index ===" |
| 385 | + # Force update the index with a timeout |
| 386 | + $timeout = 300 # 5 minutes |
| 387 | + $job = Start-Job -ScriptBlock { |
| 388 | + cargo update --dry-run |
| 389 | + } |
| 390 | + |
| 391 | + try { |
| 392 | + Wait-Job $job -Timeout $timeout |
| 393 | + $result = Receive-Job $job |
| 394 | + Write-Host "Cargo update result: $result" |
| 395 | + if ($job.State -eq "Completed") { |
| 396 | + Write-Host "Cargo index updated successfully" |
| 397 | + } else { |
| 398 | + Write-Host "Cargo index update timed out, continuing anyway" |
| 399 | + Stop-Job $job |
| 400 | + } |
| 401 | + } catch { |
| 402 | + Write-Host "Cargo index update failed: $_" |
| 403 | + Write-Host "Continuing with test anyway..." |
| 404 | + } finally { |
| 405 | + if ($job) { |
| 406 | + Remove-Job $job -Force -ErrorAction SilentlyContinue |
| 407 | + } |
| 408 | + } |
| 409 | + Write-Host "================================" |
| 410 | + |
| 411 | + - name: Pre-compile dependencies |
| 412 | + run: | |
| 413 | + Write-Host "=== Pre-compiling Dependencies ===" |
| 414 | + |
| 415 | + # Set environment variables |
| 416 | + $env:WEBDRIVER_PATH = "${{ steps.setup-chrome.outputs.chromedriver-path }}" |
| 417 | + $env:CHROME_PATH = "${{ steps.setup-chrome.outputs.chrome-path }}" |
| 418 | + $env:RUST_LOG = "debug" |
| 419 | + $env:RUST_BACKTRACE = "1" |
| 420 | + |
| 421 | + Write-Host "Pre-compiling plotly_static with features..." |
| 422 | + # Note: We don't need webdriver_download feature since chromedriver is already installed |
| 423 | + cargo check --verbose --package plotly_static --features chromedriver |
| 424 | + |
| 425 | + Write-Host "Dependencies pre-compiled successfully" |
| 426 | + |
| 427 | + - name: Run PNG export test with Chrome |
| 428 | + run: | |
| 429 | + Write-Host "=== Starting PNG Export Test ===" |
| 430 | + |
| 431 | + # Try to find chromedriver if action output path doesn't work |
| 432 | + $chromedriverPath = "${{ steps.setup-chrome.outputs.chromedriver-path }}" |
| 433 | + if (-not (Test-Path $chromedriverPath)) { |
| 434 | + Write-Host "Action output chromedriver path not found, searching for alternatives..." |
| 435 | + |
| 436 | + # Try common locations |
| 437 | + $commonPaths = @( |
| 438 | + "C:\Program Files\Google\Chrome\Application\chromedriver.exe", |
| 439 | + "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe", |
| 440 | + "$env:USERPROFILE\AppData\Local\Google\Chrome\Application\chromedriver.exe", |
| 441 | + "$env:PROGRAMFILES\Google\Chrome\Application\chromedriver.exe", |
| 442 | + "$env:PROGRAMFILES(X86)\Google\Chrome\Application\chromedriver.exe" |
| 443 | + ) |
| 444 | + |
| 445 | + foreach ($path in $commonPaths) { |
| 446 | + if (Test-Path $path) { |
| 447 | + Write-Host "Using chromedriver from: $path" |
| 448 | + $chromedriverPath = $path |
| 449 | + break |
| 450 | + } |
| 451 | + } |
| 452 | + } |
| 453 | + |
| 454 | + # Set environment variables |
| 455 | + $env:WEBDRIVER_PATH = $chromedriverPath |
| 456 | + $env:CHROME_PATH = "${{ steps.setup-chrome.outputs.chrome-path }}" |
| 457 | + $env:RUST_LOG = "debug" |
| 458 | + $env:RUST_BACKTRACE = "1" |
| 459 | + |
| 460 | + Write-Host "Environment variables set:" |
| 461 | + Write-Host "WEBDRIVER_PATH: $env:WEBDRIVER_PATH" |
| 462 | + Write-Host "CHROME_PATH: $env:CHROME_PATH" |
| 463 | + Write-Host "RUST_LOG: $env:RUST_LOG" |
| 464 | + Write-Host "RUST_BACKTRACE: $env:RUST_BACKTRACE" |
| 465 | + |
| 466 | + # Verify the paths exist |
| 467 | + if (-not (Test-Path $env:WEBDRIVER_PATH)) { |
| 468 | + Write-Error "Chromedriver not found at: $env:WEBDRIVER_PATH" |
| 469 | + Write-Host "Available chromedriver locations:" |
| 470 | + Get-ChildItem -Path "C:\Program Files\Google\Chrome\Application\" -Name "chromedriver*" -ErrorAction SilentlyContinue |
| 471 | + Get-ChildItem -Path "C:\Program Files (x86)\Google\Chrome\Application\" -Name "chromedriver*" -ErrorAction SilentlyContinue |
| 472 | + exit 1 |
| 473 | + } |
| 474 | + if (-not (Test-Path $env:CHROME_PATH)) { |
| 475 | + Write-Error "Chrome not found at: $env:CHROME_PATH" |
| 476 | + exit 1 |
| 477 | + } |
| 478 | + |
| 479 | + Write-Host "All paths verified, starting cargo test..." |
| 480 | + |
| 481 | + # Run the test directly without PowerShell job complexity |
| 482 | + # Note: We don't need webdriver_download feature since chromedriver is already installed |
| 483 | + cargo test --verbose --package plotly_static --features chromedriver tests::save_png -- --nocapture |
| 484 | + |
| 485 | + Write-Host "=== PNG Export Test Completed ===" |
| 486 | +
|
148 | 487 | build_book: |
149 | 488 | name: Build Book |
150 | 489 | runs-on: ubuntu-latest |
|
0 commit comments