Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dependabot/npm_and_…
Browse files Browse the repository at this point in the history
…yarn/prettier-3.0.3
  • Loading branch information
nanasess committed Sep 20, 2023
2 parents 59d86cd + 334dc1e commit 03e8de0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ jobs:
- 'now'
chrome_version:
- 'current'
- '114.0.5735.90'
# FIXME https://github.com/nanasess/setup-chromedriver/issues/229
# - '114.0.5735.90'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- if: startsWith(matrix.os, 'ubuntu')
run: echo 'CHROMEAPP=google-chrome' >> $GITHUB_ENV
- if: startsWith(matrix.os, 'macos')
Expand Down Expand Up @@ -83,7 +84,7 @@ jobs:
# - 'master'
- 'now'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- if: startsWith(matrix.os, 'ubuntu')
run: echo 'CHROMEAPP=google-chrome' >> $GITHUB_ENV
- if: startsWith(matrix.os, 'macos')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# - 'master'
- 'now'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- shell: pwsh
run: echo "CHROMEAPP=C:\Program Files\Google\Chrome\Application\chrome.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- run: yarn install --frozen-lockfile
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
# - 'master'
- 'now'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- shell: pwsh
run: echo "CHROMEAPP=C:\Program Files\Google\Chrome\Application\chrome.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- run: yarn install --frozen-lockfile
Expand Down
40 changes: 28 additions & 12 deletions lib/setup-chromedriver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Param(
[string]$version
)

$json_url = "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
$chrome_fullversion = (Get-Item "C:\Program Files\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion

Write-Output "Chrome version: $chrome_fullversion"
Expand All @@ -13,25 +14,40 @@ else
{
$chrome_majorversion = $version.Split(".")[0]
}

if($chrome_majorversion -lt 115)
{
$response = Invoke-WebRequest "http://chromedriver.storage.googleapis.com/LATEST_RELEASE_$chrome_majorversion"
$version = $response.Content
Invoke-WebRequest "https://chromedriver.storage.googleapis.com/$version/chromedriver_win32.zip" -OutFile chromedriver_win32.zip
Expand-Archive -Path chromedriver_win32.zip -DestinationPath C:\SeleniumWebDrivers\ChromeDriver -Force
Remove-Item chromedriver_win32.zip
Return 0
}
else

if([string]::IsNullOrEmpty($version))
{
$version = $chrome_fullversion
}

$arch = "win32"
Write-Output $arch

Write-Output "Downloading $json_url..."
$json = Invoke-WebRequest $json_url -UseBasicParsing | ConvertFrom-Json
$url = $json | Select-Object -ExpandProperty versions | Where-Object { $_.version -eq $version } | Select-Object -ExpandProperty downloads | Select-Object -ExpandProperty chromedriver | Where-Object { $_.platform -eq $arch } | Select-Object -ExpandProperty url
if (!$url)
{
if([string]::IsNullOrEmpty($version))
{
$version = $chrome_fullversion
}
$arch = "win32"
Write-Output $arch
$url = Invoke-WebRequest "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json" -UseBasicParsing | ConvertFrom-Json | Select-Object -ExpandProperty versions | Where-Object { $_.version -eq $version } | Select-Object -ExpandProperty downloads | Select-Object -ExpandProperty chromedriver | Where-Object { $_.platform -eq $arch } | Select-Object -ExpandProperty url
Invoke-WebRequest $url -OutFile chromedriver-win32.zip
Expand-Archive -Path chromedriver-win32.zip -Force
Move-Item -Path .\chromedriver-win32\chromedriver-win32\chromedriver.exe -Destination C:\SeleniumWebDrivers\ChromeDriver -Force
Remove-Item chromedriver-win32.zip
Write-Output "Falling back to latest version of ChromeDriver for $arch"
$version3 = $version.Substring(0, $version.LastIndexOf('.'))
Write-Output "VERSION3 = $version3"
$version = $json | Select-Object -ExpandProperty versions | Where-Object { $_.version -like "$version3.*" } | Select-Object -Last 1 -ExpandProperty version
Write-Output "VERSION = $version"
$url = $json | Select-Object -ExpandProperty versions | Where-Object { $_.version -eq $version } | Select-Object -ExpandProperty downloads | Select-Object -ExpandProperty chromedriver | Where-Object { $_.platform -eq $arch } | Select-Object -ExpandProperty url
}
Write-Output "Installing ChromeDriver $version for $arch"
Write-Output "Downloading $url..."
Invoke-WebRequest $url -OutFile chromedriver-win32.zip
Expand-Archive -Path chromedriver-win32.zip -Force
Move-Item -Path .\chromedriver-win32\chromedriver-win32\chromedriver.exe -Destination C:\SeleniumWebDrivers\ChromeDriver -Force
Remove-Item chromedriver-win32.zip
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"author": "nanasess",
"license": "GPL",
"dependencies": {
"@actions/core": "1.10.0",
"@actions/core": "1.10.1",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@actions/io": "^1.1.3",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# yarn lockfile v1


"@actions/core@1.10.0", "@actions/core@^1.2.6":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f"
integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==
"@actions/core@1.10.1", "@actions/core@^1.2.6":
version "1.10.1"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.1.tgz#61108e7ac40acae95ee36da074fa5850ca4ced8a"
integrity sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==
dependencies:
"@actions/http-client" "^2.0.1"
uuid "^8.3.2"
Expand Down

0 comments on commit 03e8de0

Please sign in to comment.