parent
e739f72c5e
commit
21e2bb8657
|
@ -1,7 +1,6 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
|
@ -39,7 +38,7 @@ func (r *Run) String() string {
|
|||
if jobName == "" {
|
||||
jobName = r.JobID
|
||||
}
|
||||
return fmt.Sprintf("%s/%s", r.Workflow.Name, jobName)
|
||||
return jobName
|
||||
}
|
||||
|
||||
// Job returns the job for this Run
|
||||
|
|
|
@ -272,7 +272,7 @@ func (rc *RunContext) vmRunner() func(*otto.Otto) {
|
|||
runner := map[string]interface{}{
|
||||
"os": "Linux",
|
||||
"temp": "/tmp",
|
||||
"tool_cache": "/tmp",
|
||||
"tool_cache": "/opt/hostedtoolcache",
|
||||
}
|
||||
|
||||
return func(vm *otto.Otto) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -52,7 +52,7 @@ func New(runnerConfig *Config) (Runner, error) {
|
|||
}
|
||||
|
||||
func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||
maxJobNameLen := plan.MaxRunNameLen()
|
||||
maxJobNameLen := 0
|
||||
|
||||
pipeline := make([]common.Executor, 0)
|
||||
for _, stage := range plan.Stages {
|
||||
|
@ -61,16 +61,17 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
|||
job := run.Job()
|
||||
matrixes := job.GetMatrixes()
|
||||
|
||||
jobName := fmt.Sprintf("%-*s", maxJobNameLen, run.String())
|
||||
for _, matrix := range matrixes {
|
||||
m := matrix
|
||||
runExecutor := runner.newRunExecutor(run, matrix)
|
||||
stageExecutor = append(stageExecutor, func(ctx context.Context) error {
|
||||
ctx = WithJobLogger(ctx, jobName)
|
||||
if len(m) > 0 {
|
||||
common.Logger(ctx).Infof("\U0001F9EA Matrix: %v", m)
|
||||
for i, matrix := range matrixes {
|
||||
rc := runner.newRunContext(run, matrix)
|
||||
if len(matrix) > 1 {
|
||||
rc.Name = fmt.Sprintf("%s-%d", rc.Name, i+1)
|
||||
}
|
||||
return runExecutor(ctx)
|
||||
if len(rc.String()) > maxJobNameLen {
|
||||
maxJobNameLen = len(rc.String())
|
||||
}
|
||||
stageExecutor = append(stageExecutor, func(ctx context.Context) error {
|
||||
jobName := fmt.Sprintf("%-*s", maxJobNameLen, rc.String())
|
||||
return rc.Executor()(WithJobLogger(ctx, jobName))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
|||
return common.NewPipelineExecutor(pipeline...)
|
||||
}
|
||||
|
||||
func (runner *runnerImpl) newRunExecutor(run *model.Run, matrix map[string]interface{}) common.Executor {
|
||||
func (runner *runnerImpl) newRunContext(run *model.Run, matrix map[string]interface{}) *RunContext {
|
||||
rc := &RunContext{
|
||||
Config: runner.config,
|
||||
Run: run,
|
||||
|
@ -89,5 +90,6 @@ func (runner *runnerImpl) newRunExecutor(run *model.Run, matrix map[string]inter
|
|||
Matrix: matrix,
|
||||
}
|
||||
rc.ExprEval = rc.NewExpressionEvaluator()
|
||||
return rc.Executor()
|
||||
rc.Name = rc.ExprEval.Interpolate(run.String())
|
||||
return rc
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ func TestRunEvent(t *testing.T) {
|
|||
{"remote-action-js", "push", ""},
|
||||
{"local-action-docker-url", "push", ""},
|
||||
{"local-action-dockerfile", "push", ""},
|
||||
{"matrix", "push", ""},
|
||||
{"commands", "push", ""},
|
||||
}
|
||||
log.SetLevel(log.DebugLevel)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ on: push
|
|||
|
||||
jobs:
|
||||
build:
|
||||
name: PHP ${{ matrix.os }} ${{ matrix.node}}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- run: echo ${NODE_VERSION} | grep ${{ matrix.node }}
|
||||
|
|
Loading…
Reference in New Issue