Skip to content

Commit

Permalink
pin to v1.0.0 of github action parser
Browse files Browse the repository at this point in the history
  • Loading branch information
cplee committed Feb 7, 2019
1 parent 3e04312 commit 4b61fb3
Show file tree
Hide file tree
Showing 119 changed files with 9,482 additions and 3,609 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ endif
git push origin $(NEW_VERSION)

vendor:
go run main.go -ra vendor
go mod vendor

.PHONY: vendor
62 changes: 44 additions & 18 deletions actions/runner_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,35 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
return common.NewErrorExecutor(fmt.Errorf("Unable to find action named '%s'", actionName))
}

env := make(map[string]string)
for _, applier := range []environmentApplier{newActionEnvironmentApplier(action), runner} {
applier.applyEnvironment(env)
executors := make([]common.Executor, 0)
image, err := runner.addImageExecutor(action, &executors)
if err != nil {
return common.NewErrorExecutor(err)
}
env["GITHUB_ACTION"] = actionName

logger := newActionLogger(actionName, runner.config.Dryrun)
log.Debugf("Using '%s' for action '%s'", action.Uses, actionName)
err = runner.addRunExecutor(action, image, &executors)
if err != nil {
return common.NewErrorExecutor(err)
}

return common.NewPipelineExecutor(executors...)
}

func (runner *runnerImpl) addImageExecutor(action *model.Action, executors *[]common.Executor) (string, error) {
var image string
logger := newActionLogger(action.Identifier, runner.config.Dryrun)
log.Debugf("Using '%s' for action '%s'", action.Uses, action.Identifier)

in := container.DockerExecutorInput{
Ctx: runner.config.Ctx,
Logger: logger,
Dryrun: runner.config.Dryrun,
}

var image string
executors := make([]common.Executor, 0)
switch uses := action.Uses.(type) {

case *model.UsesDockerImage:
image = uses.Image
executors = append(executors, container.NewDockerPullExecutor(container.NewDockerPullExecutorInput{
*executors = append(*executors, container.NewDockerPullExecutor(container.NewDockerPullExecutorInput{
DockerExecutorInput: in,
Image: image,
}))
Expand All @@ -56,7 +63,7 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
}
image = fmt.Sprintf("%s:%s", filepath.Base(contextDir), sha)

executors = append(executors, container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
*executors = append(*executors, container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
DockerExecutorInput: in,
ContextDir: contextDir,
ImageTag: image,
Expand All @@ -67,7 +74,7 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
cloneURL := fmt.Sprintf("https://github.com/%s", uses.Repository)

cloneDir := filepath.Join(os.TempDir(), "act", action.Uses.String())
executors = append(executors, common.NewGitCloneExecutor(common.NewGitCloneExecutorInput{
*executors = append(*executors, common.NewGitCloneExecutor(common.NewGitCloneExecutorInput{
URL: cloneURL,
Ref: uses.Ref,
Dir: cloneDir,
Expand All @@ -76,19 +83,38 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
}))

contextDir := filepath.Join(cloneDir, uses.Path)
executors = append(executors, container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
*executors = append(*executors, container.NewDockerBuildExecutor(container.NewDockerBuildExecutorInput{
DockerExecutorInput: in,
ContextDir: contextDir,
ImageTag: image,
}))

default:
return common.NewErrorExecutor(fmt.Errorf("unable to determine executor type for image '%s'", action.Uses))
return "", fmt.Errorf("unable to determine executor type for image '%s'", action.Uses)
}

return image, nil
}

func (runner *runnerImpl) addRunExecutor(action *model.Action, image string, executors *[]common.Executor) error {
logger := newActionLogger(action.Identifier, runner.config.Dryrun)
log.Debugf("Using '%s' for action '%s'", action.Uses, action.Identifier)

in := container.DockerExecutorInput{
Ctx: runner.config.Ctx,
Logger: logger,
Dryrun: runner.config.Dryrun,
}

env := make(map[string]string)
for _, applier := range []environmentApplier{newActionEnvironmentApplier(action), runner} {
applier.applyEnvironment(env)
}
env["GITHUB_ACTION"] = action.Identifier

ghReader, err := runner.createGithubTarball()
if err != nil {
return common.NewErrorExecutor(err)
return err
}

envList := make([]string, 0)
Expand All @@ -103,14 +129,14 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
if action.Runs != nil {
entrypoint = action.Runs.Split()
}
executors = append(executors, container.NewDockerRunExecutor(container.NewDockerRunExecutorInput{
*executors = append(*executors, container.NewDockerRunExecutor(container.NewDockerRunExecutorInput{
DockerExecutorInput: in,
Cmd: cmd,
Entrypoint: entrypoint,
Image: image,
WorkingDir: "/github/workspace",
Env: envList,
Name: runner.createContainerName(actionName),
Name: runner.createContainerName(action.Identifier),
Binds: []string{
fmt.Sprintf("%s:%s", runner.config.WorkingDir, "/github/workspace"),
fmt.Sprintf("%s:%s", runner.tempDir, "/github/home"),
Expand All @@ -120,7 +146,7 @@ func (runner *runnerImpl) newActionExecutor(actionName string) common.Executor {
ReuseContainers: runner.config.ReuseContainers,
}))

return common.NewPipelineExecutor(executors...)
return nil
}

func (runner *runnerImpl) applyEnvironment(env map[string]string) {
Expand Down
25 changes: 15 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,45 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.4.11 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/actions/workflow-parser v0.0.0-20190131180005-9cb71d183680
github.com/actions/workflow-parser v1.0.0
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.1+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.3.3 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/go-ini/ini v1.41.0
github.com/gogo/protobuf v1.2.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/mux v1.6.2 // indirect
github.com/gorilla/mux v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jtolds/gls v4.2.1+incompatible // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v0.1.1 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.3.0
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect
github.com/soniakeys/graph v0.0.0 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 // indirect
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
golang.org/x/sys v0.0.0-20190102155601-82a175fd1598 // indirect
golang.org/x/sys v0.0.0-20190201152629-afcc84fd7533 // indirect
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect
google.golang.org/grpc v1.17.0 // indirect
google.golang.org/genproto v0.0.0-20190128161407-8ac453e89fca // indirect
google.golang.org/grpc v1.18.0 // indirect
gopkg.in/ini.v1 v1.41.0 // indirect
gopkg.in/src-d/go-git.v4 v4.8.1
gopkg.in/src-d/go-billy.v4 v4.3.0 // indirect
gopkg.in/src-d/go-git-fixtures.v3 v3.3.0 // indirect
gopkg.in/src-d/go-git.v4 v4.9.1
gopkg.in/yaml.v2 v2.2.2
gotest.tools v2.2.0+incompatible
)
Expand Down
Loading

0 comments on commit 4b61fb3

Please sign in to comment.