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 for Executing Multiple Tasks Sequentially or in Parallel #21020

Open
x80486 opened this issue Oct 31, 2023 · 7 comments
Open

Support for Executing Multiple Tasks Sequentially or in Parallel #21020

x80486 opened this issue Oct 31, 2023 · 7 comments
Labels
suggestion suggestions for new features (yet to be agreed) task runner related to deno task

Comments

@x80486
Copy link

x80486 commented Oct 31, 2023

Running multiple tasks in Deno using the built-in task command is not quite flexible.

Would you consider the addition of a feature that allows users to execute multiple tasks sequentially or in parallel? I'm thinking about something like npm-run-all, so it's easier to define things like the following tasks without &&:

"tasks": {
  "format:check": "deno fmt --check",
  // lint
  // sync
  "test": "deno test",
  "verify": "deno --sequential format:check lint sync test"
}
@dsherret dsherret added the suggestion suggestions for new features (yet to be agreed) label Oct 31, 2023
@dsherret
Copy link
Member

The current way to do this is:

"verify": "deno task format:check && deno task lint && deno task sync && deno task test"

Alternatively, in parallel, it's:

"verify": "deno task format:check & deno task lint & deno task sync & deno task test"

I'm not sure it's worth it to introduce another way of doing this.

@dsherret dsherret added the task runner related to deno task label Oct 31, 2023
@x80486
Copy link
Author

x80486 commented Nov 5, 2023

I understand that you may not see immediate improvements. I created this issue to suggest a potentially more intuitive approach. My idea was to introduce options like --sequential and --parallel (from npm-run-all 😏) because I believe they convey the intended behavior more clearly while also reducing redundancy — we wouldn't have to write deno task for each.

This would offer a more user-friendly and straightforward way to achieve the desired task execution method.

@dsherret
Copy link
Member

dsherret commented Nov 5, 2023

Tasks can accept CLI arguments (ex. deno task my_task arg1 arg2). I guess it would not be possible to provide arguments to an individual task with this approach?

@x80486
Copy link
Author

x80486 commented Dec 23, 2023

Well, there are a few other platforms/tools that circumvent this by using --.

In this case, you could write something like: deno task --built-in-option-name -- taskName --task-option-name — where --built-in-option-name could be --run-parallel or --run-sequential, etc.

@johndeighan
Copy link

Regarding running tasks in parallel. My use case is to have 2 tasks, each of which watch for certain file changes. So, these 2 tasks each run forever, i.e. until you use Ctrl-C to kill them. But, if I understand the suggestion of using a task consisting of multiple tasks separated by &, the Ctrl-C would only kill one of the tasks. Is that correct?

@NfNitLoop
Copy link

As of Deno 2.1 (Nov. 21) we now have task dependencies! 🎉 And dependencies of a task get run in parallel automatically. ❤️

… unfortunately, this makes debugging things a bit more difficult.

  • If I have a race condition with two of my task dependencies, it's difficult to test that out. (Would be nice if there were a --serial or -J1 option to limit task execution to a single task at a time!)

  • If I have a task failure, it sometimes difficult to find which task failed. A --serial option would make sure that the Task [name] [command] header is properly interleaved between outputs. But it might also be nice just to have a failure footer like Task [name] failed when a task fails, so we know which one(s) to check.

@dsherret
Copy link
Member

dsherret commented Jan 12, 2025

@NfNitLoop set DENO_JOBS=1 (https://docs.deno.com/runtime/reference/cli/task/#task-dependencies)

Also, opened #27647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed) task runner related to deno task
Projects
None yet
Development

No branches or pull requests

4 participants