fix #108 - support matrix expressions in job name (#109)

This commit is contained in:
Casey Lee
2020-02-26 23:29:43 -08:00
committed by GitHub
parent e739f72c5e
commit 21e2bb8657
6 changed files with 34 additions and 17 deletions

View File

@@ -20,6 +20,7 @@ import (
// RunContext contains info about current job
type RunContext struct {
Name string
Config *Config
Matrix map[string]interface{}
Run *model.Run
@@ -32,6 +33,10 @@ type RunContext struct {
JobContainer container.Container
}
func (rc *RunContext) String() string {
return fmt.Sprintf("%s/%s", rc.Run.Workflow.Name, rc.Name)
}
type stepResult struct {
Success bool `json:"success"`
Outputs map[string]string `json:"outputs"`
@@ -46,7 +51,7 @@ func (rc *RunContext) GetEnv() map[string]string {
}
func (rc *RunContext) jobContainerName() string {
return createContainerName("act", rc.Run.String())
return createContainerName("act", rc.String())
}
func (rc *RunContext) startJobContainer() common.Executor {
@@ -156,6 +161,14 @@ func (rc *RunContext) ActionCacheDir() string {
// Executor returns a pipeline executor for all the steps in the job
func (rc *RunContext) Executor() common.Executor {
steps := make([]common.Executor, 0)
steps = append(steps, func(ctx context.Context) error {
if len(rc.Matrix) > 0 {
common.Logger(ctx).Infof("\U0001F9EA Matrix: %v", rc.Matrix)
}
return nil
})
steps = append(steps, rc.startJobContainer())
for i, step := range rc.Run.Job().Steps {
@@ -209,7 +222,7 @@ func (rc *RunContext) isEnabled(ctx context.Context) bool {
platformName := rc.ExprEval.Interpolate(rc.Run.Job().RunsOn)
if img, ok := rc.Config.Platforms[strings.ToLower(platformName)]; !ok || img == "" {
log.Infof(" \U0001F6A7 Skipping unsupported platform '%s'", platformName)
log.Infof("\U0001F6A7 Skipping unsupported platform '%s'", platformName)
return false
}
return true