Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

- **Fixed** When a command handler sets a working directory for a command it generates, `vp run` now runs that command in the selected directory and includes the directory in its cache fingerprint ([#1005](https://github.com/voidzero-dev/vite-task/pull/1005)).
- **Fixed** On Windows, tasks with automatic file-access tracking can now run Git Bash's `sh` and other MSYS2 or Cygwin programs, which aborted with `fatal error - MapViewOfFileEx 'shared.5'(…) Win32 error 487` ([#830](https://github.com/voidzero-dev/vite-task/issues/830), [#952](https://github.com/voidzero-dev/vite-task/pull/952)).
- **Fixed** On Linux, cached tasks no longer fail to spawn child processes in restricted sandboxes, for example rootless bubblewrap that denies the `seccomp` syscall. When the `seccomp` filter for file-access tracking cannot be installed, the process runs untracked instead and the run is reported as not cached. The not-cached message now reads "automatic file tracking couldn't record everything this task did", which fits both this case and a full tracking channel ([#700](https://github.com/voidzero-dev/vite-task/issues/700), [#701](https://github.com/voidzero-dev/vite-task/pull/701)).
- **Fixed** `vp run <task>` in a package that doesn't define the task now reports `Task "<task>" not found` when another package's `vite.config.*` fails to load, instead of failing with that package's error. Showing the tasks to choose from loads every package's config, so the task selector or task list is skipped then ([#987](https://github.com/voidzero-dev/vite-task/pull/987)).
Expand Down
9 changes: 8 additions & 1 deletion crates/vt_bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ enum Args {
/// then synthesizes a cached invocation with the given arguments. The `--` separator,
/// if present, is stripped before forwarding.
Tool {
/// Run `vtt` in this directory, relative to the script's cwd. This exercises
/// a handler that changes the command's cwd, like `vp -C <dir>`.
#[clap(short = 'C')]
dir: Option<Str>,
#[clap(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<Str>,
},
Expand Down Expand Up @@ -89,7 +93,10 @@ impl vt::CommandHandler for CommandHandler {
std::iter::once(command.program.as_str()).chain(command.args.iter().map(Str::as_str)),
)?;
match args {
Args::Tool { args } => {
Args::Tool { dir, args } => {
if let Some(dir) = dir {
command.cwd = command.cwd.join(dir.as_str()).into();
}
let program = find_executable(get_path_env(&command.envs), &command.cwd, "vtt")?;
Ok(HandledCommand::Synthesized(SyntheticPlanRequest {
program,
Expand Down
3 changes: 2 additions & 1 deletion crates/vt_plan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ pub trait PlanRequestParser: Debug {
/// - If it returns `Ok(Some(PlanRequest::Query))`, the command will be expanded as a `ExpandedExecution` with a task graph queried from the returned `TaskQuery`.
/// - If it returns `Ok(Some(PlanRequest::Synthetic))`, the command will become a `SpawnExecution` with the synthetic task.
///
/// When a `PlanRequest` is returned, any mutations to `command` are discarded.
/// When a `PlanRequest` is returned, mutations to `command` are discarded, except that
/// a `PlanRequest::Synthetic` runs in the (potentially mutated) `command.cwd`.
async fn get_plan_request(
&mut self,
command: &mut plan_request::ScriptCommand,
Expand Down
2 changes: 1 addition & 1 deletion crates/vt_plan/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ async fn plan_task_as_execution_node(
&and_item.envs,
synthetic_plan_request,
Some(task_execution_cache_key),
&cwd,
&script_command.cwd,
package_path,
parent_cache_config,
context.resolved_remote_cache(),
Expand Down
4 changes: 3 additions & 1 deletion crates/vt_plan/src/plan_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use vt_str::Str;
///
/// All fields use `Arc` for cheap reassignment. The implementation can mutate
/// these fields to modify how the command is executed when it falls through as a
/// normal process (i.e., when `get_plan_request` returns `None`).
/// normal process (i.e., when `get_plan_request` returns `None`). A mutated `cwd`
/// also applies to synthetic requests. A query request uses the cwd that the
/// parser puts into its query.
#[derive(Debug)]
pub struct ScriptCommand {
pub program: Str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"scripts": {
"build": "vtt print-file package.json",
"cd-build": "cd src && vt run build",
"cd-lint": "cd src && vt tool print lint"
"cd-lint": "cd src && vt tool print lint",
"dir-lint": "vt tool -C src print lint && vt tool print lint"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ args = ["run", "cd-build"]
[[plan]]
name = "cd_before_vt_lint_should_put_synthetic_task_under_cwd"
args = ["run", "cd-lint"]

[[plan]]
name = "handler_cwd_applies_to_synthetic_task_only"
args = ["run", "dir-lint"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// run dir-lint
{
"graph": [
{
"key": [
"<workspace>/",
"dir-lint"
],
"node": {
"task_display": {
"package_name": "",
"task_name": "dir-lint",
"package_path": "<workspace>/"
},
"items": [
{
"execution_item_display": {
"task_display": {
"package_name": "",
"task_name": "dir-lint",
"package_path": "<workspace>/"
},
"command": "vt tool -C src print lint",
"cwd": "<workspace>/"
},
"kind": {
"Leaf": {
"Spawn": {
"cache_metadata": {
"spawn_fingerprint": {
"cwd": "src",
"program_fingerprint": {
"OutsideWorkspace": {
"program_name": "vtt"
}
},
"args": [
"print",
"lint"
],
"env_fingerprints": {
"fingerprinted_envs": {},
"untracked_env_config": [
"<default untracked envs>"
]
}
},
"execution_cache_key": {
"UserTask": {
"task_name": "dir-lint",
"command_item_index": 0,
"and_item_index": 0,
"extra_args": [],
"package_path": ""
}
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
},
"output_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
},
"remote_cache": null
},
"spawn_command": {
"program_path": "<tools>/vtt",
"args": [
"print",
"lint"
],
"spawn_envs": {
"FORCE_COLOR": "1",
"PATH": "<workspace>/node_modules/.bin:<tools>",
"VP_RUN": "1"
},
"cwd": "<workspace>/src"
}
}
}
}
},
{
"execution_item_display": {
"task_display": {
"package_name": "",
"task_name": "dir-lint",
"package_path": "<workspace>/"
},
"command": "vt tool print lint",
"cwd": "<workspace>/"
},
"kind": {
"Leaf": {
"Spawn": {
"cache_metadata": {
"spawn_fingerprint": {
"cwd": "",
"program_fingerprint": {
"OutsideWorkspace": {
"program_name": "vtt"
}
},
"args": [
"print",
"lint"
],
"env_fingerprints": {
"fingerprinted_envs": {},
"untracked_env_config": [
"<default untracked envs>"
]
}
},
"execution_cache_key": {
"UserTask": {
"task_name": "dir-lint",
"command_item_index": 0,
"and_item_index": 1,
"extra_args": [],
"package_path": ""
}
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
},
"output_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
},
"remote_cache": null
},
"spawn_command": {
"program_path": "<tools>/vtt",
"args": [
"print",
"lint"
],
"spawn_envs": {
"FORCE_COLOR": "1",
"PATH": "<workspace>/node_modules/.bin:<tools>",
"VP_RUN": "1"
},
"cwd": "<workspace>/"
}
}
}
}
}
]
},
"neighbors": []
}
],
"concurrency_limit": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ flowchart TD
task_0["<workspace>/#build"]
task_1["<workspace>/#cd-build"]
task_2["<workspace>/#cd-lint"]
task_3["<workspace>/#dir-lint"]
```

## `<workspace>/#build`
Expand Down Expand Up @@ -127,3 +128,43 @@ flowchart TD
}
```

## `<workspace>/#dir-lint`

```json
{
"task_display": {
"package_name": "",
"task_name": "dir-lint",
"package_path": "<workspace>/"
},
"resolved_config": {
"commands": [
"vt tool -C src print lint && vt tool print lint"
],
"resolved_options": {
"cwd": "<workspace>/",
"cache_config": {
"remote_cache_allowed": true,
"env_config": {
"fingerprinted_envs": [],
"untracked_env": [
"<default untracked envs>"
]
},
"input_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
},
"output_config": {
"includes_auto": true,
"positive_globs": [],
"negative_globs": []
}
}
}
},
"source": "PackageJsonScript"
}
```

Loading