update to latest version of action parser
This commit is contained in:
parent
bc5c23e8e4
commit
3e04312912
10 changed files with 89 additions and 46 deletions
|
@ -1,7 +1,6 @@
|
||||||
package actions
|
package actions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -60,12 +59,14 @@ func (runner *runnerImpl) setupWorkflows() error {
|
||||||
defer workflowReader.Close()
|
defer workflowReader.Close()
|
||||||
|
|
||||||
runner.workflowConfig, err = parser.Parse(workflowReader)
|
runner.workflowConfig, err = parser.Parse(workflowReader)
|
||||||
if err != nil {
|
/*
|
||||||
parserError := err.(*parser.ParserError)
|
if err != nil {
|
||||||
for _, e := range parserError.Errors {
|
parserError := err.(*parser.ParserError)
|
||||||
fmt.Fprintln(os.Stderr, e)
|
for _, e := range parserError.Errors {
|
||||||
|
fmt.Fprintln(os.Stderr, e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,10 +95,18 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
|
||||||
for k, v := range env {
|
for k, v := range env {
|
||||||
envList = append(envList, fmt.Sprintf("%s=%s", k, v))
|
envList = append(envList, fmt.Sprintf("%s=%s", k, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cmd, entrypoint []string
|
||||||
|
if action.Args != nil {
|
||||||
|
cmd = action.Args.Split()
|
||||||
|
}
|
||||||
|
if action.Runs != nil {
|
||||||
|
entrypoint = action.Runs.Split()
|
||||||
|
}
|
||||||
executors = append(executors, container.NewDockerRunExecutor(container.NewDockerRunExecutorInput{
|
executors = append(executors, container.NewDockerRunExecutor(container.NewDockerRunExecutorInput{
|
||||||
DockerExecutorInput: in,
|
DockerExecutorInput: in,
|
||||||
Cmd: action.Args.Parsed,
|
Cmd: cmd,
|
||||||
Entrypoint: action.Runs.Parsed,
|
Entrypoint: entrypoint,
|
||||||
Image: image,
|
Image: image,
|
||||||
WorkingDir: "/github/workspace",
|
WorkingDir: "/github/workspace",
|
||||||
Env: envList,
|
Env: envList,
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ require (
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
||||||
github.com/Microsoft/go-winio v0.4.11 // indirect
|
github.com/Microsoft/go-winio v0.4.11 // indirect
|
||||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
|
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
|
||||||
github.com/actions/workflow-parser v0.0.0-20190130154146-aac54e2ba131
|
github.com/actions/workflow-parser v0.0.0-20190131180005-9cb71d183680
|
||||||
github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 // indirect
|
github.com/containerd/continuity v0.0.0-20181203112020-004b46473808 // indirect
|
||||||
github.com/docker/distribution v2.7.0+incompatible // indirect
|
github.com/docker/distribution v2.7.0+incompatible // indirect
|
||||||
github.com/docker/docker v1.13.1
|
github.com/docker/docker v1.13.1
|
||||||
|
|
6
go.sum
6
go.sum
|
@ -5,8 +5,10 @@ github.com/Microsoft/go-winio v0.4.11 h1:zoIOcVf0xPN1tnMVbTtEdI+P8OofVk3NObnwOQ6
|
||||||
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
|
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
|
||||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
|
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
|
||||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
|
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
|
||||||
github.com/actions/workflow-parser v0.0.0-20190130154146-aac54e2ba131 h1:f81A6l1wPc9LdSZ85yJb+YuZxHiweb6D3p1l/bKDbJg=
|
github.com/actions/workflow-parser v0.0.0-20190131170132-f9c507444936 h1:n7QhjGKV6TSvqiSJdRx2yZ7go8FihDG7ksqi/M1RUF8=
|
||||||
github.com/actions/workflow-parser v0.0.0-20190130154146-aac54e2ba131/go.mod h1:jz9ZVl8zUIcjMfDQearQjvUHIBhx9l1ys4keDd6be34=
|
github.com/actions/workflow-parser v0.0.0-20190131170132-f9c507444936/go.mod h1:jz9ZVl8zUIcjMfDQearQjvUHIBhx9l1ys4keDd6be34=
|
||||||
|
github.com/actions/workflow-parser v0.0.0-20190131180005-9cb71d183680 h1:MIHTh+XAfOwshi2enD7FwYkGgFpNWYx2mSzYG9LJQeg=
|
||||||
|
github.com/actions/workflow-parser v0.0.0-20190131180005-9cb71d183680/go.mod h1:jz9ZVl8zUIcjMfDQearQjvUHIBhx9l1ys4keDd6be34=
|
||||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
|
||||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
|
||||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
|
||||||
|
|
38
vendor/github.com/actions/workflow-parser/model/command.go
generated
vendored
Normal file
38
vendor/github.com/actions/workflow-parser/model/command.go
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Command represents the optional "runs" and "args" attributes.
|
||||||
|
// Each one takes one of two forms:
|
||||||
|
// - runs="entrypoint arg1 arg2 ..."
|
||||||
|
// - runs=[ "entrypoint", "arg1", "arg2", ... ]
|
||||||
|
type Command interface {
|
||||||
|
isCommand()
|
||||||
|
Split() []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringCommand represents the string based form of the "runs" or "args"
|
||||||
|
// attribute.
|
||||||
|
// - runs="entrypoint arg1 arg2 ..."
|
||||||
|
type StringCommand struct {
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListCommand represents the list based form of the "runs" or "args" attribute.
|
||||||
|
// - runs=[ "entrypoint", "arg1", "arg2", ... ]
|
||||||
|
type ListCommand struct {
|
||||||
|
Values []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *StringCommand) isCommand() {}
|
||||||
|
func (l *ListCommand) isCommand() {}
|
||||||
|
|
||||||
|
func (s *StringCommand) Split() []string {
|
||||||
|
return strings.Fields(s.Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListCommand) Split() []string {
|
||||||
|
return l.Values
|
||||||
|
}
|
15
vendor/github.com/actions/workflow-parser/model/configuration.go
generated
vendored
15
vendor/github.com/actions/workflow-parser/model/configuration.go
generated
vendored
|
@ -10,25 +10,12 @@ type Configuration struct {
|
||||||
type Action struct {
|
type Action struct {
|
||||||
Identifier string
|
Identifier string
|
||||||
Uses Uses
|
Uses Uses
|
||||||
Runs, Args ActionCommand
|
Runs, Args Command
|
||||||
Needs []string
|
Needs []string
|
||||||
Env map[string]string
|
Env map[string]string
|
||||||
Secrets []string
|
Secrets []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActionCommand represents the optional "runs" and "args" attributes.
|
|
||||||
// Each one takes one of two forms:
|
|
||||||
// - runs="entrypoint arg1 arg2 ..."
|
|
||||||
// - runs=[ "entrypoint", "arg1", "arg2", ... ]
|
|
||||||
// If the user uses the string form, "Raw" contains that value, and
|
|
||||||
// "Parsed" contains an array of the string value split at whitespace.
|
|
||||||
// If the user uses the array form, "Raw" is empty, and "Parsed" contains
|
|
||||||
// the array.
|
|
||||||
type ActionCommand struct {
|
|
||||||
Raw string
|
|
||||||
Parsed []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Workflow represents a single "workflow" stanza in a .workflow file.
|
// Workflow represents a single "workflow" stanza in a .workflow file.
|
||||||
type Workflow struct {
|
type Workflow struct {
|
||||||
Identifier string
|
Identifier string
|
||||||
|
|
2
vendor/github.com/actions/workflow-parser/model/eventtypes.go
generated
vendored
2
vendor/github.com/actions/workflow-parser/model/eventtypes.go
generated
vendored
|
@ -12,7 +12,7 @@ func IsAllowedEventType(eventType string) bool {
|
||||||
|
|
||||||
// IsMatchingEventType checks to see if the "flowOn" string from a flow's on attribute matches the incoming webhook of type eventType.
|
// IsMatchingEventType checks to see if the "flowOn" string from a flow's on attribute matches the incoming webhook of type eventType.
|
||||||
func IsMatchingEventType(flowOn, eventType string) bool {
|
func IsMatchingEventType(flowOn, eventType string) bool {
|
||||||
return strings.ToLower(flowOn) == strings.ToLower(eventType)
|
return strings.EqualFold(flowOn, eventType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#events-supported-in-workflow-files
|
// https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#events-supported-in-workflow-files
|
||||||
|
|
9
vendor/github.com/actions/workflow-parser/parser/errors.go
generated
vendored
9
vendor/github.com/actions/workflow-parser/parser/errors.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package parser
|
package parser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -17,7 +18,13 @@ type ParserError struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParserError) Error() string {
|
func (p *ParserError) Error() string {
|
||||||
return p.message
|
buffer := bytes.NewBuffer(nil)
|
||||||
|
buffer.WriteString(p.message)
|
||||||
|
for _, e := range p.Errors {
|
||||||
|
buffer.WriteString("\n ")
|
||||||
|
buffer.WriteString(e.Error())
|
||||||
|
}
|
||||||
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error represents an error identified by the parser, either syntactic
|
// Error represents an error identified by the parser, either syntactic
|
||||||
|
|
36
vendor/github.com/actions/workflow-parser/parser/parser.go
generated
vendored
36
vendor/github.com/actions/workflow-parser/parser/parser.go
generated
vendored
|
@ -43,7 +43,7 @@ func Parse(reader io.Reader, options ...OptionFunc) (*model.Configuration, error
|
||||||
pos := ErrorPos{File: pe.Pos.Filename, Line: pe.Pos.Line, Column: pe.Pos.Column}
|
pos := ErrorPos{File: pe.Pos.Filename, Line: pe.Pos.Line, Column: pe.Pos.Column}
|
||||||
errors := ErrorList{newFatal(pos, pe.Err.Error())}
|
errors := ErrorList{newFatal(pos, pe.Err.Error())}
|
||||||
return nil, &ParserError{
|
return nil, &ParserError{
|
||||||
message: pe.Err.Error(),
|
message: "unable to parse",
|
||||||
Errors: errors,
|
Errors: errors,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,24 +548,25 @@ func (ps *parseState) parseActionAttribute(name string, action *model.Action, va
|
||||||
case "uses":
|
case "uses":
|
||||||
ps.parseUses(action, val)
|
ps.parseUses(action, val)
|
||||||
case "needs":
|
case "needs":
|
||||||
needs, ok := ps.literalToStringArray(val, true)
|
if needs, ok := ps.literalToStringArray(val, true); ok {
|
||||||
if ok {
|
|
||||||
action.Needs = needs
|
action.Needs = needs
|
||||||
ps.posMap[&action.Needs] = val
|
ps.posMap[&action.Needs] = val
|
||||||
}
|
}
|
||||||
case "runs":
|
case "runs":
|
||||||
ps.parseCommand(action, &action.Runs, name, val, false)
|
if runs := ps.parseCommand(action, action.Runs, name, val, false); runs != nil {
|
||||||
|
action.Runs = runs
|
||||||
|
}
|
||||||
case "args":
|
case "args":
|
||||||
ps.parseCommand(action, &action.Args, name, val, true)
|
if args := ps.parseCommand(action, action.Args, name, val, true); args != nil {
|
||||||
|
action.Args = args
|
||||||
|
}
|
||||||
case "env":
|
case "env":
|
||||||
env := ps.literalToStringMap(val)
|
if env := ps.literalToStringMap(val); env != nil {
|
||||||
if env != nil {
|
|
||||||
action.Env = env
|
action.Env = env
|
||||||
}
|
}
|
||||||
ps.posMap[&action.Env] = val
|
ps.posMap[&action.Env] = val
|
||||||
case "secrets":
|
case "secrets":
|
||||||
secrets, ok := ps.literalToStringArray(val, false)
|
if secrets, ok := ps.literalToStringArray(val, false); ok {
|
||||||
if ok {
|
|
||||||
action.Secrets = secrets
|
action.Secrets = secrets
|
||||||
ps.posMap[&action.Secrets] = val
|
ps.posMap[&action.Secrets] = val
|
||||||
}
|
}
|
||||||
|
@ -621,11 +622,11 @@ func (ps *parseState) parseUses(action *model.Action, node ast.Node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseUses sets the action.Runs or action.Command value based on the
|
// parseUses sets the action.Runs or action.Args value based on the
|
||||||
// contents of the AST node. This function enforces formatting
|
// contents of the AST node. This function enforces formatting
|
||||||
// requirements on the value.
|
// requirements on the value.
|
||||||
func (ps *parseState) parseCommand(action *model.Action, dest *model.ActionCommand, name string, node ast.Node, allowBlank bool) {
|
func (ps *parseState) parseCommand(action *model.Action, cmd model.Command, name string, node ast.Node, allowBlank bool) model.Command {
|
||||||
if len(dest.Parsed) > 0 {
|
if cmd != nil {
|
||||||
ps.addWarning(node, "`%s' redefined in action `%s'", name, action.Identifier)
|
ps.addWarning(node, "`%s' redefined in action `%s'", name, action.Identifier)
|
||||||
// continue, allowing the redefinition
|
// continue, allowing the redefinition
|
||||||
}
|
}
|
||||||
|
@ -633,9 +634,9 @@ func (ps *parseState) parseCommand(action *model.Action, dest *model.ActionComma
|
||||||
// Is it a list?
|
// Is it a list?
|
||||||
if _, ok := node.(*ast.ListType); ok {
|
if _, ok := node.(*ast.ListType); ok {
|
||||||
if parsed, ok := ps.literalToStringArray(node, false); ok {
|
if parsed, ok := ps.literalToStringArray(node, false); ok {
|
||||||
dest.Parsed = parsed
|
return &model.ListCommand{Values: parsed}
|
||||||
}
|
}
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not, parse a whitespace-separated string into a list.
|
// If not, parse a whitespace-separated string into a list.
|
||||||
|
@ -643,14 +644,13 @@ func (ps *parseState) parseCommand(action *model.Action, dest *model.ActionComma
|
||||||
var ok bool
|
var ok bool
|
||||||
if raw, ok = ps.literalToString(node); !ok {
|
if raw, ok = ps.literalToString(node); !ok {
|
||||||
ps.addError(node, "The `%s' attribute must be a string or a list", name)
|
ps.addError(node, "The `%s' attribute must be a string or a list", name)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
if raw == "" && !allowBlank {
|
if raw == "" && !allowBlank {
|
||||||
ps.addError(node, "`%s' value in action `%s' cannot be blank", name, action.Identifier)
|
ps.addError(node, "`%s' value in action `%s' cannot be blank", name, action.Identifier)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
dest.Raw = raw
|
return &model.StringCommand{Value: raw}
|
||||||
dest.Parsed = strings.Fields(raw)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func typename(val interface{}) string {
|
func typename(val interface{}) string {
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -1,6 +1,6 @@
|
||||||
# github.com/Microsoft/go-winio v0.4.11
|
# github.com/Microsoft/go-winio v0.4.11
|
||||||
github.com/Microsoft/go-winio
|
github.com/Microsoft/go-winio
|
||||||
# github.com/actions/workflow-parser v0.0.0-20190130154146-aac54e2ba131
|
# github.com/actions/workflow-parser v0.0.0-20190131180005-9cb71d183680
|
||||||
github.com/actions/workflow-parser/model
|
github.com/actions/workflow-parser/model
|
||||||
github.com/actions/workflow-parser/parser
|
github.com/actions/workflow-parser/parser
|
||||||
# github.com/containerd/continuity v0.0.0-20181203112020-004b46473808
|
# github.com/containerd/continuity v0.0.0-20181203112020-004b46473808
|
||||||
|
|
Loading…
Reference in a new issue