[macOS] Refactor Common.Helpers (#8924)

* [macOS] Refactor Common.Helpers

* Update readme file

* Remove unnecessary double quotes

---------

Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
This commit is contained in:
Alexey-Ayupov
2023-12-04 12:13:08 +01:00
committed by GitHub
parent ff1dc02cbc
commit 69db5c6c63
46 changed files with 292 additions and 359 deletions

View File

@@ -6,8 +6,7 @@
Import-Module "~/image-generation/helpers/Common.Helpers.psm1"
function Get-ToolsetToolFullPath
{
function Get-ToolsetToolFullPath {
param
(
[Parameter(Mandatory)] [string] $ToolName,
@@ -23,25 +22,23 @@ function Get-ToolsetToolFullPath
}
$arch = Get-Architecture
$toolcache = Get-ToolsetValue "toolcache"
$toolcache = (Get-ToolsetContent).toolcache
foreach ($tool in $toolcache)
{
foreach ($tool in $toolcache) {
$toolName = $tool.name
$toolEnvironment = $tool.arch.$arch.variable_template
if (-not $toolEnvironment)
{
if (-not $toolEnvironment) {
continue
}
foreach ($toolVersion in $tool.arch.$arch.versions)
{
foreach ($toolVersion in $tool.arch.$arch.versions) {
Write-Host "Set $toolName $toolVersion environment variable..."
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $arch
$envName = $toolEnvironment -f $toolVersion.split(".")
# Add environment variable name=value
Add-EnvironmentVariable -Name $envName -Value $toolPath
$envVar = "export {0}={1}" -f $envName, $toolPath
Add-Content -Path "${env:HOME}/.bashrc" -Value $envVar
}
}

View File

@@ -31,11 +31,11 @@ $arch = Get-Architecture
# Get toolcache content from toolset
$toolsToInstall = @("Python", "Node", "Go")
$tools = Get-ToolsetValue "toolcache" | Where-Object {$toolsToInstall -contains $_.Name}
$tools = (Get-ToolsetContent).toolcache | Where-Object {$toolsToInstall -contains $_.Name}
foreach ($tool in $tools) {
# Get versions manifest for current tool
$assets = Invoke-RestMethodWithRetry -Url $tool.url
$assets = Invoke-RestMethod $tool.url -MaximumRetryCount 10 -RetryIntervalSec 30
# Get github release asset for each version
foreach ($version in $tool.arch.$arch.versions) {

View File

@@ -8,10 +8,10 @@ $ErrorActionPreference = "Stop"
Import-Module "$env:HOME/image-generation/helpers/Common.Helpers.psm1"
Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1" -DisableNameChecking
$ARCH = Get-Architecture
[Array]$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions"
$arch = Get-Architecture
[Array]$xcodeVersions = (Get-ToolsetContent).xcode.$arch.versions
write-host $xcodeVersions
$defaultXcode = Get-ToolsetValue "xcode.default"
$defaultXcode = (Get-ToolsetContent).xcode.default
[Array]::Reverse($xcodeVersions)
$threadCount = "5"
@@ -61,7 +61,7 @@ $xcodeVersions | ForEach-Object {
Write-Host "Rebuilding Launch Services database ..."
$xcodeVersions | ForEach-Object {
Rebuild-XcodeLaunchServicesDb -Version $_.link
Initialize-XcodeLaunchServicesDb -Version $_.link
}
Write-Host "Setting default Xcode to $defaultXcode"

View File

@@ -8,16 +8,16 @@ $ErrorActionPreference = "Stop"
Import-Module "$env:HOME/image-generation/helpers/Xcode.Helpers.psm1" -DisableNameChecking
Import-Module "$env:HOME/image-generation/software-report/SoftwareReport.Xcode.psm1" -DisableNameChecking
function Ensure-SimulatorInstalled {
function Test-SimulatorInstalled {
param(
[Parameter(Mandatory)]
[string]$RuntimeId,
[string] $RuntimeId,
[Parameter(Mandatory)]
[string]$DeviceId,
[string] $DeviceId,
[Parameter(Mandatory)]
[string]$SimulatorName,
[string] $SimulatorName,
[Parameter(Mandatory)]
[string]$XcodeVersion
[string] $XcodeVersion
)
$simctlPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "simctl"
@@ -52,5 +52,5 @@ Get-XcodeInfoList | Out-Null
Write-Host "Validating and fixing Xcode simulators..."
Get-BrokenXcodeSimulatorsList | ForEach-Object {
Ensure-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion
Test-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion
}

View File

@@ -33,9 +33,9 @@ components=()
ANDROID_PLATFORM=$(get_toolset_value '.android.platform_min_version')
ANDROID_BUILD_TOOL=$(get_toolset_value '.android.build_tools_min_version')
ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extra-list"[]'))
ANDROID_ADDON_LIST=($(get_toolset_value '.android."addon-list"[]'))
ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional-tools"[]'))
ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extras"[]'))
ANDROID_ADDON_LIST=($(get_toolset_value '.android."addons"[]'))
ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional_tools"[]'))
ANDROID_NDK_MAJOR_VERSIONS=($(get_toolset_value '.android.ndk."versions"[]'))
ANDROID_NDK_MAJOR_DEFAULT=$(get_toolset_value '.android.ndk.default')
ANDROID_NDK_MAJOR_LATEST=$(get_toolset_value '.android.ndk."versions"[-1]')

View File

@@ -7,12 +7,12 @@
source ~/utils/utils.sh
source ~/utils/xamarin-utils.sh
MONO_VERSIONS=($(get_toolset_value '.xamarin."mono-versions" | reverse | .[]'))
XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios-versions" | reverse | .[]'))
XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac-versions" | reverse | .[]'))
XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android-versions" | reverse | .[]'))
MONO_VERSIONS=($(get_toolset_value '.xamarin."mono_versions" | reverse | .[]'))
XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios_versions" | reverse | .[]'))
XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac_versions" | reverse | .[]'))
XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android_versions" | reverse | .[]'))
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_toolset_value '.xcode.default')
if [ "$CURRENT_SDK_SYMLINK" == "latest" ]; then

View File

@@ -2,9 +2,10 @@ Import-Module "$PSScriptRoot/SoftwareReport.Helpers.psm1" -DisableNameChecking
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
function Split-TableRowByColumns {
param(
param (
[string] $Row
)
return $Row.Split("|") | ForEach-Object { $_.trim() }
}
@@ -46,6 +47,7 @@ function Get-AndroidPackages {
function Build-AndroidTable {
Write-Host "Build-AndroidTable"
$packageInfo = Get-AndroidInstalledPackages
return @(
@{
"Package" = "Android Command Line Tools"
@@ -111,6 +113,7 @@ function Build-AndroidEnvironmentTable {
$androidVersions = Get-Item env:ANDROID_*
$shoulddResolveLink = 'ANDROID_NDK', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME'
return $androidVersions | Sort-Object -Property Name | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
@@ -191,7 +194,7 @@ function Get-AndroidGoogleAPIsVersions {
function Get-AndroidNDKVersions {
$ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk"
$versions += Get-ChildItem -Path $ndkFolderPath -Name
$ndkDefaultVersion = Get-ToolsetValue "android.ndk.default"
$ndkDefaultVersion = (Get-ToolsetContent).android.ndk.default
$ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1
return ($versions | ForEach-Object {

View File

@@ -1,7 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
function Get-BashVersion {
$version = bash -c 'echo ${BASH_VERSION}'
return $version
@@ -83,7 +81,7 @@ function Get-VcpkgVersion {
}
function Get-GccVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList = (Get-ToolsetContent).gcc.versions
$versionList | Foreach-Object {
$nameVersion = Run-Command "gcc-${_} --version" | Select-Object -First 1
$version = ($nameVersion -replace "^gcc-${_}").Trim() -replace '\).*$', ')'
@@ -92,7 +90,7 @@ function Get-GccVersions {
}
function Get-FortranVersions {
$versionList = Get-ToolsetValue -KeyPath gcc.versions
$versionList = (Get-ToolsetContent).gcc.versions
$versionList | Foreach-Object {
$nameVersion = Run-Command "gfortran-${_} --version" | Select-Object -First 1
$version = ($nameVersion -replace "^GNU Fortran").Trim() -replace '\).*$', ')'
@@ -106,7 +104,7 @@ function Get-ClangLLVMVersions {
$defaultClangOutput = Run-Command "clang --version" | Out-String
$defaultClangVersion = $clangVersionRegex.Match($defaultClangOutput).Groups['version'].Value
$homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f (Get-ToolsetValue 'llvm.version')
$homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f ((Get-ToolsetContent).llvm.version)
$homebrewClangOutput = Run-Command "$homebrewClangPath --version" | Out-String
$homebrewClangVersion = $clangVersionRegex.Match($homebrewClangOutput).Groups['version'].Value

View File

@@ -7,6 +7,7 @@ function Get-JavaVersions {
} else {
$javaVersions = Get-Item env:JAVA_HOME_*_X64
}
$sortRules = @{
Expression = { [Int32]$_.Name.Split("_")[2] }
Descending = $false

View File

@@ -54,7 +54,7 @@ function Build-ToolcacheSection {
}
function Get-PowerShellModules {
$modules = (Get-ToolsetValue powershellModules).name
$modules = ((Get-ToolsetContent).powershellModules).name
$modules | ForEach-Object {
$moduleName = $_
$moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique

View File

@@ -1,8 +1,8 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
function Build-VSMacTable {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
$vsMacVersions = (Get-ToolsetContent).xamarin.vsmac.versions
$defaultVSMacVersion = (Get-ToolsetContent).xamarin.vsmac.default
return $vsMacVersions | ForEach-Object {
$isDefault = $_ -eq $defaultVSMacVersion
@@ -29,8 +29,8 @@ function Get-NUnitVersion {
}
function Build-XamarinTable {
$xamarinBundles = Get-ToolsetValue "xamarin.bundles"
$defaultSymlink = Get-ToolsetValue "xamarin.bundle-default"
$xamarinBundles = (Get-ToolsetContent).xamarin.bundles
$defaultSymlink = (Get-ToolsetContent).xamarin.bundle_default
if ($defaultSymlink -eq "latest") {
$defaultSymlink = $xamarinBundles[0].symlink
}

View File

@@ -4,7 +4,7 @@ Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
$os = Get-OSVersion
function Get-XcodePaths {
$xcodePaths = Get-ChildItemWithoutSymlinks "/Applications" -Filter "Xcode_*.app"
$xcodePaths = Get-ChildItem -Path "/Applications" -Filter "Xcode_*.app" | Where-Object { !$_.LinkType }
return $xcodePaths | Select-Object -ExpandProperty Fullname
}

View File

@@ -7,6 +7,7 @@ function Get-CommandResult {
# Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version")
$stdout = & bash -c "$Command 2>&1"
$exitCode = $LASTEXITCODE
return @{
Output = If ($Multiline -eq $true) { $stdout } else { [string]$stdout }
ExitCode = $exitCode
@@ -14,21 +15,16 @@ function Get-CommandResult {
}
# Gets path to the tool, analogue of 'which tool'
function Get-WhichTool($tool) {
function Get-ToolPath($tool) {
return (Get-Command $tool).Path
}
# Gets value of environment variable by the name
function Get-EnvironmentVariable($variable) {
return [System.Environment]::GetEnvironmentVariable($variable)
}
# Returns the object with information about current OS
# It can be used for OS-specific tests
function Get-OSVersion {
$osVersion = [Environment]::OSVersion
$osVersionMajorMinor = $osVersion.Version.ToString(2)
$processorArchitecture = arch
return [PSCustomObject]@{
Version = $osVersion.Version
Platform = $osVersion.Platform
@@ -44,85 +40,11 @@ function Get-OSVersion {
}
}
function Get-ChildItemWithoutSymlinks {
param (
[Parameter(Mandatory)]
[string] $Path,
[string] $Filter
)
$files = Get-ChildItem -Path $Path -Filter $Filter
$files = $files | Where-Object { !$_.LinkType } # cut symlinks
return $files
}
# Get the value of specific toolset node
# Example, invoke `Get-ToolsetValue "xamarin.bundles"` to get value of `$toolsetJson.xamarin.bundles`
function Get-ToolsetValue {
param (
[Parameter(Mandatory = $true)]
[string] $KeyPath
)
# Get the value of the toolset
function Get-ToolsetContent {
$toolsetPath = Join-Path $env:HOME "image-generation" "toolset.json"
$jsonNode = Get-Content -Raw $toolsetPath | ConvertFrom-Json
$pathParts = $KeyPath.Split(".")
# try to walk through all arguments consequentially to resolve specific json node
$pathParts | ForEach-Object {
$jsonNode = $jsonNode.$_
}
return $jsonNode
}
function Get-ToolcachePackages {
$toolcachePath = Join-Path $env:HOME "image-generation" "toolcache.json"
return Get-Content -Raw $toolcachePath | ConvertFrom-Json
}
function Invoke-RestMethodWithRetry {
param (
[Parameter()]
[string]
$Url
)
Invoke-RestMethod $Url -MaximumRetryCount 10 -RetryIntervalSec 30
}
function Invoke-ValidateCommand {
param(
[Parameter(Mandatory)]
[string]$Command,
[Uint] $Timeout = 0
)
if ($Timeout -eq 0)
{
$output = Invoke-Expression -Command $Command
if ($LASTEXITCODE -ne 0) {
throw "Command '$Command' has finished with exit code $LASTEXITCODE"
}
return $output
}
else
{
$job = $command | Start-Job -ScriptBlock {
$output = Invoke-Expression -Command $input
if ($LASTEXITCODE -ne 0) {
throw 'Command failed'
}
return $output
}
$waitObject = $job | Wait-Job -Timeout $Timeout
if(-not $waitObject)
{
throw "Command '$Command' has timed out"
}
if($waitObject.State -eq 'Failed')
{
throw "Command '$Command' has failed"
}
Receive-Job -Job $job
}
$toolsetJson = Get-Content -Path $toolsetPath -Raw
ConvertFrom-Json -InputObject $toolsetJson
}
function Invoke-DownloadWithRetry {
@@ -174,37 +96,15 @@ function Invoke-DownloadWithRetry {
return $Path
}
function Add-EnvironmentVariable {
param
(
[Parameter(Mandatory)] [string] $Name,
[Parameter(Mandatory)] [string] $Value,
[string] $FilePath = "${env:HOME}/.bashrc"
)
$envVar = "export {0}={1}" -f $Name, $Value
Add-Content -Path $FilePath -Value $envVar
}
function isVeertu {
return (Test-Path -Path "/Library/Application Support/Veertu")
}
function Get-Architecture {
$arch = arch
if ($arch -ne "arm64")
{
if ($arch -ne "arm64") {
$arch = "x64"
}
return $arch
}
function Test-CommandExists {
param
(
[Parameter(Mandatory)] [string] $Command
)
[boolean] (Get-Command $Command -ErrorAction 'SilentlyContinue')
}

View File

@@ -28,14 +28,15 @@ function Get-XcodeToolPath {
}
function Get-XcodeVersionInfo {
param(
param (
[Parameter(Mandatory)]
[string]$XcodeRootPath
[string] $XcodeRootPath
)
$xcodebuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"
[string]$output = Invoke-Expression "$xcodebuildPath -version"
$versionOutputParts = $output.Split(" ")
return @{
Version = [System.Version]::Parse($versionOutputParts[1])
Build = $versionOutputParts[4]
@@ -72,11 +73,12 @@ function Test-XcodeStableRelease {
$licenseInfoPlistPath = Join-Path $XcodeRootPath "Contents" "Resources" "LicenseInfo.plist"
$releaseType = & defaults read $licenseInfoPlistPath "licenseType"
return -not ($releaseType -match "beta")
}
function Get-XcodeSimulatorsInfo {
param(
param (
[string] $Filter
)
@@ -106,6 +108,7 @@ function Get-XcodeDevicesList {
$result += "$runtimeName $deviceName"
}
}
return $result
}
@@ -120,12 +123,13 @@ function Get-XcodePairsList {
$phoneName = $_.Value.phone.name
$result += "$watchName $phoneName"
}
return $result
}
#Helper function for execution of xcversion due to: https://github.com/fastlane/fastlane/issues/18161
function Invoke-XCVersion {
param(
param (
[Parameter(Mandatory)]
[string] $Arguments,
[Parameter()]

View File

@@ -2,44 +2,41 @@ Import-Module "$PSScriptRoot/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/Xcode.Helpers.psm1"
function Install-XcodeVersion {
param(
param (
[Parameter(Mandatory)]
[string]$Version,
[string] $Version,
[Parameter(Mandatory)]
[string]$LinkTo
[string] $LinkTo
)
$xcodeDownloadDirectory = "$env:HOME/Library/Caches/XcodeInstall"
$xcodeTargetPath = Get-XcodeRootPath -Version $LinkTo
$xcodeXipDirectory = Invoke-DownloadXcodeArchive -DownloadDirectory $xcodeDownloadDirectory -Version $Version
Expand-XcodeXipArchive -DownloadDirectory $xcodeXipDirectory.FullName -TargetPath $xcodeTargetPath
Remove-Item -Path $xcodeXipDirectory -Force -Recurse
}
function Invoke-DownloadXcodeArchive {
param(
param (
[Parameter(Mandatory)]
[string]$DownloadDirectory,
[string] $DownloadDirectory,
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
Write-Host "Downloading Xcode $Version"
$tempXipDirectory = New-Item -Path $DownloadDirectory -Name "Xcode$Version" -ItemType "Directory"
$xcodeFileName = 'Xcode-{0}.xip' -f $Version
$xcodeUri = '{0}{1}?{2}'-f ${env:XCODE_INSTALL_STORAGE_URL}, $xcodeFileName, ${env:XCODE_INSTALL_SAS}
Invoke-DownloadWithRetry -Url $xcodeUri -Path (Join-Path $tempXipDirectory.FullName $xcodeFileName) | Out-Null
return $tempXipDirectory
}
function Resolve-ExactXcodeVersion {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
# if toolset string contains spaces, consider it as a full name of Xcode
@@ -50,6 +47,7 @@ function Resolve-ExactXcodeVersion {
$semverVersion = [SemVer]::Parse($Version)
$availableVersions = Get-AvailableXcodeVersions
$satisfiedVersions = $availableVersions | Where-Object { $semverVersion -eq $_.stableSemver }
return $satisfiedVersions | Select-Object -Last 1 -ExpandProperty rawVersion
}
@@ -75,18 +73,18 @@ function Get-AvailableXcodeVersions {
}
function Expand-XcodeXipArchive {
param(
param (
[Parameter(Mandatory)]
[string]$DownloadDirectory,
[string] $DownloadDirectory,
[Parameter(Mandatory)]
[string]$TargetPath
[string] $TargetPath
)
$xcodeXipPath = Get-ChildItem -Path $DownloadDirectory -Filter "Xcode-*.xip" | Select-Object -First 1
Write-Host "Extracting Xcode from '$xcodeXipPath'"
Push-Location $DownloadDirectory
if(Test-CommandExists 'unxip') {
if ([boolean] (Get-Command 'unxip' -ErrorAction 'SilentlyContinue')) {
Invoke-ValidateCommand "unxip $xcodeXipPath"
} else {
Invoke-ValidateCommand "xip -x $xcodeXipPath"
@@ -107,9 +105,9 @@ function Expand-XcodeXipArchive {
}
function Confirm-XcodeIntegrity {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
$XcodeRootPath = Get-XcodeRootPath -Version $Version
@@ -120,13 +118,12 @@ function Confirm-XcodeIntegrity {
}
function Approve-XcodeLicense {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
$os = Get-OSVersion
$XcodeRootPath = Get-XcodeRootPath -Version $Version
Write-Host "Approving Xcode license for '$XcodeRootPath'..."
$xcodeBuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"
@@ -139,9 +136,9 @@ function Approve-XcodeLicense {
}
function Install-XcodeAdditionalPackages {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
Write-Host "Installing additional packages for Xcode $Version..."
@@ -153,9 +150,9 @@ function Install-XcodeAdditionalPackages {
}
function Invoke-XcodeRunFirstLaunch {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
if ($Version.StartsWith("8") -or $Version.StartsWith("9")) {
@@ -168,9 +165,9 @@ function Invoke-XcodeRunFirstLaunch {
}
function Install-AdditionalSimulatorRuntimes {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
Write-Host "Installing Simulator Runtimes for Xcode $Version ..."
@@ -179,10 +176,10 @@ function Install-AdditionalSimulatorRuntimes {
}
function Build-XcodeSymlinks {
param(
param (
[Parameter(Mandatory)]
[string]$Version,
[string[]]$Symlinks
[string] $Version,
[string[]] $Symlinks
)
$sourcePath = Get-XcodeRootPath -Version $Version
@@ -193,10 +190,10 @@ function Build-XcodeSymlinks {
}
}
function Rebuild-XcodeLaunchServicesDb {
param(
function Initialize-XcodeLaunchServicesDb {
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
$xcodePath = Get-XcodeRootPath -Version $Version
@@ -205,9 +202,9 @@ function Rebuild-XcodeLaunchServicesDb {
}
function Build-ProvisionatorSymlink {
param(
param (
[Parameter(Mandatory)]
[string]$Version
[string] $Version
)
$sourcePath = Get-XcodeRootPath -Version $Version
@@ -222,9 +219,9 @@ function Build-ProvisionatorSymlink {
}
function Set-XcodeDeveloperDirEnvironmentVariables {
param(
param (
[Parameter(Mandatory)]
[string[]]$XcodeList
[string[]] $XcodeList
)
$exactVersionsList = $XcodeList | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object {
@@ -246,3 +243,37 @@ function Set-XcodeDeveloperDirEnvironmentVariables {
"export ${variableName}=${variableValue}" | Out-File "$env:HOME/.bashrc" -Append
}
}
function Invoke-ValidateCommand {
param (
[Parameter(Mandatory)]
[string] $Command,
[Uint] $Timeout = 0
)
if ($Timeout -eq 0) {
$output = Invoke-Expression -Command $Command
if ($LASTEXITCODE -ne 0) {
throw "Command '$Command' has finished with exit code $LASTEXITCODE"
}
return $output
} else {
$job = $command | Start-Job -ScriptBlock {
$output = Invoke-Expression -Command $input
if ($LASTEXITCODE -ne 0) {
throw 'Command failed'
}
return $output
}
$waitObject = $job | Wait-Job -Timeout $Timeout
if (-not $waitObject) {
throw "Command '$Command' has timed out"
}
if ($waitObject.State -eq 'Failed') {
throw "Command '$Command' has failed"
}
Receive-Job -Job $job
}
}

View File

@@ -6,9 +6,9 @@ $os = Get-OSVersion
Describe "Android" {
$androidSdkManagerPackages = Get-AndroidPackages
[int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version"
[version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version"
[array]$ndkVersions = Get-ToolsetValue "android.ndk.versions"
[int]$platformMinVersion = (Get-ToolsetContent).android.platform_min_version
[version]$buildToolsMinVersion = (Get-ToolsetContent).android.build_tools_min_version
[array]$ndkVersions = (Get-ToolsetContent).android.ndk.versions
$ndkFullVersions = $ndkVersions | ForEach-Object { Get-ChildItem "$env:ANDROID_HOME/ndk/${_}.*" -Name | Select-Object -Last 1 } | ForEach-Object { "ndk/${_}" }
# Platforms starting with a letter are the preview versions, which is not installed on the image
$platformVersionsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("platforms;") }) -replace 'platforms;android-', '' | Where-Object { $_ -match "^\d" } | Sort-Object -Unique
@@ -25,9 +25,9 @@ Describe "Android" {
$platformsInstalled,
$buildTools,
$ndkFullVersions,
(Get-ToolsetValue "android.extra-list" | ForEach-Object { "extras/${_}" }),
(Get-ToolsetValue "android.addon-list" | ForEach-Object { "add-ons/${_}" }),
(Get-ToolsetValue "android.additional-tools")
((Get-ToolsetContent).android.extras | ForEach-Object { "extras/${_}" }),
((Get-ToolsetContent).android.addons | ForEach-Object { "add-ons/${_}" }),
((Get-ToolsetContent).android.additional_tools)
) | ForEach-Object { $_ }
# Remove empty strings from array to avoid possible issues
@@ -36,10 +36,10 @@ Describe "Android" {
BeforeAll {
$ANDROID_SDK_DIR = Join-Path $env:HOME "Library" "Android" "sdk"
function Validate-AndroidPackage {
function Confirm-AndroidPackage {
param (
[Parameter(Mandatory = $true)]
[string]$PackageName
[string] $PackageName
)
# Convert 'm2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1' ->
@@ -76,7 +76,7 @@ Describe "Android" {
It "<PackageName>" -TestCases $testCases {
param ([string] $PackageName)
Validate-AndroidPackage $PackageName
Confirm-AndroidPackage $PackageName
}
}
}

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Azure CLI" {

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Chrome" {

View File

@@ -10,7 +10,7 @@ Describe ".NET" {
}
Describe "GCC" {
$testCases = Get-ToolsetValue -KeyPath gcc.versions | ForEach-Object { @{Version = $_ } }
$testCases = (Get-ToolsetContent).gcc.versions | ForEach-Object { @{Version = $_ } }
It "GCC <Version>" -TestCases $testCases {
param (
@@ -60,7 +60,7 @@ Describe "AzCopy" {
Describe "Miniconda" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "Conda" {
Get-EnvironmentVariable "CONDA" | Should -Not -BeNullOrEmpty
[System.Environment]::GetEnvironmentVariable("CONDA") | Should -Not -BeNullOrEmpty
$condaBinPath = Join-Path $env:CONDA "bin" "conda"
"$condaBinPath --version" | Should -ReturnZeroExitCode
}
@@ -79,8 +79,8 @@ Describe "CocoaPods" {
}
Describe "VSMac" -Skip:($os.IsVentura -or $os.IsSonoma) {
$vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions"
$defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default"
$vsMacVersions = (Get-ToolsetContent).xamarin.vsmac.versions
$defaultVSMacVersion = (Get-ToolsetContent).xamarin.vsmac.default
$testCases = $vsMacVersions | ForEach-Object {
$vsPath = "/Applications/Visual Studio $_.app"

View File

@@ -7,14 +7,14 @@ Describe "MongoDB" -Skip:($os.IsVentura -or $os.IsSonoma) {
@{ ToolName = "mongo" }
@{ ToolName = "mongod" }
) {
$toolsetVersion = Get-ToolsetValue 'mongodb.version'
$toolsetVersion = (Get-ToolsetContent).mongodb.version
(&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
}
}
Describe "PostgreSQL" -Skip:($os.IsVentura -or $os.IsSonoma) {
It "PostgreSQL version should correspond to the version in the toolset" {
$toolsetVersion = Get-ToolsetValue 'postgresql.version'
$toolsetVersion = (Get-ToolsetContent).postgresql.version
# Client version
(psql --version).split()[-2] | Should -BeLike "$toolsetVersion*"
# Server version

View File

@@ -1,5 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Git" {
It "git is installed" {
"git --version" | Should -ReturnZeroExitCode

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Haskell" -Skip:($os.IsVentura -or $os.IsSonoma) {

View File

@@ -1,11 +1,6 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
# Validates that tool is installed and in PATH
function Validate-ToolExist($tool) {
Get-Command $tool -ErrorAction SilentlyContinue | Should -BeTrue
}
function Validate-ArrayWithoutDuplicates {
function Confirm-ArrayWithoutDuplicates {
param (
[AllowEmptyCollection()]
[Parameter(Mandatory = $true)]
@@ -19,7 +14,7 @@ function Validate-ArrayWithoutDuplicates {
}
}
function Validate-Url {
function Confirm-UrlAvailability {
param (
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
@@ -37,7 +32,7 @@ function Validate-Url {
$result | Should -BeTrue -Because "'$Url' should be available, but it is not"
}
function Validate-IdenticalFileContent {
function Confirm-IdenticalFileContent {
param (
[Parameter(Mandatory)]
[string] $File1,
@@ -54,7 +49,7 @@ function Validate-IdenticalFileContent {
}
function ShouldReturnZeroExitCode {
Param(
Param (
[String] $ActualValue,
[switch] $Negate,
[string] $Because # This parameter is unused by we need it to match Pester asserts signature
@@ -65,8 +60,7 @@ function ShouldReturnZeroExitCode {
[bool]$succeeded = $result.ExitCode -eq 0
if ($Negate) { $succeeded = -not $succeeded }
if (-not $succeeded)
{
if (-not $succeeded) {
$commandOutputIndent = " " * 4
$commandOutput = ($result.Output | ForEach-Object { "${commandOutputIndent}${_}" }) -join "`n"
$failureMessage = "Command '${ActualValue}' has finished with exit code ${actualExitCode}`n${commandOutput}"
@@ -79,7 +73,7 @@ function ShouldReturnZeroExitCode {
}
function ShouldMatchCommandOutput {
Param(
Param (
[String] $ActualValue,
[String] $RegularExpression,
[switch] $Negate
@@ -115,7 +109,7 @@ If (Get-Command -Name Add-ShouldOperator -ErrorAction SilentlyContinue) {
}
function Invoke-PesterTests {
Param(
Param (
[Parameter(Mandatory)][string] $TestFile,
[string] $TestName
)

View File

@@ -14,7 +14,7 @@ function Get-NativeVersionFormat {
Describe "Java" {
BeforeAll {
function Validate-JavaVersion {
function Confirm-JavaVersion {
param($JavaCommand, $ExpectedVersion)
$commandResult = Get-CommandResult $JavaCommand
@@ -26,7 +26,7 @@ Describe "Java" {
}
}
$toolsetJava = Get-ToolsetValue "java"
$toolsetJava = (Get-ToolsetContent).java
$defaultVersion = $toolsetJava.$arch.default
$jdkVersions = $toolsetJava.$arch.versions
@@ -44,14 +44,14 @@ Describe "Java" {
}
It "Java <Version>" -TestCases $_ {
$envVariablePath = Get-EnvironmentVariable $EnvVariable
$envVariablePath = [System.Environment]::GetEnvironmentVariable($EnvVariable)
$javaBinPath = Join-Path $envVariablePath "/bin/java"
Validate-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version
Confirm-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version
}
if ($_.Title -eq "Default") {
It "Version is default" -TestCases $_ {
Validate-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version
Confirm-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version
}
}
}

View File

@@ -2,7 +2,7 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Describe "Clang/LLVM" {
BeforeAll {
$toolsetVersion = Get-ToolsetValue 'llvm.version'
$toolsetVersion = (Get-ToolsetContent).llvm.version
}
It "Clang/LLVM <toolsetVersion> is installed and version is correct" {

View File

@@ -9,7 +9,7 @@ Describe "Node.js" {
}
It "Node.js version should correspond to the version in the toolset" {
node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*"
node --version | Should -BeLike "v$((Get-ToolsetContent).node.default)*"
}
It "NPM is installed" {
@@ -33,7 +33,7 @@ Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) {
}
Context "nvm versions" {
[array]$nvmVersions = Get-ToolsetValue 'node.nvm_versions'
[array]$nvmVersions = (Get-ToolsetContent).node.nvm_versions
$testCases = $nvmVersions | ForEach-Object { @{NvmVersion = $_} }
It "<NvmVersion>" -TestCases $testCases {
@@ -47,7 +47,7 @@ Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) {
}
Describe "Global NPM Packages" {
$globalNpmPackages = Get-ToolsetValue "npm.global_packages"
$globalNpmPackages = (Get-ToolsetContent).npm.global_packages
$globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } }
It "<Name>" -TestCases $globalNpmPackagesWithTests {

View File

@@ -1,13 +1,14 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "PHP" {
Context "PHP" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
It "PHP Path" {
Get-WhichTool "php" | Should -Not -BeLike "/usr/bin/php*"
Get-ToolPath "php" | Should -Not -BeLike "/usr/bin/php*"
}
It "PHP version" {
$phpVersionToolset = Get-ToolsetValue 'php.version'
$phpVersionToolset = (Get-ToolsetContent).php.version
$phpInstalledVersion = php --version | Out-String | Select-String "${phpVersionToolset}"
$phpInstalledVersion | Should -BeLike "PHP ${phpVersionToolset}*"
}

View File

@@ -4,7 +4,7 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "PipxPackages" -Skip:($os.IsVentura -or $os.IsSonoma) {
$pipxToolset = Get-ToolsetValue "pipx"
$pipxToolset = (Get-ToolsetContent).pipx
$testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} }
It "<package>" -TestCases $testCases {
"$cmd" | Should -ReturnZeroExitCode

View File

@@ -9,7 +9,7 @@ Describe "Powershell" {
}
Context "Powershell Modules" {
$modules = Get-ToolsetValue powershellModules
$modules = (Get-ToolsetContent).powershellModules
$withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object {
@{moduleName = $_.name}
}

View File

@@ -9,7 +9,7 @@ Describe "Python3" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
}
It "Python 3 is installed under /usr/local/bin" {
Get-WhichTool "python3" | Should -BeLike "/usr/local/bin*"
Get-ToolPath "python3" | Should -BeLike "/usr/local/bin*"
}
It "Pip 3 is available" {

View File

@@ -9,14 +9,14 @@ Describe "Ruby" -Skip:(-not $os.IsArm64) {
}
It "Ruby is installed via HomeBrew" {
Get-WhichTool "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
}
It "Ruby tools are consistent" {
$expectedPrefix = "/opt/homebrew"
Get-WhichTool "ruby" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "gem" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "bundler" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*"
}
It "Ruby gems permissions are valid" {

View File

@@ -9,14 +9,14 @@ Describe "Ruby" -Skip:($os.IsArm64) {
}
It "Ruby is installed via HomeBrew" {
Get-WhichTool "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*"
}
It "Ruby tools are consistent" {
$expectedPrefix = "/usr/local"
Get-WhichTool "ruby" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "gem" | Should -Match "$($expectedPrefix)*"
Get-WhichTool "bundler" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*"
Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*"
}
It "Ruby gems permissions are valid" {

View File

@@ -1,13 +1,13 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "RubyGems" {
$gemTestCases = Get-ToolsetValue -KeyPath "ruby.rubygems" | ForEach-Object {
$gemTestCases = (Get-ToolsetContent).ruby.rubygems | ForEach-Object {
@{gemName = $_}
}
if ($gemTestCases)
{
if ($gemTestCases) {
It "Gem <gemName> is installed" -TestCases $gemTestCases {
"gem list -i '^$gemName$'" | Should -MatchCommandOutput "true"
}

View File

@@ -1,4 +1,5 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$os = Get-OSVersion
Describe "Rust" {

View File

@@ -6,7 +6,7 @@ $os = Get-OSVersion
Describe "Toolcache" {
$toolcacheDirectory = Join-Path $env:HOME "hostedtoolcache"
[array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object {
[array]$packages += (Get-ToolsetContent).toolcache | ForEach-Object {
return [PSCustomObject] @{
ToolName = ($_.name).ToLower()
Arch = $arch

View File

@@ -39,83 +39,82 @@ $toolsets | ForEach-Object {
It "Version '$vsmacVersion' is available and can be downloaded" {
$vsmacUrl = Invoke-BashUtilsFunction("buildVSMacDownloadUrl", $vsmacVersion)
Validate-Url $vsmacUrl
Confirm-UrlAvailability $vsmacUrl
}
}
Context "Mono" {
$sdkVersions = $toolset.xamarin."mono-versions"
$sdkVersions = $toolset.xamarin.mono_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildMonoDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin.iOS" {
$sdkVersions = $toolset.xamarin."ios-versions"
$sdkVersions = $toolset.xamarin.ios_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamariniIOSDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin.Mac" {
$sdkVersions = $toolset.xamarin."mac-versions"
$sdkVersions = $toolset.xamarin.mac_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamarinMacDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin.Android" {
$sdkVersions = $toolset.xamarin."android-versions"
$sdkVersions = $toolset.xamarin.android_versions
$sdkVersions | ForEach-Object {
It "Version '$_' is available and can be downloaded" {
$sdkUrl = Invoke-BashUtilsFunction("buildXamarinAndroidDownloadUrl", $_)
Validate-Url $sdkUrl
Confirm-UrlAvailability $sdkUrl
}
}
It "Version list doesn't contain versions with the same major/minor version" {
$versions = $sdkVersions | ForEach-Object { $_.Replace("-", ".") } | ForEach-Object { Get-ShortVersion $_ }
Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor"
}
}
Context "Xamarin bundles" {
$monoVersions = $toolset.xamarin."mono-versions" | ForEach-Object { Get-ShortVersion $_ }
$iOSVersions = $toolset.xamarin."ios-versions" | ForEach-Object { Get-ShortVersion $_ }
$macVersions = $toolset.xamarin."mac-versions" | ForEach-Object { Get-ShortVersion $_ }
$monoVersions = $toolset.xamarin.mono_versions | ForEach-Object { Get-ShortVersion $_ }
$iOSVersions = $toolset.xamarin.ios_versions | ForEach-Object { Get-ShortVersion $_ }
$macVersions = $toolset.xamarin.mac_versions | ForEach-Object { Get-ShortVersion $_ }
# Old Xamarin.Android version looks like "9.0.0-18" that doesn't support by System.Version
$androidVersions = $toolset.xamarin."android-versions" | ForEach-Object { Get-ShortVersion $_.Replace("-", ".") }
$androidVersions = $toolset.xamarin.android_versions | ForEach-Object { Get-ShortVersion $_.Replace("-", ".") }
$bundles = $toolset.xamarin.bundles
$bundles | ForEach-Object {
It "'$($_.symlink)' is valid" {
$monoVersions | Should -Contain $_.mono
@@ -127,18 +126,16 @@ $toolsets | ForEach-Object {
It "Each bundle has unique symlink" {
$symlinks = $bundles | ForEach-Object { $_.symlink }
Validate-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique"
Confirm-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique"
}
It "Current bundle is valid" {
$currentBundleSymlink = $toolset.xamarin."bundle-default"
$currentBundleSymlink = $toolset.xamarin.bundle_default
if ($currentBundleSymlink -ne "latest") {
$bundleSymlinks = $bundles | ForEach-Object { $_.symlink }
$bundleSymlinks | Should -Contain $currentBundleSymlink -Because "Current bundle should be installed"
}
}
}
}
}

View File

@@ -2,16 +2,17 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
$os = Get-OSVersion
if ($os.IsVentura -or $os.IsSonoma) {
$MONO_VERSIONS = @(Get-ToolsetValue "mono.framework.version")
$MONO_VERSIONS = @((Get-ToolsetContent).mono.framework.version)
$XAMARIN_IOS_VERSIONS = @()
$XAMARIN_MAC_VERSIONS = @()
$XAMARIN_ANDROID_VERSIONS = @()
} elseif ($os.IsBigSur -or $os.IsMonterey) {
$MONO_VERSIONS = Get-ToolsetValue "xamarin.mono-versions"
$XAMARIN_IOS_VERSIONS = Get-ToolsetValue "xamarin.ios-versions"
$XAMARIN_MAC_VERSIONS = Get-ToolsetValue "xamarin.mac-versions"
$XAMARIN_ANDROID_VERSIONS = Get-ToolsetValue "xamarin.android-versions"
$MONO_VERSIONS = (Get-ToolsetContent).xamarin.mono_versions
$XAMARIN_IOS_VERSIONS = (Get-ToolsetContent).xamarin.ios_versions
$XAMARIN_MAC_VERSIONS = (Get-ToolsetContent).xamarin.mac_versions
$XAMARIN_ANDROID_VERSIONS = (Get-ToolsetContent).xamarin.android_versions
}
BeforeAll {
@@ -53,7 +54,7 @@ Describe "Mono" {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
It "NUnit console is installed" -TestCases $testCase {
@@ -116,7 +117,7 @@ Describe "Xamarin.iOS" -Skip:($os.IsVentura -or $os.IsSonoma) {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
}
}
@@ -149,7 +150,7 @@ Describe "Xamarin.Mac" -Skip:($os.IsVentura -or $os.IsSonoma) {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
}
}
@@ -181,7 +182,7 @@ Describe "Xamarin.Android" -Skip:($os.IsVentura -or $os.IsSonoma) {
$shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION"
$fullVersionPath = Join-Path $VersionFolderPath "VERSION"
Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath
}
It "has correct symlinks" -TestCases $testCase {
@@ -205,8 +206,8 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
If ($XAMARIN_BUNDLES.Count -eq 0) { return } # Skip this test if there are no bundles
[array]$XAMARIN_BUNDLES = Get-ToolsetValue "xamarin.bundles"
$XAMARIN_DEFAULT_BUNDLE = Get-ToolsetValue "xamarin.bundle-default"
[array]$XAMARIN_BUNDLES = (Get-ToolsetContent).xamarin.bundles
$XAMARIN_DEFAULT_BUNDLE = (Get-ToolsetContent).xamarin.bundle_default
If ($XAMARIN_DEFAULT_BUNDLE -eq "latest") { $XAMARIN_DEFAULT_BUNDLE = $XAMARIN_BUNDLES[0].symlink }
$currentBundle = [PSCustomObject] @{
@@ -244,7 +245,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleMono "VERSION"
$targetVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "iOS symlink <BundleSymlink> exists" -TestCases $allBundles {
@@ -262,7 +263,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleIos "VERSION"
$targetVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "Mac symlink <BundleSymlink> exists" -TestCases $allBundles {
@@ -280,7 +281,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleMac "VERSION"
$targetVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
It "Xamarin.Android symlink <BundleSymlink> exists" -TestCases $allBundles {
@@ -298,7 +299,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) {
$sourceVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleAndroid "VERSION"
$targetVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleSymlink "VERSION"
Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath
}
}

View File

@@ -2,14 +2,20 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1"
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
$ARCH = Get-Architecture
$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions"
$defaultXcode = Get-ToolsetValue "xcode.default"
$arch = Get-Architecture
$xcodeVersions = (Get-ToolsetContent).xcode.${arch}.versions
$defaultXcode = (Get-ToolsetContent).xcode.default
$latestXcodeVersion = $xcodeVersions | Select-Object -First 1
$os = Get-OSVersion
Describe "Xcode" {
$testCases = $xcodeVersions | ForEach-Object { @{ XcodeVersion = $_.link; LatestXcodeVersion = $xcodeVersions[0].link; Symlinks = $_.symlinks } }
$testCases = $xcodeVersions | ForEach-Object {
@{
XcodeVersion = $_.link;
LatestXcodeVersion = $xcodeVersions[0].link;
Symlinks = $_.symlinks
}
}
Context "Versions" {
It "<XcodeVersion>" -TestCases $testCases {
@@ -82,7 +88,7 @@ Describe "XCODE_DEVELOPER_DIR variables" {
It "XCODE_<MajorVersion>_DEVELOPER_DIR" -TestCases $testCases {
$variableName = "XCODE_${MajorVersion}_DEVELOPER_DIR"
$actualPath = Get-EnvironmentVariable $variableName
$actualPath = [System.Environment]::GetEnvironmentVariable($variableName)
$expectedVersion = $VersionsList | Where-Object { $_.Version.Major -eq $MajorVersion } | Select-Object -First 1
$expectedPath = "$($expectedVersion.RootPath)/Contents/Developer"
$actualPath | Should -Exist
@@ -99,21 +105,13 @@ Describe "Xcode simulators" {
[array]$devicesList = @(Get-XcodeDevicesList | Where-Object { $_ })
Write-Host "Devices for $XcodeVersion"
Write-Host ($devicesList -join "`n")
Validate-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators"
Confirm-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators"
}
# It "No duplicates in pairs" -TestCases $testCase {
# Switch-Xcode -Version $XcodeVersion
# [array]$pairsList = @(Get-XcodePairsList | Where-Object { $_ })
# Write-Host "Pairs for $XcodeVersion"
# Write-Host ($pairsList -join "`n")
# Validate-ArrayWithoutDuplicates $pairsList -Because "Found duplicate pairs simulators"
# }
}
}
AfterEach {
$defaultXcode = Get-ToolsetValue "xcode.default"
$defaultXcode = (Get-ToolsetContent).xcode.default
Switch-Xcode -Version $defaultXcode
}
}

View File

@@ -1,5 +1,7 @@
# Toolset JSON structure
## Xcode
- `versions` - the array of objects that will present installed Xcode versions
- `link` property points to the place where Xcode will be located on image. `/Applications/Xcode_<link>.app`
- `version` points to Xcode version that will be downloaded and installed
@@ -8,6 +10,7 @@
**Example:** `"11.2"`
**Note:**
- If `version` is specified with spaces, it is considered as exact Xcode name like `12.1.1 Release Candidate`.
- If `version` doesn't contain spaces, the latest version will be resolved with the following priority:
- stable version like `12.1`
@@ -16,7 +19,8 @@
- beta version like `12.1 beta N` (the latest N will be chosen)
**Example:**
```
```json
"versions": [
{ "link": "12.2", "version": "12.2.0" },
{ "link": "11.7", "version": "11.7.0", "symlinks": ["11.7_beta"] }
@@ -24,27 +28,26 @@
```
## Xamarin
- `vsmac` - version of Visual Studio For Mac to install.
**Example:** `"8.3.11.1"`
- `mono-versions` - the array of Mono versions to install.
- `mono_versions` - the array of Mono versions to install.
**Example:** `[ "6.4.0.208", "6.0.0.334" ]`
- `ios-versions` - the array of Xamarin iOS versions to install.
- `ios_versions` - the array of Xamarin iOS versions to install.
**Example:** `[ "13.6.0.12", "13.4.0.2", "13.2.0.47" ]`
- `mac-versions` - the array of Xamarin iOS versions to install.
- `mac_versions` - the array of Xamarin iOS versions to install.
**Example:** `[ "6.6.0.12", "6.4.0.2", "6.2.0.47" ]`
- `android-versions` - the array of Xamarin iOS versions to install.
- `android_versions` - the array of Xamarin iOS versions to install.
**Example:** `[ "10.0.6.2", "9.4.1.0" ]`
**Note:** More than one version of SDK with the same major.minor version should not be installed. It applies to `mono-versions`, `ios-versions`, `mac-versions`, `android-versions` fields.
**Note:** More than one version of SDK with the same major.minor version should not be installed. It applies to `mono_versions`, `ios_versions`, `mac_versions`, `android_versions` fields.
For example, if Mono `6.4.0.100` is installed and Mono `6.4.1.2` was released recently, we should not install both, just update `6.4.0.100` -> `6.4.1.2`. Only major and minor version changes can break backward compatibility so it is safe.
<br>
- `bundle-default` - the symlink of the bundle that will be set as default on the image.
- `bundle_default` - the symlink of the bundle that will be set as default on the image.
This bundle will be set as `Current`.
**Example:** `"5_12_0"` (set bundle with symlink `5_12_0` as default)
**Example:** `"latest"` (set latest bundle as default)
@@ -59,9 +62,9 @@ The first bundle in the list will be as `Latest`.
- `mac` - version of Xamarin.Mac that will be set in this bundle. Only two numbers (`major.minor`) should be specified.
- `android` - version of Xamarin.Android that will be set in this bundle. Only two numbers (`major.minor`) should be specified.
**Example:**
**Example:**
```
```json
[
{
"symlink": "6_4_2",
@@ -81,19 +84,20 @@ The first bundle in the list will be as `Latest`.
```
## Android
- `platform-list` - the array of android platforms to install.
**Example:** `[ "android-29", "android-28", "android-27" ]`
- `build-tools` - the array of android build tools to install.
**Example:** `[ "29.0.2", "29.0.1", "29.0.0", "28.0.3" ]`
- `extra-list` - the array of android extra items to install.
- `extras` - the array of android extra items to install.
**Example:** `[ "google;google_play_services", "intel;Hardware_Accelerated_Execution_Manager" ]`
- `addon-list` - the array of android addons to install.
- `addons` - the array of android addons to install.
**Example:** `[ "addon-google_apis-google-24", "addon-google_apis-google-23" ]`
## Toolset JSON validation
# Toolset JSON validation
File `Toolset.Tests.ps1` contains PowerShell [Pester](https://github.com/Pester/Pester) tests that validate JSON toolset files.
Type `Invoke-Pester` in the current folder in PowerShell to run tests.

View File

@@ -17,19 +17,19 @@
"default": "2022",
"versions": [ "2019", "2022" ]
},
"mono-versions": [
"mono_versions": [
"6.12.0.188"
],
"ios-versions": [
"ios_versions": [
"15.8.0.3", "15.6.0.3", "15.4.0.0", "15.2.0.17", "15.0.0.6", "14.20.0.24", "14.16.0.5", "14.14.2.5", "14.10.0.4", "14.8.0.3", "14.6.0.15", "14.4.1.3", "14.2.0.12", "14.0.0.0", "13.20.2.2"
],
"mac-versions": [
"mac_versions": [
"8.8.0.3", "8.6.0.3", "8.4.0.0", "8.2.0.17", "7.14.0.27", "7.10.0.5", "7.8.2.5", "7.4.0.10", "7.2.0.3", "7.0.0.15", "6.22.1.26", "6.20.2.2"
],
"android-versions": [
"android_versions": [
"12.2.8.3", "12.1.0.2", "12.0.0.3", "11.3.0.4", "11.2.2.1", "11.1.0.26", "11.0.2.0"
],
"bundle-default": "6_12_12",
"bundle_default": "6_12_12",
"bundles": [
{
"symlink": "6_12_16",
@@ -162,11 +162,11 @@
"cmdline-tools": "commandlinetools-mac-9123335_latest.zip",
"platform_min_version": "27",
"build_tools_min_version": "27.0.0",
"extra-list": [
"extras": [
"android;m2repository", "google;m2repository", "google;google_play_services"
],
"addon-list": [],
"additional-tools": [
"addons": [],
"additional_tools": [
"cmake;3.10.2.4988404",
"cmake;3.18.1",
"cmake;3.22.1"

View File

@@ -18,19 +18,19 @@
"default": "2022",
"versions": [ "2019", "2022" ]
},
"mono-versions": [
"mono_versions": [
"6.12.0.188"
],
"ios-versions": [
"ios_versions": [
"16.2.0.5", "16.1.1.27", "16.0.0.72", "15.12.0.2", "15.10.0.5", "15.8.0.3", "15.6.0.3", "15.4.0.0", "15.2.0.17", "15.0.0.6"
],
"mac-versions": [
"mac_versions": [
"9.1.0.5", "9.0.0.27", "8.12.0.2", "8.10.0.5", "8.8.0.3", "8.6.0.3", "8.4.0.0", "8.2.0.17", "7.14.0.27"
],
"android-versions": [
"android_versions": [
"13.2.1.2", "13.1.0.1", "13.0.0.0", "12.3.3.3", "12.2.8.3", "12.1.0.2", "12.0.0.3", "11.3.0.4"
],
"bundle-default": "6_12_21",
"bundle_default": "6_12_21",
"bundles": [
{
"symlink": "6_12_24",
@@ -149,11 +149,11 @@
"cmdline-tools": "commandlinetools-mac-9123335_latest.zip",
"platform_min_version": "27",
"build_tools_min_version": "27.0.0",
"extra-list": [
"extras": [
"android;m2repository", "google;m2repository", "google;google_play_services"
],
"addon-list": [],
"additional-tools": [
"addons": [],
"additional_tools": [
"cmake;3.18.1",
"cmake;3.22.1"
],

View File

@@ -33,11 +33,11 @@
"sdk-tools": "sdk-tools-darwin-4333796.zip",
"platform_min_version": "33",
"build_tools_min_version": "33.0.2",
"extra-list": [
"extras": [
"android;m2repository", "google;m2repository", "google;google_play_services"
],
"addon-list": [],
"additional-tools": [
"addons": [],
"additional_tools": [
"cmake;3.22.1"
],
"ndk": {

View File

@@ -29,11 +29,11 @@
"sdk-tools": "sdk-tools-darwin-4333796.zip",
"platform_min_version": "33",
"build_tools_min_version": "33.0.2",
"extra-list": [
"extras": [
"android;m2repository", "google;m2repository", "google;google_play_services"
],
"addon-list": [],
"additional-tools": [
"addons": [],
"additional_tools": [
"cmake;3.22.1"
],
"ndk": {