New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional framework inference #4788
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,11 @@ func DryRun( | |
} | ||
|
||
if taskSummary.Framework == "" { | ||
taskSummary.Framework = runsummary.MissingFrameworkLabel | ||
if rs.Opts.runOpts.FrameworkInference { | ||
taskSummary.Framework = runsummary.NoFrameworkDetected | ||
} else { | ||
taskSummary.Framework = runsummary.FrameworkDetectionSkipped | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only reason For skipped inference, maybe we do want it to say "skipped" even in real run summaries, to differentiate from Or you could make the case that since we have the I guess I don't have a strong enough opinion, because while leaving this comment, I'm leaning towards adding the Missing and skipped labels into real run summaries, whereas I explicitly decided not to add it before. What are your thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two ways to derive this information:
And the consequences of the configuration show up in run summary as:
We don't need it; it's derivable, and having an arbitrary string slug as part of an API feels bad. I added this to the PR primarily because I didn't want people getting The other legit option is to remove it from dry run, but that's an API change and should be held to at least 1.10. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (In other words: rather than adding it to run summary, I'd pitch removing it from dry run.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a post-Go world we could do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can I'm ok with the direction of removing from dry run, and in that case it's fine to only add this differentiation there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want the field to always be present though! lots of things blow up on missing keys. |
||
} | ||
Comment on lines
+47
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This clarifies the output in the |
||
} | ||
|
||
// This mutex is not _really_ required, since we are using Concurrency: 1 as an execution | ||
|
@@ -63,7 +67,7 @@ func DryRun( | |
return rs.ArgsForTask(taskID) | ||
} | ||
|
||
visitorFn := g.GetPackageTaskVisitor(ctx, engine.TaskGraph, globalEnvMode, getArgs, base.Logger, execFunc) | ||
visitorFn := g.GetPackageTaskVisitor(ctx, engine.TaskGraph, rs.Opts.runOpts.FrameworkInference, globalEnvMode, getArgs, base.Logger, execFunc) | ||
execOpts := core.EngineExecutionOptions{ | ||
Concurrency: 1, | ||
Parallel: false, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ type GlobalHashableInputs struct { | |
pipeline fs.PristinePipeline | ||
envVarPassthroughs []string | ||
envMode util.EnvMode | ||
frameworkInference bool | ||
} | ||
|
||
type newGlobalHashable struct { | ||
|
@@ -43,6 +44,7 @@ type newGlobalHashable struct { | |
pipeline fs.PristinePipeline | ||
envVarPassthroughs []string | ||
envMode util.EnvMode | ||
frameworkInference bool | ||
} | ||
|
||
// newGlobalHash is a transformation of GlobalHashableInputs. | ||
|
@@ -57,6 +59,7 @@ func newGlobalHash(full GlobalHashableInputs) (string, error) { | |
pipeline: full.pipeline, | ||
envVarPassthroughs: full.envVarPassthroughs, | ||
envMode: full.envMode, | ||
frameworkInference: full.frameworkInference, | ||
}) | ||
} | ||
|
||
|
@@ -94,6 +97,11 @@ func calculateGlobalHashFromHashableInputs(full GlobalHashableInputs) (string, e | |
return newGlobalHash(full) | ||
} | ||
|
||
// If you tell us not to infer framework you get the new hash. | ||
if !full.frameworkInference { | ||
return newGlobalHash(full) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an early opt-in to the " |
||
} | ||
|
||
// If we're in infer mode, and there is no global pass through config, | ||
// we use the old struct layout. this will be true for everyone not using the strict env | ||
// feature, and we don't want to break their cache. | ||
|
@@ -123,6 +131,7 @@ func getGlobalHashInputs( | |
lockFile lockfile.Lockfile, | ||
envVarPassthroughs []string, | ||
envMode util.EnvMode, | ||
frameworkInference bool, | ||
logger hclog.Logger, | ||
ui cli.Ui, | ||
isStructuredOutput bool, | ||
|
@@ -196,5 +205,6 @@ func getGlobalHashInputs( | |
pipeline: pipeline.Pristine(), | ||
envVarPassthroughs: envVarPassthroughs, | ||
envMode: envMode, | ||
frameworkInference: frameworkInference, | ||
}, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,13 +55,14 @@ func (rsm *Meta) normalize() { | |
// This struct exists solely for the purpose of serializing to JSON and should not be | ||
// used anywhere else. | ||
type nonMonorepoRunSummary struct { | ||
ID ksuid.KSUID `json:"id"` | ||
Version string `json:"version"` | ||
TurboVersion string `json:"turboVersion"` | ||
GlobalHashSummary *GlobalHashSummary `json:"globalCacheInputs"` | ||
Packages []string `json:"-"` | ||
EnvMode util.EnvMode `json:"envMode"` | ||
ExecutionSummary *executionSummary `json:"execution,omitempty"` | ||
Tasks []*TaskSummary `json:"tasks"` | ||
SCM *scmState `json:"scm"` | ||
ID ksuid.KSUID `json:"id"` | ||
Version string `json:"version"` | ||
TurboVersion string `json:"turboVersion"` | ||
GlobalHashSummary *GlobalHashSummary `json:"globalCacheInputs"` | ||
Packages []string `json:"-"` | ||
EnvMode util.EnvMode `json:"envMode"` | ||
FrameworkInference bool `json:"frameworkInference"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Starting to think we're eventually just going to want something like: Config runOpts `json:"config"` There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, and I've got another one coming in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be backwards compatible by duplicating whatever else you're thinking of in two places. There are other things that fall into that boat. That said, I'm not even sure we want all of runOpts, or in the form they exist today. So this is not a change we need in this PR right now |
||
ExecutionSummary *executionSummary `json:"execution,omitempty"` | ||
Tasks []*TaskSummary `json:"tasks"` | ||
SCM *scmState `json:"scm"` | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,11 @@ import ( | |
// the RunSummary will print this, instead of the script (e.g. `next build`). | ||
const MissingTaskLabel = "<NONEXISTENT>" | ||
|
||
// MissingFrameworkLabel is a string to identify when a workspace doesn't detect a framework | ||
const MissingFrameworkLabel = "<NO FRAMEWORK DETECTED>" | ||
// NoFrameworkDetected is a string to identify when a workspace doesn't detect a framework | ||
const NoFrameworkDetected = "<NO FRAMEWORK DETECTED>" | ||
|
||
// FrameworkDetectionSkipped is a string to identify when framework detection was skipped | ||
const FrameworkDetectionSkipped = "<FRAMEWORK DETECTION SKIPPED>" | ||
|
||
const runSummarySchemaVersion = "0" | ||
const runsEndpoint = "/v0/spaces/%s/runs" | ||
|
@@ -56,15 +59,16 @@ type Meta struct { | |
|
||
// RunSummary contains a summary of what happens in the `turbo run` command and why. | ||
type RunSummary struct { | ||
ID ksuid.KSUID `json:"id"` | ||
Version string `json:"version"` | ||
TurboVersion string `json:"turboVersion"` | ||
GlobalHashSummary *GlobalHashSummary `json:"globalCacheInputs"` | ||
Packages []string `json:"packages"` | ||
EnvMode util.EnvMode `json:"envMode"` | ||
ExecutionSummary *executionSummary `json:"execution,omitempty"` | ||
Tasks []*TaskSummary `json:"tasks"` | ||
SCM *scmState `json:"scm"` | ||
ID ksuid.KSUID `json:"id"` | ||
Version string `json:"version"` | ||
TurboVersion string `json:"turboVersion"` | ||
GlobalHashSummary *GlobalHashSummary `json:"globalCacheInputs"` | ||
Packages []string `json:"packages"` | ||
EnvMode util.EnvMode `json:"envMode"` | ||
FrameworkInference bool `json:"frameworkInference"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any chance we'll add more inference? If so, might makes sense to nest this as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After how this went I'm expecting it to be extremely limited, and likely opted-into using improved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (We're already discussing switching the default on this flag in the next major, and then I'm going to propose removing the flag + feature in the major after that. But better |
||
ExecutionSummary *executionSummary `json:"execution,omitempty"` | ||
Tasks []*TaskSummary `json:"tasks"` | ||
SCM *scmState `json:"scm"` | ||
} | ||
|
||
// NewRunSummary returns a RunSummary instance | ||
|
@@ -98,15 +102,16 @@ func NewRunSummary( | |
|
||
return Meta{ | ||
RunSummary: &RunSummary{ | ||
ID: ksuid.New(), | ||
Version: runSummarySchemaVersion, | ||
ExecutionSummary: executionSummary, | ||
TurboVersion: turboVersion, | ||
Packages: packages, | ||
EnvMode: globalEnvMode, | ||
Tasks: []*TaskSummary{}, | ||
GlobalHashSummary: globalHashSummary, | ||
SCM: getSCMState(repoRoot), | ||
ID: ksuid.New(), | ||
Version: runSummarySchemaVersion, | ||
ExecutionSummary: executionSummary, | ||
TurboVersion: turboVersion, | ||
Packages: packages, | ||
EnvMode: globalEnvMode, | ||
FrameworkInference: runOpts.FrameworkInference, | ||
Tasks: []*TaskSummary{}, | ||
GlobalHashSummary: globalHashSummary, | ||
SCM: getSCMState(repoRoot), | ||
}, | ||
ui: ui, | ||
runType: runType, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.turbo/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "docs", | ||
"scripts": { | ||
"build": "next build" | ||
}, | ||
"dependencies": { | ||
"next": "latest" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a global toggle; the only way to make it not a global toggle is to put it into
turbo.json
and that's really a "workspace config" issue for whenever we circle back to improvements in that space.This is explicitly intended to enable the advanced use case of:
turbo run build --env-mode=strict --framework-inference=false