Render correct graph for non-default events
This commit is contained in:
parent
449c899973
commit
589ff16271
3 changed files with 40 additions and 2 deletions
|
@ -104,7 +104,7 @@ func (runner *runnerImpl) ListEvents() []string {
|
||||||
// GraphEvent builds an execution path
|
// GraphEvent builds an execution path
|
||||||
func (runner *runnerImpl) GraphEvent(eventName string) ([][]string, error) {
|
func (runner *runnerImpl) GraphEvent(eventName string) ([][]string, error) {
|
||||||
log.Debugf("Listing actions for event '%s'", eventName)
|
log.Debugf("Listing actions for event '%s'", eventName)
|
||||||
resolves := runner.resolveEvent(runner.config.EventName)
|
resolves := runner.resolveEvent(eventName)
|
||||||
return newExecutionGraph(runner.workflowConfig, resolves...), nil
|
return newExecutionGraph(runner.workflowConfig, resolves...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ func (runner *runnerImpl) Close() error {
|
||||||
|
|
||||||
// get list of resolves for an event
|
// get list of resolves for an event
|
||||||
func (runner *runnerImpl) resolveEvent(eventName string) []string {
|
func (runner *runnerImpl) resolveEvent(eventName string) []string {
|
||||||
workflows := runner.workflowConfig.GetWorkflows(runner.config.EventName)
|
workflows := runner.workflowConfig.GetWorkflows(eventName)
|
||||||
resolves := make([]string, 0)
|
resolves := make([]string, 0)
|
||||||
for _, workflow := range workflows {
|
for _, workflow := range workflows {
|
||||||
for _, resolve := range workflow.Resolves {
|
for _, resolve := range workflow.Resolves {
|
||||||
|
|
|
@ -8,6 +8,25 @@ import (
|
||||||
"gotest.tools/assert"
|
"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) {
|
func TestRunEvent(t *testing.T) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping integration test")
|
t.Skip("skipping integration test")
|
||||||
|
|
19
actions/testdata/multi.workflow
vendored
Normal file
19
actions/testdata/multi.workflow
vendored
Normal file
|
@ -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 a new issue