From 0b1999e92eae8eda259d9b1f8e608d5bec638359 Mon Sep 17 00:00:00 2001 From: fedor Date: Tue, 29 Nov 2022 15:23:19 -0500 Subject: [PATCH 1/2] Advanced archiotecture guessing Similar to platform guessing we can check if the instances has "Arm" in the type url. Related to https://github.com/cirruslabs/cirrus-ci-docs/pull/905#issuecomment-1330488930 --- pkg/parser/instance/proto.go | 15 ++++++++++++--- pkg/parser/task/task.go | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/parser/instance/proto.go b/pkg/parser/instance/proto.go index 4762e0cf..b0a0b617 100644 --- a/pkg/parser/instance/proto.go +++ b/pkg/parser/instance/proto.go @@ -380,9 +380,18 @@ func GuessPlatformOfProtoMessage(message protoreflect.Message, descriptor protor return "" } -func GuessArchitectureOfProtoMessage(anyInstance *anypb.Any, descriptor protoreflect.MessageDescriptor) string { - message := dynamicpb.NewMessage(descriptor) - _ = proto.Unmarshal(anyInstance.GetValue(), message) +func GuessArchitecture(anyInstance *anypb.Any, descriptor protoreflect.MessageDescriptor) string { + instanceType := anyInstance.TypeUrl + if strings.Contains(instanceType, "Arm") { + return "arm64" + } + + dynamicMessage := dynamicpb.NewMessage(descriptor) + _ = proto.Unmarshal(anyInstance.GetValue(), dynamicMessage) + return GuessArchitectureOfProtoMessage(dynamicMessage, descriptor) +} + +func GuessArchitectureOfProtoMessage(message protoreflect.Message, descriptor protoreflect.MessageDescriptor) string { fields := descriptor.Fields() architectureField := fields.ByJSONName("architecture") if architectureField != nil && message.Has(architectureField) { diff --git a/pkg/parser/task/task.go b/pkg/parser/task/task.go index 3088b878..43ea4d6b 100644 --- a/pkg/parser/task/task.go +++ b/pkg/parser/task/task.go @@ -209,7 +209,7 @@ func NewTask( }, ) } - architecture := instance.GuessArchitectureOfProtoMessage(anyInstance, scopedDescriptor) + architecture := instance.GuessArchitecture(anyInstance, scopedDescriptor) if architecture != "" { task.proto.Environment = environment.Merge( task.proto.Environment, map[string]string{ From 0d9e7e8fe50b6b98528141391d9c9aad1cd48ce7 Mon Sep 17 00:00:00 2001 From: fedor Date: Wed, 30 Nov 2022 08:20:48 -0500 Subject: [PATCH 2/2] Use scaleway worker --- .cirrus.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 5727fbf1..c612714c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -45,8 +45,7 @@ task: alias: Tests persistent_worker: labels: - os: darwin - tart: installed + name: scaleway-m1 env: CIRRUS_INTERNAL_TART_VM: ghcr.io/cirruslabs/macos-monterey-vanilla:12.4 CIRRUS_INTERNAL_TART_SSH_PASSWORD: admin