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

feat(task): dependencies #26467

Merged
merged 39 commits into from
Nov 19, 2024
Merged

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Oct 22, 2024

This commit adds support for "dependencies" in deno task subcommand:

{
    "tasks": {
        "build": "deno run -RW build.ts",
        "generate": "deno run -RW generate.ts",
        "serve": {
            "command": "deno run -RN server.ts",
            "dependencies": ["build", "generate"]
        }
    }
}

Executing deno task serve will first execute build and generate tasks
(in parallel) and once both complete the serve task will be executed.

Number of tasks run in parallel is equal to the no of cores on the machine,
and respects DENO_JOBS env var if one is specified.

  • Tests
  • Cycle detection
  • Concurrency

For follow up PRs:

  • Cross package dependencies (../client:build)
  • files and output fields for better caching and coordination
  • caching based on files/output options
  • automatic cleaning of output files

Part of #26462

@bartlomieju bartlomieju added this to the 2.1.0 milestone Oct 24, 2024
cli/tools/task.rs Outdated Show resolved Hide resolved
bartlomieju added a commit that referenced this pull request Nov 16, 2024
This commit changes three aspects of `deno task`:
1. Tasks can now be written using object notation like so:
```jsonc
{
  "tasks": {
     "foo": "deno run foo.js",
     "bar": {
        "command": "deno run bar.js"
     }
}
```
2. Support for comments for tasks is now removed. Comments above tasks
will
no longer be printed when running `deno task`.
3. Tasks written using object notation can have "description" field that
replaces
support for comments above tasks:
```jsonc
{
  "tasks": {
     "bar": {
        "description": "This is a bar task"
        "command": "deno run bar.js"
     }
}
```
```
$ deno task
Available tasks:
- bar
    // This is a bar task
    deno run bar.js
```

Pulled most of the changes from
#26467 to
support "dependencies" in tasks. Additionally some cleanup was performed
to make code easier to read.

---------

Co-authored-by: David Sherret <dsherret@gmail.com>
@bartlomieju bartlomieju marked this pull request as ready for review November 16, 2024 12:04
@bartlomieju bartlomieju changed the title feat(task): dependencies (WIP) feat(task): dependencies Nov 16, 2024
cli/tools/task.rs Outdated Show resolved Hide resolved
Comment on lines +1 to +6
Task e deno run e.js
Running e
[UNORDERED_START]
Task b deno run b.js
Running b
Task d deno run d.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we might want to show that this task is being run because it's a dependency of another task. Could be done in a follow up though.

cli/tools/task.rs Outdated Show resolved Hide resolved
cli/tools/task.rs Outdated Show resolved Hide resolved
cli/tools/task.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bartlomieju bartlomieju enabled auto-merge (squash) November 19, 2024 12:45
@bartlomieju bartlomieju merged commit 661aa22 into denoland:main Nov 19, 2024
17 checks passed
@bartlomieju bartlomieju deleted the feat_task_dependencies branch November 19, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants