Skip to content

Commit 6eada53

Browse files
Merge pull request #28 from actionforge/feature/validation-improvement
Improve validation functionality
2 parents 7efdf7f + 0f90b9d commit 6eada53

11 files changed

Lines changed: 238 additions & 141 deletions

File tree

.github/workflows/graphs/build-test-publish.act

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,12 +2172,10 @@ nodes:
21722172
plum-kiwano-lobster: dev.actionforge.actrun
21732173
coral-dragonfruit-jackfruit: ''
21742174
persimmon-date-coral: distribution.xml
2175-
blackberry-apricot-butterfly: 'Developer ID Installer: Actionforge Inc. (D9L94G8QN4)'
21762175
grape-peach-apricot: 1.0.0
21772176
goose-goat-indigo: ''
21782177
guava-boysenberry-hippopotamus: ''
21792178
strawberry-nectarine-seahorse: actrun-cli.pkg
2180-
pomegranate-cranberry-gold: actrun-cli.pkg
21812179
graph:
21822180
entry: group-inputs-v1-kiwano-peach-horse
21832181
type: group

cmd/cmd_validate.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,14 @@ func validateGraph(filePath string) error {
116116
hasErrors = true
117117
}
118118

119-
_, errs := core.LoadGraph(graphYaml, nil, "", true, core.RunOpts{})
119+
opts := core.RunOpts{
120+
VS: &core.ValidationState{},
121+
OverrideSecrets: make(map[string]string),
122+
}
123+
if ghToken := u.GetGhTokenFromEnv(); ghToken != "" {
124+
opts.OverrideSecrets["GITHUB_TOKEN"] = ghToken
125+
}
126+
_, errs := core.LoadGraph(graphYaml, nil, "", opts)
120127

121128
if len(errs) > 0 {
122129
fmt.Printf("\n❌ Graph validation failed with %d error(s):\n", len(errs))
@@ -132,6 +139,13 @@ func validateGraph(filePath string) error {
132139
hasErrors = true
133140
}
134141

142+
if len(opts.VS.Warnings) > 0 {
143+
fmt.Printf("\n⚠️ %d warning(s):\n", len(opts.VS.Warnings))
144+
for i, w := range opts.VS.Warnings {
145+
fmt.Printf(" %d. %s\n", i+1, w)
146+
}
147+
}
148+
135149
if hasErrors {
136150
return fmt.Errorf("validation failed")
137151
}

core/base.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ type NodeBaseInterface interface {
180180
// Base component for nodes that offer values from other nodes.
181181
// The node that implements this component has outgoing connections.
182182
type NodeBaseComponent struct {
183-
Name string // Human readable name of the node
184-
Label string // Label of the node shown in the graph editor
185-
Id string // Unique identifier for the node
186-
FullPath string // Full path of the node within the graph hierarchy
187-
CacheId string // Unique identifier for the cache
188-
NodeType string // Node type of the node (e.g. core/run@v1 or github.com/actions/checkout@v3)
183+
Name string // Human readable name of the node
184+
Label string // Label of the node shown in the graph editor
185+
Id string // Unique identifier for the node
186+
FullPath string // Full path of the node within the graph hierarchy
187+
CacheId string // Unique identifier for the cache
188+
NodeType string // Node type of the node (e.g. core/run@v1 or github.com/actions/checkout@v3)
189189
Graph *ActionGraph
190190
Parent NodeBaseInterface
191191
isExecutionNode bool
@@ -605,7 +605,13 @@ func NewGhActionNode(nodeType string, parent NodeBaseInterface, parentId string,
605605

606606
node, errs := factoryEntry.FactoryFn(nodeType, parent, parentId, nil, validate, opts)
607607
if len(errs) > 0 {
608-
return nil, errs
608+
if node == nil {
609+
return nil, errs
610+
}
611+
// Factory returned a valid node with warnings/errors (e.g. validation
612+
// proxy). Initialise the node and pass the errors through.
613+
utils.InitMapAndSliceInStructRecursively(reflect.ValueOf(node))
614+
return node, errs
609615
}
610616

611617
utils.InitMapAndSliceInStructRecursively(reflect.ValueOf(node))

0 commit comments

Comments
 (0)