From 33261492c5ae908962df7401e7326e9a34f32faa Mon Sep 17 00:00:00 2001 From: Alexey-Ayupov <116575425+Alexey-Ayupov@users.noreply.github.com> Date: Mon, 5 Feb 2024 18:16:30 +0100 Subject: [PATCH] [macOS] Add toolcache to the macOS 14 (#9274) --- .../docs-gen/Generate-SoftwareReport.ps1 | 39 +++++----- .../docs-gen/SoftwareReport.Toolcache.psm1 | 8 ++- .../macos/scripts/tests/Toolcache.Tests.ps1 | 2 +- images/macos/templates/macOS-14.anka.pkr.hcl | 12 +++- .../templates/macOS-14.arm64.anka.pkr.hcl | 12 +++- images/macos/toolsets/toolset-14.json | 72 +++++++++++++++++++ 6 files changed, 120 insertions(+), 25 deletions(-) diff --git a/images/macos/scripts/docs-gen/Generate-SoftwareReport.ps1 b/images/macos/scripts/docs-gen/Generate-SoftwareReport.ps1 index acb6db20ef0e..7c57214edf08 100644 --- a/images/macos/scripts/docs-gen/Generate-SoftwareReport.ps1 +++ b/images/macos/scripts/docs-gen/Generate-SoftwareReport.ps1 @@ -216,27 +216,26 @@ $java = $installedSoftware.AddHeader("Java") $java.AddTable($(Get-JavaVersions)) # Toolcache -if (-not $os.IsSonoma) { - $toolcache = $installedSoftware.AddHeader("Cached Tools") - $toolcache.AddNodes($(Build-ToolcacheSection)) - - # Rust - $rust = $installedSoftware.AddHeader("Rust Tools") - $rust.AddToolVersion("Cargo", $(Get-RustCargoVersion)) - $rust.AddToolVersion("Rust", $(Get-RustVersion)) - $rust.AddToolVersion("Rustdoc", $(Get-RustdocVersion)) - $rust.AddToolVersion("Rustup", $(Get-RustupVersion)) - - $rustPackages = $rust.AddHeader("Packages") - if (-not $os.IsVentura) { - $rustPackages.AddToolVersion("Bindgen", $(Get-Bindgen)) - $rustPackages.AddToolVersion("Cargo-audit", $(Get-Cargoaudit)) - $rustPackages.AddToolVersion("Cargo-outdated", $(Get-Cargooutdated)) - $rustPackages.AddToolVersion("Cbindgen", $(Get-Cbindgen)) - } - $rustPackages.AddToolVersion("Clippy", $(Get-RustClippyVersion)) - $rustPackages.AddToolVersion("Rustfmt", $(Get-RustfmtVersion)) + +$toolcache = $installedSoftware.AddHeader("Cached Tools") +$toolcache.AddNodes($(Build-ToolcacheSection)) + +# Rust +$rust = $installedSoftware.AddHeader("Rust Tools") +$rust.AddToolVersion("Cargo", $(Get-RustCargoVersion)) +$rust.AddToolVersion("Rust", $(Get-RustVersion)) +$rust.AddToolVersion("Rustdoc", $(Get-RustdocVersion)) +$rust.AddToolVersion("Rustup", $(Get-RustupVersion)) + +$rustPackages = $rust.AddHeader("Packages") +if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) { + $rustPackages.AddToolVersion("Bindgen", $(Get-Bindgen)) + $rustPackages.AddToolVersion("Cargo-audit", $(Get-Cargoaudit)) + $rustPackages.AddToolVersion("Cargo-outdated", $(Get-Cargooutdated)) + $rustPackages.AddToolVersion("Cbindgen", $(Get-Cbindgen)) } +$rustPackages.AddToolVersion("Clippy", $(Get-RustClippyVersion)) +$rustPackages.AddToolVersion("Rustfmt", $(Get-RustfmtVersion)) # PowerShell $powerShell = $installedSoftware.AddHeader("PowerShell Tools") diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 index ad5c41881299..18fc1bdf3332 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 @@ -37,12 +37,16 @@ function Build-ToolcacheSection { $nodes = @() - if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) { + if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) { $nodes += @( - [ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List"), [ToolVersionsListNode]::new("PyPy", $(Get-ToolcachePyPyVersions), '^\d+\.\d+', "List") ) } + if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) { + $nodes += @( + [ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List") + ) + } $nodes += @( [ToolVersionsListNode]::new("Python", $(Get-ToolcachePythonVersions), '^\d+\.\d+', "List"), diff --git a/images/macos/scripts/tests/Toolcache.Tests.ps1 b/images/macos/scripts/tests/Toolcache.Tests.ps1 index 4f57962ec6a8..623a41632a2d 100644 --- a/images/macos/scripts/tests/Toolcache.Tests.ps1 +++ b/images/macos/scripts/tests/Toolcache.Tests.ps1 @@ -99,7 +99,7 @@ Describe "Toolcache" { } } } - Context "PyPy" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) { + Context "PyPy" -Skip:($os.IsVenturaArm64 -or $os.IsSonoma) { $pypyDirectory = Join-Path $toolcacheDirectory "PyPy" $pypyPackage = $packages | Where-Object { $_.ToolName -eq "pypy" } | Select-Object -First 1 $testCase = @{ PypyDirectory = $pypyDirectory } diff --git a/images/macos/templates/macOS-14.anka.pkr.hcl b/images/macos/templates/macOS-14.anka.pkr.hcl index 38c6396afb09..89fccc987c07 100644 --- a/images/macos/templates/macOS-14.anka.pkr.hcl +++ b/images/macos/templates/macOS-14.anka.pkr.hcl @@ -228,6 +228,15 @@ build { ] } + provisioner "shell" { + environment_vars = ["IMAGE_FOLDER=${local.image_folder}"] + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" + scripts = [ + "${path.root}/../scripts/build/Install-Toolset.ps1", + "${path.root}/../scripts/build/Configure-Toolset.ps1" + ] + } + provisioner "shell" { execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}" script = "${path.root}/../scripts/build/configure-xcode-simulators.rb" @@ -237,7 +246,8 @@ build { environment_vars = ["IMAGE_FOLDER=${local.image_folder}"] execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" inline = [ - "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}" + "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}", + "pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\"" ] } diff --git a/images/macos/templates/macOS-14.arm64.anka.pkr.hcl b/images/macos/templates/macOS-14.arm64.anka.pkr.hcl index 19d25641966d..360251efd05b 100644 --- a/images/macos/templates/macOS-14.arm64.anka.pkr.hcl +++ b/images/macos/templates/macOS-14.arm64.anka.pkr.hcl @@ -223,6 +223,15 @@ build { ] } + provisioner "shell" { + environment_vars = ["IMAGE_FOLDER=${local.image_folder}"] + execute_command = "chmod +x {{ .Path }}; source $HOME/.bash_profile; {{ .Vars }} pwsh -f {{ .Path }}" + scripts = [ + "${path.root}/../scripts/build/Install-Toolset.ps1", + "${path.root}/../scripts/build/Configure-Toolset.ps1" + ] + } + provisioner "shell" { execute_command = "source $HOME/.bash_profile; ruby {{ .Path }}" script = "${path.root}/../scripts/build/configure-xcode-simulators.rb" @@ -232,7 +241,8 @@ build { environment_vars = ["IMAGE_FOLDER=${local.image_folder}"] execute_command = "source $HOME/.bash_profile; {{ .Vars }} {{ .Path }}" inline = [ - "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}" + "pwsh -File \"${local.image_folder}/software-report/Generate-SoftwareReport.ps1\" -OutputDirectory \"${local.image_folder}/output/software-report\" -ImageName ${var.build_id}", + "pwsh -File \"${local.image_folder}/tests/RunAll-Tests.ps1\"" ] } diff --git a/images/macos/toolsets/toolset-14.json b/images/macos/toolsets/toolset-14.json index 47d3290f8b9d..2d3cbc459d26 100644 --- a/images/macos/toolsets/toolset-14.json +++ b/images/macos/toolsets/toolset-14.json @@ -112,6 +112,78 @@ "fastlane" ] }, + "toolcache": [ + { + "name": "Python", + "url" : "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json", + "platform" : "darwin", + "arch": { + "x64": { + "versions": [ + "3.11.*", + "3.12.*" + ] + }, + "arm64": { + "versions": [ + "3.11.*", + "3.12.*" + ] + } + } + }, + { + "name": "Node", + "url" : "https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json", + "platform" : "darwin", + "arch": { + "x64": { + "versions": [ + "18.*", + "20.*" + ] + }, + "arm64": { + "versions": [ + "18.*", + "20.*" + ] + } + } + }, + { + "name": "Go", + "url" : "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json", + "platform" : "darwin", + "arch": { + "x64": { + "variable_template" : "GOROOT_{0}_{1}_X64", + "versions": [ + "1.20.*", + "1.21.*" + ] + }, + "arm64": { + "variable_template" : "GOROOT_{0}_{1}_ARM64", + "versions": [ + "1.20.*", + "1.21.*" + ] + } + } + }, + { + "name": "Ruby", + "arch": { + "x64": { + "versions": [ + "3.0.*", + "3.1.*" + ] + } + } + } + ], "go": { "default": "1.20" },