From 1cf422e41108bf72ec837bea66e080d400ca1192 Mon Sep 17 00:00:00 2001 From: "Ryan (hackercat)" Date: Wed, 23 Jun 2021 18:09:27 +0000 Subject: [PATCH] fix: warn Apple M1 (arm64) users (#743) * fix: warn Apple M1 (arm64) users * fix: missing dep * fix: linting * fix: linting (again) --- cmd/root.go | 13 +++++++++++-- pkg/runner/command_test.go | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 9b75b88..214dbad 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -6,10 +6,9 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strings" - "github.com/nektos/act/pkg/common" - "github.com/AlecAivazis/survey/v2" "github.com/andreaskoch/go-fswatch" "github.com/joho/godotenv" @@ -18,6 +17,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "github.com/nektos/act/pkg/common" "github.com/nektos/act/pkg/model" "github.com/nektos/act/pkg/runner" ) @@ -152,6 +152,15 @@ func readEnvs(path string, envs map[string]string) bool { //nolint:gocyclo func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []string) error { return func(cmd *cobra.Command, args []string) error { + if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" && input.containerArchitecture == "" { + l := log.New() + l.SetFormatter(&log.TextFormatter{ + DisableQuote: true, + DisableTimestamp: true, + }) + l.Warnf(" \U000026A0 You are using Apple M1 chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. \U000026A0 \n") + } + log.Debugf("Loading environment from %s", input.Envfile()) envs := make(map[string]string) if input.envs != nil { diff --git a/pkg/runner/command_test.go b/pkg/runner/command_test.go index eb80e46..d4981fe 100644 --- a/pkg/runner/command_test.go +++ b/pkg/runner/command_test.go @@ -4,9 +4,10 @@ import ( "context" "testing" - "github.com/nektos/act/pkg/common" "github.com/sirupsen/logrus/hooks/test" "github.com/stretchr/testify/assert" + + "github.com/nektos/act/pkg/common" ) func TestSetEnv(t *testing.T) {