question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Caching & dependencies between targets

See original GitHub issue

Description

Adding the ability to specify dependencies between targets (and optionally, configurations) and ensuring these targets / configurations have been run before executing the current target.

Motivation

I’ve got a workspace with a lot of projects. Each of those projects have “build” and “deploy” targets. When running “deploy”, I first have to make sure I’ve already run “build”, otherwise (obviously) I’ll deploy the wrong version.

This is on top of dependencies between projects, which I also have.

The ideal is that when I run nx run my-project:deploy --withDeps it should first execute my-project:build.

An additional wrinkle is that, regardless of the configuration I’m using to deploy, I always want to run the production build configuration.

Suggested Implementation

Ideally in angular.json, add a field to each target: dependsOnTargets. This is an array of strings formatted {target}[:{configuration}].

Before running any target, nx should first run each target in dependsOnTargets. Just as if a target is run directly, the cached result should be used if available.

Alternate Implementations

Essentially the same as above, but in nx.json instead.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

4reactions
rgoomarcommented, Jan 6, 2021

Just adding on that this type of feature would be great to have. I’m running into a similar issue and using the run-commands with chained commands feels like a hack and does not work in the desired way I want.

For example, if I have Project X which has a target called serve that depends on Project Y and Project Z to be served as well prior to it being run, if I chain them, since it starts a server for each, it doesn’t have a graceful “end” to the task since it will end with like Served on localhost:3000. The problem here is that since it runs the first Project X serve, it ends up not continuing since the command hasn’t technically “finished”.

It would be nice to just have something like Gradle’s dependsOn or Bazel’s :deps to explicitly define target dependencies. It also makes it more clear so you don’t have to have separate targets and create a “wrapper” target that encompasses those.

0reactions
sweepy84commented, Jul 5, 2022

Really need this feature too. Can be easily done with Turborepo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caching Dependencies - CircleCI
This document is a guide to caching dependencies in CircleCI pipelines.
Read more >
Caching in GitLab CI/CD
Use cache for dependencies, like packages you download from the internet. Cache is stored where GitLab Runner is installed and uploaded to S3...
Read more >
Caching dependencies in GitHub Actions | Lorenzo Bettini
I recently started to port all my Java projects from Travis CI to GitHub Actions, since Travis CI changed its pricing model.
Read more >
Caching Dependencies and Directories - Travis CI Docs
On Ruby and Objective-C projects, installing dependencies via Bundler can make up a large portion of the build duration. Caching the bundle between...
Read more >
Advanced local caching - Earthly
One option is to use layer-based caching to first download all dependencies and only afterwards to copy the code and build it. Thus,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found