Skip to content

Commit

Permalink
[macOS] Add toolcache to the macOS 14 (actions#9274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-Ayupov authored Feb 5, 2024
1 parent 3387580 commit 3326149
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 25 deletions.
39 changes: 19 additions & 20 deletions images/macos/scripts/docs-gen/Generate-SoftwareReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 6 additions & 2 deletions images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion images/macos/scripts/tests/Toolcache.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
12 changes: 11 additions & 1 deletion images/macos/templates/macOS-14.anka.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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\""
]
}

Expand Down
12 changes: 11 additions & 1 deletion images/macos/templates/macOS-14.arm64.anka.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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\""
]
}

Expand Down
72 changes: 72 additions & 0 deletions images/macos/toolsets/toolset-14.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit 3326149

Please sign in to comment.