Skip to content

Conversation

@Philip-Scott
Copy link
Member

Avoid adding packages to build graph when not specified. This will be highly impactful for our build times of our PR Deployment environment as we'd be able to just bundle packages, we deploy to this environment instead of the full repo. In our build pipelines where we need to build everything, we can add build to the Lage tasks.

Manual Validation

Within our team's repo, I was able to confirm that running lage test ran all test tasks our team has, and avoided building packages without tests and that were not in any dependency path. We went from having to build 117 packages to 108.

I can share the results with you privately to avoid sharing any private package names here :)

Fixes #592

@Philip-Scott Philip-Scott requested a review from kenotron as a code owner March 1, 2023 19:43
@netlify
Copy link

netlify bot commented Mar 1, 2023

Deploy Preview for peppy-praline-1c3272 canceled.

Name Link
🔨 Latest commit e476a8d
🔍 Latest deploy log https://app.netlify.com/sites/peppy-praline-1c3272/deploys/63ffaae486bc870007266f2b

@kenotron
Copy link
Contributor

kenotron commented Mar 7, 2023

So, we really can't assume knowledge of whether to add something to the graph or not here in this package. We may need to factor the workspace target graph builder OUT of this package so it can know about "runners". The runners themselves tell you whether the target "shouldRun()" something. Based on that flag, then we can determine if the graph should be trimmed or not.

Copy link
Contributor

@kenotron kenotron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check my message. If you're up for it, we can chat more offline about the approach.

@kenotron
Copy link
Contributor

kenotron commented Mar 10, 2023

Here's what to do next:

  1. move WorkspaceTargetGraphBuilder to cli package
  2. pull in TargetRunnerPicker as a constructor dependency to the WorkspaceTargetGraphBuilder
  3. replace the conditional to use the shouldRun() function of the picked runner to skip "entries" target in WTGBuilder
  4. please add WTGBuilder test to cover the cases as we drew here:

image

@Philip-Scott
Copy link
Member Author

pipeline: {
  transpile: [],
  types: ['^types']
  copy: ['transpile']
  bundle: ['copy', '^transpile'],
  
}

root package.json {
  build: lage transpile types
}

@dobesv
Copy link
Contributor

dobesv commented Mar 15, 2025

One thing to consider here is that sometimes phantom/virtual tasks are desirable to use as a sort of generic node in a dependency graph. For example, I have a pipeline _build:js-recursive that depends on the js build in the same package and all the dependencies of it. I use this when I need some tool to be build before a pipeline runs, including everything that tool depends on. I don't need build:js to depend on ^build:js because babel doesn't actually read the dependent packages' files.

Also, it would be nice to be able to have a script that does exist in package.json but you don't want to run it - for example I have a script in package.json I can run manally that runs build:types build:node build:browser but when running lage I would ideally be able to tell it not to run that script and just process it as a dependency. The workaround here is to create a phantom _build pipeline instead.

@dobesv
Copy link
Contributor

dobesv commented Mar 15, 2025

Which is to say I'd rather this not be merged unless there's some option to control whether a given task gets handled this way or the old way - otherwise I'll have to add dummy no-op scripts for all the places I'm making use of the current behavior.

@dobesv
Copy link
Contributor

dobesv commented Mar 16, 2025

One way to support different logic for pipelines would be to add more options for the type field - for example"

  • type: 'script' would only add to the dep graph if there's a script defined
  • type: 'virtual' would always add to the dep graph; additionally it would never run a script even if one is defined

@dobesv
Copy link
Contributor

dobesv commented Mar 17, 2025

Hmm actually looking at the code I see you can set a pipeline item to type: 'noop' which always returns shouldRun: true and does nothing when you run the task. So this can be used for virtual targets. Then the shouldRun logic could be used to decide whether a task propagates dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lage scheduler adding "phantom" tasks to the graph.

3 participants