Merge pull request #56 from aidansteele/graph-render
Render correct graph for non-default events
This commit is contained in:
commit
f2cb9e391e
|
@ -104,7 +104,7 @@ func (runner *runnerImpl) ListEvents() []string {
|
|||
// GraphEvent builds an execution path
|
||||
func (runner *runnerImpl) GraphEvent(eventName string) ([][]string, error) {
|
||||
log.Debugf("Listing actions for event '%s'", eventName)
|
||||
resolves := runner.resolveEvent(runner.config.EventName)
|
||||
resolves := runner.resolveEvent(eventName)
|
||||
return newExecutionGraph(runner.workflowConfig, resolves...), nil
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ func (runner *runnerImpl) Close() error {
|
|||
|
||||
// get list of resolves for an event
|
||||
func (runner *runnerImpl) resolveEvent(eventName string) []string {
|
||||
workflows := runner.workflowConfig.GetWorkflows(runner.config.EventName)
|
||||
workflows := runner.workflowConfig.GetWorkflows(eventName)
|
||||
resolves := make([]string, 0)
|
||||
for _, workflow := range workflows {
|
||||
for _, resolve := range workflow.Resolves {
|
||||
|
|
|
@ -8,6 +8,25 @@ import (
|
|||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
func TestGraphEvent(t *testing.T) {
|
||||
runnerConfig := &RunnerConfig{
|
||||
Ctx: context.Background(),
|
||||
WorkflowPath: "multi.workflow",
|
||||
WorkingDir: "testdata",
|
||||
EventName: "push",
|
||||
}
|
||||
runner, err := NewRunner(runnerConfig)
|
||||
assert.NilError(t, err)
|
||||
|
||||
graph, err := runner.GraphEvent("push")
|
||||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, graph, [][]string{{"build"}})
|
||||
|
||||
graph, err = runner.GraphEvent("release")
|
||||
assert.NilError(t, err)
|
||||
assert.DeepEqual(t, graph, [][]string{{"deploy"}})
|
||||
}
|
||||
|
||||
func TestRunEvent(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
workflow "buildwf" {
|
||||
on = "push"
|
||||
resolves = ["build"]
|
||||
}
|
||||
|
||||
action "build" {
|
||||
uses = "./action1"
|
||||
args = "echo 'build'"
|
||||
}
|
||||
|
||||
workflow "deploywf" {
|
||||
on = "release"
|
||||
resolves = ["deploy"]
|
||||
}
|
||||
|
||||
action "deploy" {
|
||||
uses = "./action2"
|
||||
runs = ["/bin/sh", "-c", "cat $GITHUB_EVENT_PATH"]
|
||||
}
|
Loading…
Reference in New Issue