Skip to content

Commit

Permalink
Add passthrough env vars to run summary.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhammond committed Apr 11, 2023
1 parent 2d46c2a commit 6e1f7ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/vercel/turbo/cli/internal/core"
"github.com/vercel/turbo/cli/internal/daemon"
"github.com/vercel/turbo/cli/internal/daemonclient"
"github.com/vercel/turbo/cli/internal/env"
"github.com/vercel/turbo/cli/internal/fs"
"github.com/vercel/turbo/cli/internal/graph"
"github.com/vercel/turbo/cli/internal/process"
Expand Down Expand Up @@ -340,6 +341,11 @@ func (r *run) run(ctx gocontext.Context, targets []string) error {
}
}

var envVarPassthroughMap env.EnvironmentVariableMap
if envVarPassthroughDetailedMap, err := env.GetHashableEnvVars(globalHashable.envVarPassthroughs, nil, ""); err != nil {
envVarPassthroughMap = envVarPassthroughDetailedMap.All
}

// RunSummary contains information that is statically analyzable about
// the tasks that we expect to run based on the user command.
summary := runsummary.NewRunSummary(
Expand All @@ -354,6 +360,7 @@ func (r *run) run(ctx gocontext.Context, targets []string) error {
globalHashable.globalFileHashMap,
globalHashable.rootExternalDepsHash,
globalHashable.envVars,
envVarPassthroughMap,
globalHashable.globalCacheKey,
globalHashable.pipeline,
),
Expand Down
1 change: 1 addition & 0 deletions cli/internal/runsummary/format_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (rsm *Meta) FormatJSON() ([]byte, error) {
func (rsm *Meta) normalize() {
for _, t := range rsm.RunSummary.Tasks {
t.EnvVars.Global = rsm.RunSummary.GlobalHashSummary.envVars
t.EnvVars.GlobalPassthrough = rsm.RunSummary.GlobalHashSummary.passthroughEnvVars
}

// Remove execution summary for dry runs
Expand Down
5 changes: 4 additions & 1 deletion cli/internal/runsummary/globalhash_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ type GlobalHashSummary struct {
Pipeline fs.PristinePipeline `json:"rootPipeline"`

// This is a private field because and not in JSON, because we'll add it to each task
envVars env.EnvironmentVariablePairs
envVars env.EnvironmentVariablePairs
passthroughEnvVars env.EnvironmentVariablePairs
}

// NewGlobalHashSummary creates a GlobalHashSummary struct from a set of fields.
func NewGlobalHashSummary(
fileHashMap map[turbopath.AnchoredUnixPath]string,
rootExternalDepsHash string,
envVars env.DetailedMap,
passthroughEnvVars env.EnvironmentVariableMap,
globalCacheKey string,
pipeline fs.PristinePipeline,
) *GlobalHashSummary {
return &GlobalHashSummary{
envVars: envVars.All.ToSecretHashable(),
passthroughEnvVars: passthroughEnvVars.ToSecretHashable(),
GlobalFileHashMap: fileHashMap,
RootExternalDepsHash: rootExternalDepsHash,
GlobalCacheKey: globalCacheKey,
Expand Down
8 changes: 5 additions & 3 deletions cli/internal/runsummary/task_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ type TaskSummary struct {

// TaskEnvVarSummary contains the environment variables that impacted a task's hash
type TaskEnvVarSummary struct {
Configured []string `json:"configured"`
Inferred []string `json:"inferred"`
Global []string `json:"global"`
Configured []string `json:"configured"`
Inferred []string `json:"inferred"`
Global []string `json:"global"`
GlobalPassthrough []string `json:"globalPassthrough"`
Passthrough []string `json:"passthrough"`
}

// cleanForSinglePackage converts a TaskSummary to remove references to workspaces
Expand Down

0 comments on commit 6e1f7ec

Please sign in to comment.