refactor actions to improve testability

This commit is contained in:
Casey Lee
2019-01-17 00:15:35 -08:00
parent 19d1d0cfda
commit 317a305f51
10 changed files with 608 additions and 870 deletions

49
actions/api.go Normal file
View File

@@ -0,0 +1,49 @@
package actions
import (
"context"
"io"
)
// Runner provides capabilities to run GitHub actions
type Runner interface {
EventGrapher
EventLister
EventRunner
ActionRunner
io.Closer
}
// EventGrapher to list the actions
type EventGrapher interface {
GraphEvent(eventName string) ([][]string, error)
}
// EventLister to list the events
type EventLister interface {
ListEvents() []string
}
// EventRunner to run the actions for a given event
type EventRunner interface {
RunEvent() error
}
// ActionRunner to run a specific actions
type ActionRunner interface {
RunActions(actionNames ...string) error
}
// RunnerConfig contains the config for a new runner
type RunnerConfig struct {
Ctx context.Context // context to use for the run
Dryrun bool // don't start any of the containers
WorkingDir string // base directory to use
WorkflowPath string // path to load main.workflow file, relative to WorkingDir
EventName string // name of event to run
EventPath string // path to JSON file to use for event.json in containers, relative to WorkingDir
}
type environmentApplier interface {
applyEnvironment(map[string]string)
}