enhance: add macOS VM executor backend

Replace the Tart-based prototype with a runner-oriented macOS VM
executor backed by runner-executor-macos and Apple Virtualization.

Assisted-by: Codet:MODEL_VERSION
This commit is contained in:
Lunny Xiao
2026-09-05 13:20:03 -07:00
parent 1745c7c841
commit 2db24c7401
18 changed files with 1167 additions and 15 deletions
+19 -4
View File
@@ -9,11 +9,15 @@ import (
)
const (
SchemeHost = "host"
SchemeDocker = "docker"
SchemeHost = "host"
SchemeDocker = "docker"
SchemeMacOSVM = "macos-vm"
// SelfHostedPlatform is the platform marker act treats as "run on the host".
SelfHostedPlatform = "-self-hosted"
// MacOSVMSchemePrefix marks a platform image that act should run in a macOS VM.
MacOSVMSchemePrefix = "macos-vm://"
)
type Label struct {
@@ -42,7 +46,7 @@ func Parse(str string) (*Label, error) {
if len(splits) >= 3 {
label.Arg = splits[2]
}
if label.Schema != SchemeHost && label.Schema != SchemeDocker {
if label.Schema != SchemeHost && label.Schema != SchemeDocker && label.Schema != SchemeMacOSVM {
// Not a schema we know: the colon belongs to the label name itself.
return &Label{
Name: str,
@@ -64,6 +68,15 @@ func (l Labels) RequireDocker() bool {
return false
}
func (l Labels) RequireMacOSVM() bool {
for _, label := range l {
if label.Schema == SchemeMacOSVM {
return true
}
}
return false
}
// PickPlatform returns the platform of the first runs-on entry this runner has a label for, or "".
func (l Labels) PickPlatform(runsOn []string) string {
platforms := make(map[string]string, len(l))
@@ -72,10 +85,12 @@ func (l Labels) PickPlatform(runsOn []string) string {
case SchemeDocker:
// "//" will be ignored
platforms[label.Name] = strings.TrimPrefix(label.Arg, "//")
case SchemeMacOSVM:
platforms[label.Name] = MacOSVMSchemePrefix + strings.TrimPrefix(label.Arg, "//")
case SchemeHost:
platforms[label.Name] = SelfHostedPlatform
default:
// unreachable: Parse only produces host or docker schemas
// unreachable: Parse only produces host, docker, or macOS VM schemas
continue
}
}
+32
View File
@@ -25,6 +25,15 @@ func TestParse(t *testing.T) {
},
wantErr: false,
},
{
args: "macos-latest:macos-vm://ghcr.io/cirruslabs/macos-sonoma-base:latest",
want: &Label{
Name: "macos-latest",
Schema: "macos-vm",
Arg: "//ghcr.io/cirruslabs/macos-sonoma-base:latest",
},
wantErr: false,
},
{
args: "ubuntu:host",
want: &Label{
@@ -103,6 +112,7 @@ func TestRequireDocker(t *testing.T) {
{"empty", nil, false},
{"only host", []string{"ubuntu:host", "self-hosted"}, false},
{"has docker", []string{"ubuntu:host", "ubuntu:docker://node:18"}, true},
{"macos-vm does not require docker", []string{"macos-latest:macos-vm://ghcr.io/cirruslabs/macos-sonoma-base:latest"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
@@ -111,10 +121,29 @@ func TestRequireDocker(t *testing.T) {
}
}
func TestRequireMacOSVM(t *testing.T) {
tests := []struct {
name string
strs []string
want bool
}{
{"empty", nil, false},
{"only host", []string{"ubuntu:host", "self-hosted"}, false},
{"only docker", []string{"ubuntu:docker://node:18"}, false},
{"has macos-vm", []string{"macos-latest:macos-vm://ghcr.io/cirruslabs/macos-sonoma-base:latest"}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.want, mustParse(t, tt.strs...).RequireMacOSVM())
})
}
}
func TestPickPlatform(t *testing.T) {
ls := mustParse(t,
"ubuntu:docker://node:18",
"self-hosted:host",
"macos-latest:macos-vm://ghcr.io/cirruslabs/macos-sonoma-base:latest",
)
tests := []struct {
@@ -124,6 +153,7 @@ func TestPickPlatform(t *testing.T) {
}{
{"docker strips leading slashes", []string{"ubuntu"}, "node:18"},
{"host maps to self-hosted marker", []string{"self-hosted"}, SelfHostedPlatform},
{"macos-vm prefixes platform marker", []string{"macos-latest"}, MacOSVMSchemePrefix + "ghcr.io/cirruslabs/macos-sonoma-base:latest"},
{"first match wins", []string{"self-hosted", "ubuntu"}, SelfHostedPlatform},
{"unknown label picks nothing", []string{"windows"}, ""},
{"no runsOn picks nothing", nil, ""},
@@ -145,12 +175,14 @@ func TestToStrings(t *testing.T) {
ls := mustParse(t,
"ubuntu:docker://node:18",
"self-hosted:host",
"macos-latest:macos-vm://ghcr.io/cirruslabs/macos-sonoma-base:latest",
"bare",
"pool:e57e18d4",
)
require.Equal(t, []string{
"ubuntu:docker://node:18",
"self-hosted:host",
"macos-latest:macos-vm://ghcr.io/cirruslabs/macos-sonoma-base:latest",
"bare:host",
"pool:e57e18d4",
}, ls.ToStrings())