How to run included dep only once #1497
-
I'm currently working in a mono repo where we have taskfiles for the various tools/services/libs we have in the repo. At the top level we have a single taskfile that includes each of the taskfiles for the tools/services/libs so that we can run the tasks from the root of the monorepo. Some of the libs have common dependencies that are defined in the other task files. For example, we build a protoc plugin that needs to exist to build the libraries. Here is an example similar to our setup ./tools/input
./tools/taskfile.yml
version: "3"
tasks:
exe:
run: once
sources:
- ./input
generates:
- ./output
cmds:
- touch output
./lib/a/taskfile.yml
version: "3"
includes:
tools:
taskfile: ../../tools
dir: ../../tools
internal: true
tasks:
lib:
deps:
- tools:exe
cmds:
- touch a
./lib/b/taskfile.yml
version: "3"
includes:
tools:
taskfile: ../../tools
dir: ../../tools
internal: true
tasks:
lib:
deps:
- tools:exe
cmds:
- touch b
./taskfile.yml
version: "3"
tasks:
all:
deps:
- a:lib
- b:lib
includes:
a:
taskfile: ./lib/a
dir: ./lib/a
b:
taskfile: ./lib/b
dir: ./lib/b When we want to build all the libraries, we run
Which we can see builds the tool multiple times. If I collapse the task files all down to a single file, I can get the single build of the tool version: "3"
tasks:
tools:exe:
run: once
sources:
- ./tools/input
generates:
- ./tools/output
cmds:
- touch ./tools/output
a:lib:
deps:
- tools:exe
cmds:
- touch lib/a
b:lib:
deps:
- tools:exe
cmds:
- touch lib/b
all:
deps:
- a:lib
- b:lib
Is there a good way for us to get the best of both worlds? (The organization of multiple files but the single run of building the tool?) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @maxmzkrcensys, Have you tried |
Beta Was this translation helpful? Give feedback.
Sorry for missing it! (Had to take another cup of coffee ☕)
This looks like a bug to me, where
run: once
is not working due to the multiple includes. Do you mind opening an issue about it?