From 7ecf44801bfa5946631ecf5436e8ce001c7f09e3 Mon Sep 17 00:00:00 2001 From: Jakub Raczek Date: Thu, 28 Nov 2024 12:22:17 +0100 Subject: [PATCH] Update ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 --- ...gTestsOnLinuxBrowserStackGithubActions.ps1 | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 b/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 index 230c8aaf..56ed3c29 100644 --- a/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 +++ b/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 @@ -5,31 +5,43 @@ $Env:ASPNETCORE_ENVIRONMENT="Linux" echo $Env:ASPNETCORE_ENVIRONMENT -CHROMEVER=$(google-chrome --product-version | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") \ - && major=$(echo "$CHROMEVER" | cut -d. -f 1) \ - && minor=$(echo "$CHROMEVER" | cut -d. -f 2) \ - && build=$(echo "$CHROMEVER" | cut -d. -f 3) \ - && if [ "$major" -ge 115 ]; then \ - re=^${major}\.${minor}\.${build}\.; \ - url=$(wget --quiet -O- https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json | \ - jq -r '.versions[] | select(.version | test("'"${re}"'")) | .downloads.chromedriver[] | select(.platform == "linux64") | .url' | \ - tail -1); \ - if [ -z "$url" ]; then \ - echo "Failed finding latest release matching /${re}/"; \ - exit 1; \ - fi; \ - rel=$(echo "$url" | sed -nre 's!.*/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/.*!\1!p'); \ - srcfile=chromedriver-linux64/chromedriver; \ - else \ - short=$(echo "$build" | sed -re 's/\.[0-9]+$//'); \ - rel=$(wget --quiet -O- "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${short}"); \ - url=https://chromedriver.storage.googleapis.com/${rel}/chromedriver_linux64.zip; \ - srcfile=chromedriver; \ - fi \ - && wget -q --continue -P /chromedriver "$url" \ - && unzip /chromedriver/chromedriver* -d /chromedriver \ - && mv /chromedriver/$srcfile /usr/local/bin/chromedriver \ - && chmod +x /usr/local/bin/chromedriver +$chromeVersion = (& google-chrome --product-version) -match "\d+\.\d+\.\d+\.\d+" + +if ($chromeVersion) { + $major = $Matches[0].Split('.')[0] + $minor = $Matches[0].Split('.')[1] + $build = $Matches[0].Split('.')[2] + + if ($major -ge 115) { + $re = "$major\.$minor\.$build\." + $url = (Invoke-WebRequest -Uri "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json").Content | + ConvertFrom-Json | + Select-Object -ExpandProperty versions | + Where-Object { $_.version -match $re } | + Select-Object -ExpandProperty downloads | + Where-Object { $_.platform -eq "linux64" } | + Select-Object -ExpandProperty url | + Select-Object -Last 1 + + if (-not $url) { + Write-Host "Failed finding latest release matching /$re/" + exit 1 + } + + $rel = $url -replace '.*/(\d+\.\d+\.\d+\.\d+)/.*', '$1' + $srcfile = "chromedriver-linux64/chromedriver" + } else { + $short = $build -replace '\.\d+$', '' + $rel = Invoke-WebRequest -Uri "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$short" -UseBasicParsing + $url = "https://chromedriver.storage.googleapis.com/$rel/chromedriver_linux64.zip" + $srcfile = "chromedriver" + } + + Invoke-WebRequest -Uri $url -OutFile "/chromedriver/chromedriver.zip" + Expand-Archive -Path "/chromedriver/chromedriver.zip" -DestinationPath "/chromedriver" + Move-Item -Path "/chromedriver/$srcfile" -Destination "/usr/local/bin/chromedriver" + icacls "/usr/local/bin/chromedriver" /grant Everyone:F +} .\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net8.0" "appsettings.Linux.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|/usr/local/bin/" -logValues -json