Skip to content
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

Support loops in dependencies as well #1299

Closed
eliad-wiz opened this issue Aug 9, 2023 · 4 comments · Fixed by #1541
Closed

Support loops in dependencies as well #1299

eliad-wiz opened this issue Aug 9, 2023 · 4 comments · Fixed by #1541
Labels
area: loops Changes related to looping over tasks/commands. type: feature A new feature or functionality.

Comments

@eliad-wiz
Copy link

Allow specifying loops in task dependencies the same way they can be used in cmds

Taskfile:

version: '3'

tasks:
  deptask:
    desc: dependency task
    cmds:
      - echo dependency foo {{.FOO}}

  default:
    desc: some task
    deps:
      - for: ['foo', 'bar']
        task: deptask
        vars:
          FOO: "DEP-{{.ITEM}}"

    cmds:
      - for: ['foo', 'bar']
        task: deptask
        vars:
          FOO: "ROOT-{{.ITEM}}"

Expected output

task: [deptask] echo dependency foo DEP-foo
dependency foo DEP-foo
task: [deptask] echo dependency foo DEP-bar
dependency foo DEP-bar
task: [deptask] echo dependency foo ROOT-foo
dependency foo ROOT-foo
task: [deptask] echo dependency foo ROOT-bar
dependency foo ROOT-bar

Actual output

task: [deptask] echo dependency foo DEP-
dependency foo DEP-
task: [deptask] echo dependency foo ROOT-foo
dependency foo ROOT-foo
task: [deptask] echo dependency foo ROOT-bar
dependency foo ROOT-bar
  • Task version: v3.28.0 (h1:PGYGwevlGQdYrqhO6lLCYylC7YuGoQLlVwHkO42gf0I=)
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Aug 9, 2023
@andreynering andreynering added type: feature A new feature or functionality. and removed state: needs triage Waiting to be triaged by a maintainer. labels Aug 9, 2023
@q0rban
Copy link
Contributor

q0rban commented Aug 9, 2023

Perhaps this is obvious to others, but is there a reason this isn't desirable?

version: '3'

tasks:
  deptask:
    desc: dependency task
    cmds:
      - echo dependency foo {{.FOO}}

  default:
    desc: some task

    cmds:
      - for: ['foo', 'bar']
        task: deptask
        vars:
          FOO: "DEP-{{.ITEM}}"
      - for: ['foo', 'bar']
        task: deptask
        vars:
          FOO: "ROOT-{{.ITEM}}"

If it's because deptask isn't run in parallel, I wonder about your thoughts on #1300.

@eliad-wiz
Copy link
Author

eliad-wiz commented Aug 9, 2023

sorry for not mentioning it, but the reason is parallelism, as you mentioned.

i don't like the "parallel for" syntax too much, as there's no reason to specialize it.
something like this is more generic, and makes more sense to me:

version: '3'

tasks:
  deptask:
    desc: dependency task
    cmds:
      - echo dependency foo {{.FOO}}

  default:
    desc: some task

    cmds:
      - parallel:
        - echo first command
        - for: ['foo', 'bar']
          task: deptask
          vars:
            FOO: "DEP-{{.ITEM}}"
        - echo last command

i.e. specifying all the parallel commands in a separate group.
it is also nicer since it can replace the deps altogether.

i think it is a better solution, but having loops support in "deps" (similar to "cmds") is good enough for my usecase.

@postlund
Copy link

postlund commented Nov 9, 2023

Would really love to see this feature too!

@samj1912
Copy link

samj1912 commented Jan 4, 2024

+1 on the feature

@andreynering andreynering added the area: loops Changes related to looping over tasks/commands. label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: loops Changes related to looping over tasks/commands. type: feature A new feature or functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants