mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-18 07:46:45 +00:00
[Windows] Fix chromedriver download process (#7942)
This commit is contained in:
committed by
GitHub
parent
a5632eb5f2
commit
654d8a6688
@@ -451,11 +451,13 @@ function Extract-7Zip {
|
|||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$Path,
|
[string]$Path,
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$DestinationPath
|
[string]$DestinationPath,
|
||||||
|
[ValidateSet("x", "e")]
|
||||||
|
[char]$ExtractMethod = "x"
|
||||||
)
|
)
|
||||||
|
|
||||||
Write-Host "Expand archive '$PATH' to '$DestinationPath' directory"
|
Write-Host "Expand archive '$PATH' to '$DestinationPath' directory"
|
||||||
7z.exe x "$Path" -o"$DestinationPath" -y | Out-Null
|
7z.exe $ExtractMethod "$Path" -o"$DestinationPath" -y | Out-Null
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0)
|
if ($LASTEXITCODE -ne 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,23 +48,33 @@ if (-not (Test-Path -Path $ChromeDriverPath))
|
|||||||
New-Item -Path $ChromeDriverPath -ItemType Directory -Force
|
New-Item -Path $ChromeDriverPath -ItemType Directory -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Get the Chrome WebDriver version..."
|
Write-Host "Get the Chrome WebDriver download URL..."
|
||||||
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
|
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
|
||||||
$ChromePath = (Get-ItemProperty "$RegistryPath\chrome.exe").'(default)'
|
$ChromePath = (Get-ItemProperty "$RegistryPath\chrome.exe").'(default)'
|
||||||
[version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion
|
[version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion
|
||||||
$ChromeDriverVersionUrl = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$($ChromeVersion.Major).$($ChromeVersion.Minor).$($ChromeVersion.Build)"
|
$ChromeBuild = "$($ChromeVersion.Major).$($ChromeVersion.Minor).$($ChromeVersion.Build)"
|
||||||
|
$ChromeDriverVersionsUrl = "https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json"
|
||||||
|
|
||||||
$ChromeDriverVersionFile = Start-DownloadWithRetry -Url $ChromeDriverVersionUrl -Name "versioninfo.txt" -DownloadPath $ChromeDriverPath
|
Write-Host "Chrome version is $ChromeVersion"
|
||||||
|
$ChromeDriverVersions = Invoke-RestMethod -Uri $ChromeDriverVersionsUrl
|
||||||
|
$ChromeDriverVersion = $ChromeDriverVersions.builds.$ChromeBuild
|
||||||
|
|
||||||
Write-Host "Download Chrome WebDriver..."
|
if (-not ($ChromeDriverVersion)) {
|
||||||
$ChromeDriverVersion = Get-Content -Path $ChromeDriverVersionFile
|
$availableVersions = $ChromeDriverVersions.builds | Get-Member | Select-Object -ExpandProperty Name
|
||||||
$ChromeDriverArchName = "chromedriver_win32.zip"
|
Write-Host "Available chromedriver builds are $availableVersions"
|
||||||
$ChromeDriverZipDownloadUrl = "https://chromedriver.storage.googleapis.com/${ChromeDriverVersion}/${ChromeDriverArchName}"
|
Throw "Can't determine chromedriver version that matches chrome build $ChromeBuild"
|
||||||
|
}
|
||||||
|
|
||||||
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl -Name $ChromeDriverArchName
|
$ChromeDriverVersion.version | Out-File -FilePath "$ChromeDriverPath\versioninfo.txt" -Force;
|
||||||
|
|
||||||
Write-Host "Expand Chrome WebDriver archive..."
|
Write-Host "Chrome WebDriver version to install is $($ChromeDriverVersion.version)"
|
||||||
Extract-7Zip -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath
|
$ChromeDriverZipDownloadUrl = ($ChromeDriverVersion.downloads.chromedriver | Where-Object platform -eq "win64").url
|
||||||
|
|
||||||
|
Write-Host "Download Chrome WebDriver from $ChromeDriverZipDownloadUrl..."
|
||||||
|
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl
|
||||||
|
|
||||||
|
Write-Host "Expand Chrome WebDriver archive (without using directory names)..."
|
||||||
|
Extract-7Zip -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -ExtractMethod "e"
|
||||||
|
|
||||||
Write-Host "Setting the environment variables..."
|
Write-Host "Setting the environment variables..."
|
||||||
setx ChromeWebDriver "$ChromeDriverPath" /M
|
setx ChromeWebDriver "$ChromeDriverPath" /M
|
||||||
|
|||||||
Reference in New Issue
Block a user