Hi All!
In the docs (https://docs.dagger.io/sdk/nodejs) it is written: "When the engine receives an API request, it computes a Directed Acyclic Graph (DAG) of low-level operations required to compute the result, and starts processing operations concurrently."
My question is, how are these single "graph elements" defined? I mean, I when I define my build-and-test.mjs file, I would define it like this:
import Client, { connect } from "@dagger.io/dagger"
connect(async (client: Client) => {
const source = client.host().directory(".", { exclude: ["node_modules/"] })
const node = client.container().from("node:16")
const runner = client
.container({ id: node })
.withMountedDirectory("/src", source)
.withWorkdir("/src")
.withExec(["npm", "install"])
await runner.withExec(["npm", "test", "--", "--watchAll=false"]).exitCode()
await runner
.withExec(["npm", "run", "build"])
.directory("build/")
.export("./build")
})```
However here I'm defining the dependency installation, testing and building *all-in-one*. Hence if I had "code-analysis" task, then I'd have to redefine "dependency installation" again, right?
What I'm looking for instead is that for a given "task" I define how that task is performed and what other tasks it depends on. For example, I would like to **only** define how dependencies are installed (npm install), or how each of my other tasks (test and build) are executed. When I define test/build, I don't want to redefine how dependency installation is to be done, but just refer to my old definition (say it's okay to build even if test fail).
And later on, of I append my system with a new "task", say "deploy", I just want to define how deployment should happen but I don't want to redefine how dependency installation or building happens. So, I want define "deploy" and say that it depends on "build" and the rest is calculated. I want each of my graph elements to be defined once only to avoid code repetition.