feat: --validate and --strict (#2717)
* feat: `--validate` and `--strict` * fix missing changes * add test for strict validate --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,8 @@ type Input struct {
|
|||||||
useNewActionCache bool
|
useNewActionCache bool
|
||||||
localRepository []string
|
localRepository []string
|
||||||
listOptions bool
|
listOptions bool
|
||||||
|
validate bool
|
||||||
|
strict bool
|
||||||
concurrentJobs int
|
concurrentJobs int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ func createRootCommand(ctx context.Context, input *Input, version string) *cobra
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootCmd.Flags().BoolP("watch", "w", false, "watch the contents of the local repo and run when files change")
|
rootCmd.Flags().BoolP("watch", "w", false, "watch the contents of the local repo and run when files change")
|
||||||
|
rootCmd.Flags().BoolVar(&input.validate, "validate", false, "validate workflows")
|
||||||
|
rootCmd.Flags().BoolVar(&input.strict, "strict", false, "use strict workflow schema")
|
||||||
rootCmd.Flags().BoolP("list", "l", false, "list workflows")
|
rootCmd.Flags().BoolP("list", "l", false, "list workflows")
|
||||||
rootCmd.Flags().BoolP("graph", "g", false, "draw workflows")
|
rootCmd.Flags().BoolP("graph", "g", false, "draw workflows")
|
||||||
rootCmd.Flags().StringP("job", "j", "", "run a specific job ID")
|
rootCmd.Flags().StringP("job", "j", "", "run a specific job ID")
|
||||||
@@ -446,7 +448,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
|||||||
matrixes := parseMatrix(input.matrix)
|
matrixes := parseMatrix(input.matrix)
|
||||||
log.Debugf("Evaluated matrix inclusions: %v", matrixes)
|
log.Debugf("Evaluated matrix inclusions: %v", matrixes)
|
||||||
|
|
||||||
planner, err := model.NewWorkflowPlanner(input.WorkflowsPath(), input.noWorkflowRecurse)
|
planner, err := model.NewWorkflowPlanner(input.WorkflowsPath(), input.noWorkflowRecurse, input.strict)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -462,6 +464,11 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if we should just validate the workflows
|
||||||
|
if input.validate {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// check if we should just draw the graph
|
// check if we should just draw the graph
|
||||||
graph, err := cmd.Flags().GetBool("graph")
|
graph, err := cmd.Flags().GetBool("graph")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ func runTestJobFile(ctx context.Context, t *testing.T, tjfi TestJobFileInfo) {
|
|||||||
runner, err := runner.New(runnerConfig)
|
runner, err := runner.New(runnerConfig)
|
||||||
assert.Nil(t, err, tjfi.workflowPath)
|
assert.Nil(t, err, tjfi.workflowPath)
|
||||||
|
|
||||||
planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true)
|
planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true, false)
|
||||||
assert.Nil(t, err, fullWorkflowPath)
|
assert.Nil(t, err, fullWorkflowPath)
|
||||||
|
|
||||||
plan, err := planner.PlanEvent(tjfi.eventName)
|
plan, err := planner.PlanEvent(tjfi.eventName)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ type WorkflowFiles struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories
|
// NewWorkflowPlanner will load a specific workflow, all workflows from a directory or all workflows from a directory and its subdirectories
|
||||||
func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, error) {
|
func NewWorkflowPlanner(path string, noWorkflowRecurse, strict bool) (WorkflowPlanner, error) {
|
||||||
path, err := filepath.Abs(path)
|
path, err := filepath.Abs(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -124,7 +124,7 @@ func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Reading workflow '%s'", f.Name())
|
log.Debugf("Reading workflow '%s'", f.Name())
|
||||||
workflow, err := ReadWorkflow(f)
|
workflow, err := ReadWorkflow(f, strict)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
@@ -161,7 +161,7 @@ func NewSingleWorkflowPlanner(name string, f io.Reader) (WorkflowPlanner, error)
|
|||||||
wp := new(workflowPlanner)
|
wp := new(workflowPlanner)
|
||||||
|
|
||||||
log.Debugf("Reading workflow %s", name)
|
log.Debugf("Reading workflow %s", name)
|
||||||
workflow, err := ReadWorkflow(f)
|
workflow, err := ReadWorkflow(f, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return nil, fmt.Errorf("unable to read workflow '%s': file is empty: %w", name, err)
|
return nil, fmt.Errorf("unable to read workflow '%s': file is empty: %w", name, err)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func TestPlanner(t *testing.T) {
|
|||||||
assert.NoError(t, err, workdir)
|
assert.NoError(t, err, workdir)
|
||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
fullWorkflowPath := filepath.Join(workdir, table.workflowPath)
|
fullWorkflowPath := filepath.Join(workdir, table.workflowPath)
|
||||||
_, err = NewWorkflowPlanner(fullWorkflowPath, table.noWorkflowRecurse)
|
_, err = NewWorkflowPlanner(fullWorkflowPath, table.noWorkflowRecurse, false)
|
||||||
if table.errorMessage == "" {
|
if table.errorMessage == "" {
|
||||||
assert.NoError(t, err, "WorkflowPlanner should exit without any error")
|
assert.NoError(t, err, "WorkflowPlanner should exit without any error")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -80,6 +80,20 @@ func (w *Workflow) UnmarshalYAML(node *yaml.Node) error {
|
|||||||
return node.Decode((*WorkflowDefault)(w))
|
return node.Decode((*WorkflowDefault)(w))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WorkflowStrict Workflow
|
||||||
|
|
||||||
|
func (w *WorkflowStrict) UnmarshalYAML(node *yaml.Node) error {
|
||||||
|
// Validate the schema before deserializing it into our model
|
||||||
|
if err := (&schema.Node{
|
||||||
|
Definition: "workflow-root-strict",
|
||||||
|
Schema: schema.GetWorkflowSchema(),
|
||||||
|
}).UnmarshalYAML(node); err != nil {
|
||||||
|
return errors.Join(err, fmt.Errorf("Actions YAML Strict Schema Validation Error detected:\nFor more information, see: https://nektosact.com/usage/schema.html"))
|
||||||
|
}
|
||||||
|
type WorkflowDefault Workflow
|
||||||
|
return node.Decode((*WorkflowDefault)(w))
|
||||||
|
}
|
||||||
|
|
||||||
type WorkflowDispatchInput struct {
|
type WorkflowDispatchInput struct {
|
||||||
Description string `yaml:"description"`
|
Description string `yaml:"description"`
|
||||||
Required bool `yaml:"required"`
|
Required bool `yaml:"required"`
|
||||||
@@ -711,7 +725,12 @@ func (s *Step) Type() StepType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReadWorkflow returns a list of jobs for a given workflow file reader
|
// ReadWorkflow returns a list of jobs for a given workflow file reader
|
||||||
func ReadWorkflow(in io.Reader) (*Workflow, error) {
|
func ReadWorkflow(in io.Reader, strict bool) (*Workflow, error) {
|
||||||
|
if strict {
|
||||||
|
w := new(WorkflowStrict)
|
||||||
|
err := yaml.NewDecoder(in).Decode(w)
|
||||||
|
return (*Workflow)(w), err
|
||||||
|
}
|
||||||
w := new(Workflow)
|
w := new(Workflow)
|
||||||
err := yaml.NewDecoder(in).Decode(w)
|
err := yaml.NewDecoder(in).Decode(w)
|
||||||
return w, err
|
return w, err
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
- uses: ./actions/docker-url
|
- uses: ./actions/docker-url
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
|
|
||||||
assert.Len(t, workflow.On(), 1)
|
assert.Len(t, workflow.On(), 1)
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
- uses: ./actions/docker-url
|
- uses: ./actions/docker-url
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
|
|
||||||
assert.Len(t, workflow.On(), 2)
|
assert.Len(t, workflow.On(), 2)
|
||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
- uses: ./actions/docker-url
|
- uses: ./actions/docker-url
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Len(t, workflow.On(), 2)
|
assert.Len(t, workflow.On(), 2)
|
||||||
assert.Contains(t, workflow.On(), "push")
|
assert.Contains(t, workflow.On(), "push")
|
||||||
@@ -83,7 +83,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: ./actions/docker-url`
|
- uses: ./actions/docker-url`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Equal(t, workflow.Jobs["test"].RunsOn(), []string{"ubuntu-latest"})
|
assert.Equal(t, workflow.Jobs["test"].RunsOn(), []string{"ubuntu-latest"})
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: ./actions/docker-url`
|
- uses: ./actions/docker-url`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Equal(t, workflow.Jobs["test"].RunsOn(), []string{"ubuntu-latest", "linux"})
|
assert.Equal(t, workflow.Jobs["test"].RunsOn(), []string{"ubuntu-latest", "linux"})
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ jobs:
|
|||||||
- uses: ./actions/docker-url
|
- uses: ./actions/docker-url
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Len(t, workflow.Jobs, 2)
|
assert.Len(t, workflow.Jobs, 2)
|
||||||
assert.Contains(t, workflow.Jobs["test"].Container().Image, "nginx:latest")
|
assert.Contains(t, workflow.Jobs["test"].Container().Image, "nginx:latest")
|
||||||
@@ -156,7 +156,7 @@ jobs:
|
|||||||
- uses: ./actions/docker-url
|
- uses: ./actions/docker-url
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Len(t, workflow.Jobs, 1)
|
assert.Len(t, workflow.Jobs, 1)
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ jobs:
|
|||||||
uses: ./some/path/to/workflow.yaml
|
uses: ./some/path/to/workflow.yaml
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Len(t, workflow.Jobs, 6)
|
assert.Len(t, workflow.Jobs, 6)
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ jobs:
|
|||||||
uses: some/path/to/workflow.yaml
|
uses: some/path/to/workflow.yaml
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Len(t, workflow.Jobs, 4)
|
assert.Len(t, workflow.Jobs, 4)
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ jobs:
|
|||||||
uses: ./local-action
|
uses: ./local-action
|
||||||
`
|
`
|
||||||
|
|
||||||
_, err := ReadWorkflow(strings.NewReader(yaml))
|
_, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.Error(t, err, "read workflow should fail")
|
assert.Error(t, err, "read workflow should fail")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ jobs:
|
|||||||
echo "${{ needs.test1.outputs.some-b-key }}"
|
echo "${{ needs.test1.outputs.some-b-key }}"
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
assert.Len(t, workflow.Jobs, 2)
|
assert.Len(t, workflow.Jobs, 2)
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestReadWorkflow_Strategy(t *testing.T) {
|
func TestReadWorkflow_Strategy(t *testing.T) {
|
||||||
w, err := NewWorkflowPlanner("testdata/strategy/push.yml", true)
|
w, err := NewWorkflowPlanner("testdata/strategy/push.yml", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
p, err := w.PlanJob("strategy-only-max-parallel")
|
p, err := w.PlanJob("strategy-only-max-parallel")
|
||||||
@@ -418,7 +418,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
yaml := `
|
yaml := `
|
||||||
name: local-action-docker-url
|
name: local-action-docker-url
|
||||||
`
|
`
|
||||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
workflow, err := ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch := workflow.WorkflowDispatchConfig()
|
workflowDispatch := workflow.WorkflowDispatchConfig()
|
||||||
assert.Nil(t, workflowDispatch)
|
assert.Nil(t, workflowDispatch)
|
||||||
@@ -427,7 +427,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
name: local-action-docker-url
|
name: local-action-docker-url
|
||||||
on: push
|
on: push
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.Nil(t, workflowDispatch)
|
assert.Nil(t, workflowDispatch)
|
||||||
@@ -436,7 +436,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
name: local-action-docker-url
|
name: local-action-docker-url
|
||||||
on: workflow_dispatch
|
on: workflow_dispatch
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.NotNil(t, workflowDispatch)
|
assert.NotNil(t, workflowDispatch)
|
||||||
@@ -446,7 +446,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
name: local-action-docker-url
|
name: local-action-docker-url
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.Nil(t, workflowDispatch)
|
assert.Nil(t, workflowDispatch)
|
||||||
@@ -455,7 +455,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
name: local-action-docker-url
|
name: local-action-docker-url
|
||||||
on: [push, workflow_dispatch]
|
on: [push, workflow_dispatch]
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.NotNil(t, workflowDispatch)
|
assert.NotNil(t, workflowDispatch)
|
||||||
@@ -467,7 +467,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
- push
|
- push
|
||||||
- workflow_dispatch
|
- workflow_dispatch
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.NotNil(t, workflowDispatch)
|
assert.NotNil(t, workflowDispatch)
|
||||||
@@ -479,7 +479,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.Nil(t, workflowDispatch)
|
assert.Nil(t, workflowDispatch)
|
||||||
@@ -501,7 +501,7 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
- warning
|
- warning
|
||||||
- debug
|
- debug
|
||||||
`
|
`
|
||||||
workflow, err = ReadWorkflow(strings.NewReader(yaml))
|
workflow, err = ReadWorkflow(strings.NewReader(yaml), false)
|
||||||
assert.NoError(t, err, "read workflow should succeed")
|
assert.NoError(t, err, "read workflow should succeed")
|
||||||
workflowDispatch = workflow.WorkflowDispatchConfig()
|
workflowDispatch = workflow.WorkflowDispatchConfig()
|
||||||
assert.NotNil(t, workflowDispatch)
|
assert.NotNil(t, workflowDispatch)
|
||||||
@@ -517,3 +517,19 @@ func TestReadWorkflow_WorkflowDispatchConfig(t *testing.T) {
|
|||||||
Type: "choice",
|
Type: "choice",
|
||||||
}, workflowDispatch.Inputs["logLevel"])
|
}, workflowDispatch.Inputs["logLevel"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadWorkflow_InvalidStringEvent(t *testing.T) {
|
||||||
|
yaml := `
|
||||||
|
name: local-action-docker-url
|
||||||
|
on: push2
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: ./actions/docker-url
|
||||||
|
`
|
||||||
|
|
||||||
|
_, err := ReadWorkflow(strings.NewReader(yaml), true)
|
||||||
|
assert.Error(t, err, "read workflow should succeed")
|
||||||
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ func cloneIfRequired(rc *RunContext, remoteReusableWorkflow remoteReusableWorkfl
|
|||||||
|
|
||||||
func newReusableWorkflowExecutor(rc *RunContext, directory string, workflow string) common.Executor {
|
func newReusableWorkflowExecutor(rc *RunContext, directory string, workflow string) common.Executor {
|
||||||
return func(ctx context.Context) error {
|
return func(ctx context.Context) error {
|
||||||
planner, err := model.NewWorkflowPlanner(path.Join(directory, workflow), true)
|
planner, err := model.NewWorkflowPlanner(path.Join(directory, workflow), true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNoWorkflowsFoundByPlanner(t *testing.T) {
|
func TestNoWorkflowsFoundByPlanner(t *testing.T) {
|
||||||
planner, err := model.NewWorkflowPlanner("res", true)
|
planner, err := model.NewWorkflowPlanner("res", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
out := log.StandardLogger().Out
|
out := log.StandardLogger().Out
|
||||||
@@ -75,7 +75,7 @@ func TestNoWorkflowsFoundByPlanner(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGraphMissingEvent(t *testing.T) {
|
func TestGraphMissingEvent(t *testing.T) {
|
||||||
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-event.yml", true)
|
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-event.yml", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
out := log.StandardLogger().Out
|
out := log.StandardLogger().Out
|
||||||
@@ -93,7 +93,7 @@ func TestGraphMissingEvent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGraphMissingFirst(t *testing.T) {
|
func TestGraphMissingFirst(t *testing.T) {
|
||||||
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-first.yml", true)
|
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/no-first.yml", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
plan, err := planner.PlanEvent("push")
|
plan, err := planner.PlanEvent("push")
|
||||||
@@ -103,7 +103,7 @@ func TestGraphMissingFirst(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGraphWithMissing(t *testing.T) {
|
func TestGraphWithMissing(t *testing.T) {
|
||||||
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/missing.yml", true)
|
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/missing.yml", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
out := log.StandardLogger().Out
|
out := log.StandardLogger().Out
|
||||||
@@ -122,7 +122,7 @@ func TestGraphWithMissing(t *testing.T) {
|
|||||||
func TestGraphWithSomeMissing(t *testing.T) {
|
func TestGraphWithSomeMissing(t *testing.T) {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
|
|
||||||
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/", true)
|
planner, err := model.NewWorkflowPlanner("testdata/issue-1595/", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
out := log.StandardLogger().Out
|
out := log.StandardLogger().Out
|
||||||
@@ -140,7 +140,7 @@ func TestGraphWithSomeMissing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGraphEvent(t *testing.T) {
|
func TestGraphEvent(t *testing.T) {
|
||||||
planner, err := model.NewWorkflowPlanner("testdata/basic", true)
|
planner, err := model.NewWorkflowPlanner("testdata/basic", true, false)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
plan, err := planner.PlanEvent("push")
|
plan, err := planner.PlanEvent("push")
|
||||||
@@ -198,7 +198,7 @@ func (j *TestJobFileInfo) runTest(ctx context.Context, t *testing.T, cfg *Config
|
|||||||
runner, err := New(runnerConfig)
|
runner, err := New(runnerConfig)
|
||||||
assert.Nil(t, err, j.workflowPath)
|
assert.Nil(t, err, j.workflowPath)
|
||||||
|
|
||||||
planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true)
|
planner, err := model.NewWorkflowPlanner(fullWorkflowPath, true, false)
|
||||||
if j.errorMessage != "" && err != nil {
|
if j.errorMessage != "" && err != nil {
|
||||||
assert.Error(t, err, j.errorMessage)
|
assert.Error(t, err, j.errorMessage)
|
||||||
} else if assert.Nil(t, err, fullWorkflowPath) {
|
} else if assert.Nil(t, err, fullWorkflowPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user