diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ecb9fe8..07babda2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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') @@ -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') diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7c985c57..fc3ca8da 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -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 @@ -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 diff --git a/lib/setup-chromedriver.ps1 b/lib/setup-chromedriver.ps1 index 486e9afa..4e701812 100644 --- a/lib/setup-chromedriver.ps1 +++ b/lib/setup-chromedriver.ps1 @@ -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" @@ -13,6 +14,7 @@ else { $chrome_majorversion = $version.Split(".")[0] } + if($chrome_majorversion -lt 115) { $response = Invoke-WebRequest "http://chromedriver.storage.googleapis.com/LATEST_RELEASE_$chrome_majorversion" @@ -20,18 +22,32 @@ if($chrome_majorversion -lt 115) 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 diff --git a/package.json b/package.json index c820e5c7..b9d08642 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 572a44ff..80b09e8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"