Skip to content

Commit

Permalink
Merge branch 'issue-18' (fix #18)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jul 31, 2021
2 parents 3194be6 + 5b9035a commit 8fcbdc3
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 180 deletions.
3 changes: 3 additions & 0 deletions action_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type ActionMetadata struct {
// SkipInputs is flag to specify behavior of inputs check. When it is true, inputs for this
// action will not be checked.
SkipInputs bool `json:"skip_inputs"`
// SkipOutputs is flag to specify a bit loose typing to outputs object. If it is set to
// true, the outputs object accepts any properties along with strictly typed props.
SkipOutputs bool `json:"skip_outputs"`
}

// LocalActionsCache is cache for local actions' metadata. It avoids repeating to find/read/parse
Expand Down
5 changes: 2 additions & 3 deletions popular_actions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions rule_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,13 @@ func (rule *RuleExpression) getActionOutputsType(spec *String) *ObjectType {
return NewObjectType()
}

ty := NewObjectType()
for n := range meta.Outputs {
ty.Props[n] = AnyType{}
}
ty.StrictProps = true
return ty
return typeOfActionOutputs(meta)
}

// When the action run at this step is a popular action, we know what outputs are set by it.
// Set the output names to `steps.{step_id}.outputs.{name}`.
if meta, ok := PopularActions[spec.Value]; ok {
ty := NewObjectType()
for n := range meta.Outputs {
ty.Props[n] = AnyType{}
}
ty.StrictProps = true
return ty
return typeOfActionOutputs(meta)
}

return NewObjectType()
Expand Down Expand Up @@ -777,3 +767,17 @@ func convertExprLineColToPos(line, col, lineBase, colBase int) *Pos {
Col: col - 1 + colBase,
}
}

func typeOfActionOutputs(meta *ActionMetadata) *ObjectType {
// Some action sets outputs dynamically. Such outputs are not defined in action.yml. actionlint
// cannot check such outputs statically so it allows any props (#18)
if meta.SkipOutputs {
return NewObjectType()
}
ty := NewObjectType()
for n := range meta.Outputs {
ty.Props[n] = AnyType{}
}
ty.StrictProps = true
return ty
}
Loading

0 comments on commit 8fcbdc3

Please sign in to comment.