mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
44
images/windows/scripts/build/Install-MongoDB.ps1
Normal file
44
images/windows/scripts/build/Install-MongoDB.ps1
Normal file
@@ -0,0 +1,44 @@
|
||||
####################################################################################
|
||||
## File: Install-MongoDB.ps1
|
||||
## Desc: Install MongoDB
|
||||
####################################################################################
|
||||
|
||||
# Install mongodb package
|
||||
$toolsetVersion = (Get-ToolsetContent).mongodb.version
|
||||
|
||||
$getMongoReleases = Invoke-WebRequest -Uri "mongodb.com/docs/manual/release-notes/$toolsetVersion/" -UseBasicParsing
|
||||
$TargetReleases = $getMongoReleases.Links.href | Where-Object {$_ -like "#$toolsetVersion*---*"}
|
||||
|
||||
$MinorVersions = @()
|
||||
foreach ($release in $TargetReleases) {
|
||||
if ($release -notlike "*upcoming*") {
|
||||
$pattern = '\d+\.\d+\.\d+'
|
||||
$version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
|
||||
$MinorVersions += $version
|
||||
}
|
||||
}
|
||||
|
||||
$LatestVersion = $MinorVersions[0]
|
||||
|
||||
$installDir = "c:\PROGRA~1\MongoDB"
|
||||
$binaryName = "mongodb-windows-x86_64-$LatestVersion-signed.msi"
|
||||
$downloadURL = "https://fastdl.mongodb.org/windows/$BinaryName"
|
||||
$installArg = "INSTALLLOCATION=$installDir ADDLOCAL=all"
|
||||
Install-Binary -Url $downloadURL -Name $binaryName -ArgumentList ("/q","/i","${env:Temp}\$binaryName", $installArg) -ExpectedSignature (Get-ToolsetContent).mongodb.signature
|
||||
|
||||
|
||||
# Add mongodb to the PATH
|
||||
$mongodbService = "mongodb"
|
||||
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE '$mongodbService'").PathName
|
||||
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
|
||||
Add-MachinePathItem "$mongoBin"
|
||||
|
||||
# Wait for mongodb service running
|
||||
$svc = Get-Service $mongodbService
|
||||
$svc.WaitForStatus('Running','00:01:00')
|
||||
|
||||
# Stop and disable mongodb service
|
||||
Stop-Service -Name $mongodbService
|
||||
Set-Service $mongodbService -StartupType Disabled
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
|
||||
Reference in New Issue
Block a user