Skip to content

Commit

Permalink
Actually pass env vars between steps
Browse files Browse the repository at this point in the history
Also some refactoring and testing.
  • Loading branch information
lkysow committed Aug 21, 2019
1 parent 33c0a72 commit 6edfb2f
Show file tree
Hide file tree
Showing 10 changed files with 321 additions and 120 deletions.
36 changes: 14 additions & 22 deletions server/events/mocks/mock_env_step_runner.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions server/events/project_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type CustomStepRunner interface {

// EnvStepRunner runs env steps.
type EnvStepRunner interface {
Run(ctx models.ProjectCommandContext, name string, cmd string, value string, path string, envs map[string]string) (string, string, error)
Run(ctx models.ProjectCommandContext, cmd string, value string, path string, envs map[string]string) (string, error)
}

//go:generate pegomock generate -m --use-experimental-model-gen --package mocks -o mocks/mock_webhooks_sender.go WebhooksSender
Expand Down Expand Up @@ -181,11 +181,10 @@ func (p *DefaultProjectCommandRunner) doPlan(ctx models.ProjectCommandContext) (

func (p *DefaultProjectCommandRunner) runSteps(steps []valid.Step, ctx models.ProjectCommandContext, absPath string) ([]string, error) {
var outputs []string
envs := make(map[string]string)
for _, step := range steps {
var envs = make(map[string]string)
var out string
var err error
var name string
switch step.StepName {
case "init":
out, err = p.InitStepRunner.Run(ctx, step.ExtraArgs, absPath, envs)
Expand All @@ -196,8 +195,10 @@ func (p *DefaultProjectCommandRunner) runSteps(steps []valid.Step, ctx models.Pr
case "run":
out, err = p.RunStepRunner.Run(ctx, step.RunCommand, absPath, envs)
case "env":
name, out, err = p.EnvStepRunner.Run(ctx, step.EnvVarName, step.RunCommand, step.EnvVarValue, absPath, envs)
envs[name] = out
out, err = p.EnvStepRunner.Run(ctx, step.RunCommand, step.EnvVarValue, absPath, envs)
envs[step.EnvVarName] = out
// We reset out to the empty string because we don't want it to
// be printed to the PR, it's solely to set the environment variable.
out = ""
}

Expand Down
Loading

0 comments on commit 6edfb2f

Please sign in to comment.