diff --git a/cmd/root.go b/cmd/root.go index 39cc7f31..ddb71bcd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -62,8 +62,8 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str var eventName string if len(args) > 0 { eventName = args[0] - } else if events := planner.GetEvents(); len(events) == 1 { - // set default event type if we only have a single workflow in the file. + } else if events := planner.GetEvents(); len(events) > 1 { + // set default event type to first event // this way user dont have to specify the event. log.Debugf("Using detected workflow event: %s", events[0]) eventName = events[0] diff --git a/pkg/common/executor.go b/pkg/common/executor.go index 7023e42c..f16de41d 100644 --- a/pkg/common/executor.go +++ b/pkg/common/executor.go @@ -42,7 +42,7 @@ func NewInfoExecutor(format string, args ...interface{}) Executor { // NewPipelineExecutor creates a new executor from a series of other executors func NewPipelineExecutor(executors ...Executor) Executor { - if executors == nil { + if len(executors) == 0 { return func(ctx context.Context) error { return nil } diff --git a/pkg/model/planner.go b/pkg/model/planner.go index 8a5765f8..35be015c 100644 --- a/pkg/model/planner.go +++ b/pkg/model/planner.go @@ -64,6 +64,7 @@ func NewWorkflowPlanner(dirname string) (WorkflowPlanner, error) { return nil, err } + log.Debugf("Reading workflow '%s'", f.Name()) workflow, err := ReadWorkflow(f) if err != nil { f.Close() diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index 35d34826..b823d3d6 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -24,15 +24,16 @@ import ( // RunContext contains info about current job type RunContext struct { - Config *Config - Matrix map[string]interface{} - Run *model.Run - EventJSON string - Env map[string]string - Tempdir string - ExtraPath []string - CurrentStep string - StepResults map[string]*stepResult + Config *Config + Matrix map[string]interface{} + Run *model.Run + EventJSON string + Env map[string]string + Tempdir string + ExtraPath []string + CurrentStep string + StepResults map[string]*stepResult + PlatformName string } type stepResult struct { @@ -55,6 +56,10 @@ func (rc *RunContext) Close(ctx context.Context) error { // Executor returns a pipeline executor for all the steps in the job func (rc *RunContext) Executor() common.Executor { + if img := platformImage(rc.PlatformName); img == "" { + return common.NewInfoExecutor(" \U0001F6A7 Skipping unsupported platform '%s'", rc.PlatformName) + } + err := rc.setupTempDir() if err != nil { return common.NewErrorExecutor(err) diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index c870ae46..5b378553 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -79,6 +79,9 @@ func (runner *runnerImpl) NewRunExecutor(run *model.Run, matrix map[string]inter rc.EventJSON = runner.eventJSON rc.StepResults = make(map[string]*stepResult) rc.Matrix = matrix + + ee := rc.NewExpressionEvaluator() + rc.PlatformName = ee.Interpolate(run.Job().RunsOn) return func(ctx context.Context) error { ctx = WithJobLogger(ctx, rc.Run.String()) return rc.Executor()(ctx) diff --git a/pkg/runner/step.go b/pkg/runner/step.go index 29936213..d8c7800c 100644 --- a/pkg/runner/step.go +++ b/pkg/runner/step.go @@ -34,7 +34,7 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor { containerSpec.Volumes = job.Container.Volumes containerSpec.Options = job.Container.Options } else { - containerSpec.Image = platformImage(ee.Interpolate(job.RunsOn)) + containerSpec.Image = platformImage(rc.PlatformName) } return common.NewPipelineExecutor( rc.setupShellCommand(containerSpec, step.Shell, step.Run), @@ -154,7 +154,7 @@ func (rc *RunContext) setupShellCommand(containerSpec *model.ContainerSpec, shel } func platformImage(platform string) string { - switch platform { + switch strings.ToLower(platform) { case "ubuntu-latest", "ubuntu-18.04": return "ubuntu:18.04" case "ubuntu-16.04":