Skip to content

Commit

Permalink
Update ExecutingTestsOnLinuxBrowserStackGithubActions.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
raczeja authored Nov 28, 2024
1 parent 3283843 commit 7ecf448
Showing 1 changed file with 37 additions and 25 deletions.
62 changes: 37 additions & 25 deletions ExecutingTestsOnLinuxBrowserStackGithubActions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7ecf448

Please sign in to comment.