1+ # Windows environment setup for plotly static export tests
2+ # This script sets up Chrome, chromedriver, and environment variables for Windows CI
3+
4+ param (
5+ [string ]$ChromeVersion ,
6+ [string ]$ChromePath ,
7+ [string ]$ChromeDriverPath
8+ )
9+
10+ Write-Host " === Setting up Windows environment for static export ==="
11+
12+ # Find chromedriver path
13+ $chromedriverPath = $ChromeDriverPath
14+ if (-not (Test-Path $chromedriverPath )) {
15+ Write-Host " Action output chromedriver path not found, searching for alternatives..."
16+
17+ $commonPaths = @ (
18+ " C:\Program Files\Google\Chrome\Application\chromedriver.exe" ,
19+ " C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" ,
20+ " $env: USERPROFILE \AppData\Local\Google\Chrome\Application\chromedriver.exe" ,
21+ " $env: PROGRAMFILES \Google\Chrome\Application\chromedriver.exe" ,
22+ " $env: PROGRAMFILES (X86)\Google\Chrome\Application\chromedriver.exe"
23+ )
24+
25+ foreach ($path in $commonPaths ) {
26+ if (Test-Path $path ) {
27+ Write-Host " Using chromedriver from: $path "
28+ $chromedriverPath = $path
29+ break
30+ }
31+ }
32+ }
33+
34+ # Find Chrome path
35+ $chromePath = $ChromePath
36+ if (-not (Test-Path $chromePath )) {
37+ # Try the tool cache path first
38+ $toolCachePath = " C:\hostedtoolcache\windows\setup-chrome\chromium\$ChromeVersion \x64\chrome.exe"
39+ if (Test-Path $toolCachePath ) {
40+ $chromePath = $toolCachePath
41+ Write-Host " Using Chrome from setup-chrome installation: $chromePath "
42+ } else {
43+ # Fallback: search for Chrome in the tool cache
44+ $toolCacheDir = " C:\hostedtoolcache\windows\setup-chrome\chromium"
45+ if (Test-Path $toolCacheDir ) {
46+ $chromeExe = Get-ChildItem - Path $toolCacheDir - Recurse - Name " chrome.exe" | Select-Object - First 1
47+ if ($chromeExe ) {
48+ $chromePath = Join-Path $toolCacheDir $chromeExe
49+ Write-Host " Using Chrome from tool cache search: $chromePath "
50+ } else {
51+ $chromePath = " C:\Program Files\Google\Chrome\Application\chrome.exe"
52+ Write-Host " Using system Chrome: $chromePath "
53+ }
54+ } else {
55+ $chromePath = " C:\Program Files\Google\Chrome\Application\chrome.exe"
56+ Write-Host " Using system Chrome: $chromePath "
57+ }
58+ }
59+ }
60+
61+ # Set environment variables
62+ $env: WEBDRIVER_PATH = $chromedriverPath
63+ $env: CHROME_PATH = $chromePath
64+ $env: RUST_LOG = " debug"
65+ $env: RUST_BACKTRACE = " 1"
66+ $env: ANGLE_DEFAULT_PLATFORM = " swiftshader"
67+
68+ Write-Host " Environment variables set:"
69+ Write-Host " WEBDRIVER_PATH: $env: WEBDRIVER_PATH "
70+ Write-Host " CHROME_PATH: $env: CHROME_PATH "
71+ Write-Host " RUST_LOG: $env: RUST_LOG "
72+ Write-Host " RUST_BACKTRACE: $env: RUST_BACKTRACE "
73+
74+ # Verify paths exist
75+ if (-not (Test-Path $env: WEBDRIVER_PATH )) {
76+ Write-Error " Chromedriver executable not found at: $env: WEBDRIVER_PATH "
77+ Write-Host " Available chromedriver locations:"
78+ Get-ChildItem - Path " C:\Program Files\Google\Chrome\Application\" - Name " chromedriver*" - ErrorAction SilentlyContinue
79+ Get-ChildItem - Path " C:\Program Files (x86)\Google\Chrome\Application\" - Name " chromedriver*" - ErrorAction SilentlyContinue
80+ exit 1
81+ }
82+
83+ if (-not (Test-Path $env: CHROME_PATH )) {
84+ Write-Error " Chrome not found at: $env: CHROME_PATH "
85+ exit 1
86+ }
87+
88+ # Test Chrome version
89+ try {
90+ $chromeVersion = & " $env: CHROME_PATH " -- version 2>&1
91+ Write-Host " Chrome version: $chromeVersion "
92+ } catch {
93+ Write-Host " Failed to get Chrome version: $_ "
94+ }
95+
96+ # Test chromedriver version
97+ try {
98+ $chromedriverVersion = & " $env: WEBDRIVER_PATH " -- version 2>&1
99+ Write-Host " Chromedriver version: $chromedriverVersion "
100+ } catch {
101+ Write-Host " Failed to get chromedriver version: $_ "
102+ }
103+
104+ Write-Host " === Windows environment setup completed ==="
0 commit comments