mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Merge remote-tracking branch 'upstream/main' into main
This commit is contained in:
@@ -52,7 +52,8 @@ jobs:
|
|||||||
inputs:
|
inputs:
|
||||||
targetType: 'filePath'
|
targetType: 'filePath'
|
||||||
filePath: ./images.CI/macos/select-datastore.ps1
|
filePath: ./images.CI/macos/select-datastore.ps1
|
||||||
arguments: -VIServer "$(vcenter-server-v2)" `
|
arguments: -VMName "$(VirtualMachineName)" `
|
||||||
|
-VIServer "$(vcenter-server-v2)" `
|
||||||
-VIUserName "$(vcenter-username-v2)" `
|
-VIUserName "$(vcenter-username-v2)" `
|
||||||
-VIPassword "$(vcenter-password-v2)"
|
-VIPassword "$(vcenter-password-v2)"
|
||||||
|
|
||||||
@@ -121,8 +122,8 @@ jobs:
|
|||||||
condition: always()
|
condition: always()
|
||||||
|
|
||||||
- task: PowerShell@2
|
- task: PowerShell@2
|
||||||
displayName: 'Move vm to cold storage'
|
displayName: 'Move vm to cold storage and clear datastore tag'
|
||||||
condition: succeededOrFailed()
|
condition: always()
|
||||||
inputs:
|
inputs:
|
||||||
targetType: 'filePath'
|
targetType: 'filePath'
|
||||||
filePath: ./images.CI/macos/move-vm.ps1
|
filePath: ./images.CI/macos/move-vm.ps1
|
||||||
|
|||||||
@@ -48,6 +48,13 @@ Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
|||||||
# Connection to a vCenter Server system
|
# Connection to a vCenter Server system
|
||||||
Connect-VCServer
|
Connect-VCServer
|
||||||
|
|
||||||
|
# Clear previously assigned tag with VM Name
|
||||||
|
try {
|
||||||
|
Remove-Tag $VMName -Confirm:$false
|
||||||
|
} catch {
|
||||||
|
Write-Host "Tag with $VMName doesn't exist"
|
||||||
|
}
|
||||||
|
|
||||||
$vm = Get-VM $VMName
|
$vm = Get-VM $VMName
|
||||||
|
|
||||||
if ($env:AGENT_JOBSTATUS -eq 'Failed') {
|
if ($env:AGENT_JOBSTATUS -eq 'Failed') {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ vCenter password (Example "12345678")
|
|||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$VMName,
|
||||||
|
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$VIServer,
|
[string]$VIServer,
|
||||||
@@ -30,35 +34,72 @@ param(
|
|||||||
|
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$VIPassword
|
[string]$VIPassword,
|
||||||
|
|
||||||
|
[string]$TagCategory = "Busy"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Import helpers module
|
# Import helpers module
|
||||||
Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
Import-Module $PSScriptRoot\helpers.psm1 -DisableNameChecking
|
||||||
|
|
||||||
# Connection to a vCenter Server system
|
function Select-DataStore {
|
||||||
Connect-VCServer
|
param (
|
||||||
|
[string]$VMName,
|
||||||
|
[string]$TagCategory,
|
||||||
|
[string]$TemplateDatastore = "ds-local-Datastore-*",
|
||||||
|
[int]$ThresholdInGb = 400,
|
||||||
|
[int]$VMCount = 2,
|
||||||
|
[int]$Retries = 5
|
||||||
|
)
|
||||||
|
|
||||||
# Get a target datastore for current deployment
|
# 1. Name starts with ds-local-Datastore
|
||||||
# 1. Name starts with ds-local-Datastore
|
# 2. FreespaceGB > 400 Gb
|
||||||
# 2. FreespaceGB > 400 Gb
|
# 3. VM count on a datastore < 2
|
||||||
# 3. VM count on a datastore < 2
|
|
||||||
$templateDatastore = "ds-local-Datastore-*"
|
Write-Host "Start Datastore selection process..."
|
||||||
$thresholdInGb = 400
|
$allDatastores = Get-Datastore -Name $templateDatastore | Where-Object { $_.State -eq "Available" }
|
||||||
$vmCount = 2
|
$buildDatastore = $allDatastores | Where-Object { $_.FreeSpaceGB -ge $thresholdInGb } | Where-Object {
|
||||||
$allDatastores = Get-Datastore -Name $templateDatastore | Where-Object { $_.State -eq "Available" }
|
|
||||||
$buildDatastore = $allDatastores | Where-Object { $_.FreeSpaceGB -ge $thresholdInGb } | Where-Object {
|
|
||||||
$vmOnDatastore = @((Get-ChildItem -Path $_.DatastoreBrowserPath).Name -notmatch "^\.").Count
|
$vmOnDatastore = @((Get-ChildItem -Path $_.DatastoreBrowserPath).Name -notmatch "^\.").Count
|
||||||
$vmOnDatastore -lt $vmCount
|
$vmOnDatastore -lt $vmCount
|
||||||
} | Select-Object -ExpandProperty Name -First 1
|
} | Select-Object -ExpandProperty Name -First 1
|
||||||
|
|
||||||
if ($buildDatastore)
|
$tag = Get-Tag -Category $TagCategory -Name $VMName -ErrorAction Ignore
|
||||||
{
|
if (-not $tag)
|
||||||
|
{
|
||||||
|
$tag = New-Tag -Name $VMName -Category $TagCategory
|
||||||
|
}
|
||||||
|
|
||||||
|
New-TagAssignment -Tag $tag -Entity $buildDatastore | Out-Null
|
||||||
|
|
||||||
|
# Wait for 60 seconds to check if any other tags are assigned to the same datastore
|
||||||
|
Start-Sleep -Seconds 60
|
||||||
|
# Take only first 2 tags, all the others will go to the next round
|
||||||
|
$tagAssignments = (Get-TagAssignment -Entity $buildDatastore).Tag.Name | Select-Object -First 2
|
||||||
|
$isAllow = $tagAssignments -contains $VMName
|
||||||
|
|
||||||
|
if ($isAllow)
|
||||||
|
{
|
||||||
Write-Host "Datastore selected successfully"
|
Write-Host "Datastore selected successfully"
|
||||||
Write-Host "##vso[task.setvariable variable=buildDatastore;issecret=true]$buildDatastore"
|
Write-Host "##vso[task.setvariable variable=buildDatastore;issecret=true]$buildDatastore"
|
||||||
}
|
return
|
||||||
else
|
}
|
||||||
{
|
|
||||||
|
# Remove the tag if datastore wasn't selected
|
||||||
|
Remove-Tag $tag -Confirm:$false
|
||||||
|
|
||||||
|
$retries--
|
||||||
|
if ($retries -le 0)
|
||||||
|
{
|
||||||
Write-Host "##vso[task.LogIssue type=error;]No datastores found for the condition"
|
Write-Host "##vso[task.LogIssue type=error;]No datastores found for the condition"
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Datastore select failed, $retries left"
|
||||||
|
Select-DataStore -VMName $VMName -TagCategory $TagCategory -Retries $retries
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Connection to a vCenter Server system
|
||||||
|
Connect-VCServer
|
||||||
|
|
||||||
|
# Get a target datastore for current deployment
|
||||||
|
Select-DataStore -VMName $VMName -TagCategory $TagCategory
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ source $HELPER_SCRIPTS/etc-environment.sh
|
|||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||||||
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
|
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
|
||||||
|
|
||||||
# Make brew files and directories writable by any user
|
|
||||||
sudo chmod -R o+w $HOMEBREW_PREFIX
|
|
||||||
|
|
||||||
# Update /etc/environemnt
|
# Update /etc/environemnt
|
||||||
## Put HOMEBREW_* variables
|
## Put HOMEBREW_* variables
|
||||||
brew shellenv|grep 'export HOMEBREW'|sed -E 's/^export (.*);$/\1/' | sudo tee -a /etc/environment
|
brew shellenv|grep 'export HOMEBREW'|sed -E 's/^export (.*);$/\1/' | sudo tee -a /etc/environment
|
||||||
|
|||||||
@@ -3,11 +3,7 @@
|
|||||||
source ~/utils/utils.sh
|
source ~/utils/utils.sh
|
||||||
|
|
||||||
echo "Installing Microsoft Edge..."
|
echo "Installing Microsoft Edge..."
|
||||||
# Workaround to install version 85 since webdriver is broken for 86
|
|
||||||
cd "$(brew --repo homebrew/homebrew-cask)"
|
|
||||||
git checkout 81f9d08d2b9b7557c0178621078cf59d2c5db2bc
|
|
||||||
brew cask install microsoft-edge
|
brew cask install microsoft-edge
|
||||||
git checkout master
|
|
||||||
|
|
||||||
EDGE_INSTALLATION_PATH="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
EDGE_INSTALLATION_PATH="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
||||||
EDGE_VERSION=$("$EDGE_INSTALLATION_PATH" --version | cut -d' ' -f 3)
|
EDGE_VERSION=$("$EDGE_INSTALLATION_PATH" --version | cut -d' ' -f 3)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac-versions" | reverse | .
|
|||||||
XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android-versions" | reverse | .[]'))
|
XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android-versions" | reverse | .[]'))
|
||||||
LATEST_SDK_SYMLINK=$(get_toolset_value '.xamarin.bundles[0].symlink')
|
LATEST_SDK_SYMLINK=$(get_toolset_value '.xamarin.bundles[0].symlink')
|
||||||
CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle-default"')
|
CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle-default"')
|
||||||
|
DEFAULT_XCODE_VERSION=$(get_default_xcode_from_toolset)
|
||||||
|
|
||||||
if [ "$CURRENT_SDK_SYMLINK" == "latest" ]; then
|
if [ "$CURRENT_SDK_SYMLINK" == "latest" ]; then
|
||||||
CURRENT_SDK_SYMLINK=$LATEST_SDK_SYMLINK
|
CURRENT_SDK_SYMLINK=$LATEST_SDK_SYMLINK
|
||||||
@@ -82,3 +83,8 @@ popd
|
|||||||
|
|
||||||
echo "Clean up packages..."
|
echo "Clean up packages..."
|
||||||
sudo rm -rf "$TMPMOUNT"
|
sudo rm -rf "$TMPMOUNT"
|
||||||
|
|
||||||
|
# Fix Xamarin issue with Xcode symlink: https://github.com/xamarin/xamarin-macios/issues/9960
|
||||||
|
PREFERENCES_XAMARIN_DIR="${HOME}/Library/Preferences/Xamarin"
|
||||||
|
mkdir -p $PREFERENCES_XAMARIN_DIR
|
||||||
|
/usr/libexec/PlistBuddy -c "add :AppleSdkRoot string /Applications/Xcode_${DEFAULT_XCODE_VERSION}.app" $PREFERENCES_XAMARIN_DIR/Settings.plist
|
||||||
|
|||||||
@@ -128,11 +128,7 @@ if (Test-IsWin19) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Expand disk size of OS drive
|
# Expand disk size of OS drive
|
||||||
New-Item -Path d:\ -Name cmds.txt -ItemType File -Force
|
$driveLetter = "C"
|
||||||
Add-Content -Path d:\cmds.txt "SELECT VOLUME=C`r`nEXTEND"
|
$size = Get-PartitionSupportedSize -DriveLetter $driveLetter
|
||||||
|
Resize-Partition -DriveLetter $driveLetter -Size $size.SizeMax
|
||||||
$expandResult = (diskpart /s 'd:\cmds.txt')
|
Get-Volume | Select-Object DriveLetter, SizeRemaining, Size | Sort-Object DriveLetter
|
||||||
Write-Host $expandResult
|
|
||||||
|
|
||||||
Write-Host "Disk sizes after expansion"
|
|
||||||
wmic logicaldisk get size,freespace,caption
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"virtual_network_resource_group_name": "{{env `VNET_RESOURCE_GROUP`}}",
|
"virtual_network_resource_group_name": "{{env `VNET_RESOURCE_GROUP`}}",
|
||||||
"virtual_network_subnet_name": "{{env `VNET_SUBNET`}}",
|
"virtual_network_subnet_name": "{{env `VNET_SUBNET`}}",
|
||||||
"private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}",
|
"private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}",
|
||||||
"vm_size": "Standard_D4_v2",
|
"vm_size": "Standard_DS4_v2",
|
||||||
"run_scan_antivirus": "false",
|
"run_scan_antivirus": "false",
|
||||||
"root_folder": "C:",
|
"root_folder": "C:",
|
||||||
"toolset_json_path": "{{env `TEMP`}}\\toolset.json",
|
"toolset_json_path": "{{env `TEMP`}}\\toolset.json",
|
||||||
|
|||||||
Reference in New Issue
Block a user