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

- **Changed** The run summary now says a task that wrote a file it also read was `not cached because it modified its inputs`, and the statistics in `vp run --verbose` and `vp run --last-details` use the singular for a count of one, e.g. `1 task • 1 cache miss` ([#783](https://github.com/voidzero-dev/vite-task/pull/783)).
- **Fixed** An invalid glob in `--filter` no longer shows its error message twice ([#763](https://github.com/voidzero-dev/vite-task/pull/763)).
- **Changed** The detailed summary from `vp run --verbose` and `vp run --last-details` now shows each underlying cause of an error on its own line ([#761](https://github.com/voidzero-dev/vite-task/pull/761)).
- **Added** Remote caching. Configure an endpoint with the workspace's `cache: { remote: { url } }` or `VP_REMOTE_CACHE_URL`, and choose access with `--remote-cache=off|read|read-write` or `VP_REMOTE_CACHE`. The default is `read` with an endpoint and `off` without one. After a local cache miss, `vp run` looks the task up in the remote cache and, on a hit, restores its outputs and caches it locally. The task output and the run summary show which hits came from the remote cache. A failed read is just a cache miss, with the failure as its reason. In `read-write` mode, `vp run` also uploads the results of successful, cacheable tasks after caching them locally. A failed upload doesn't fail the task; the run summary shows a warning instead. Ctrl-C, or a failing task, stops remote cache requests right away, and a task still being looked up doesn't start. Tasks can opt out with `cache: { remote: false }`. Requests use the proxy environment variables or, on macOS and Windows, the system proxy settings ([#727](https://github.com/voidzero-dev/vite-task/pull/727), [#755](https://github.com/voidzero-dev/vite-task/pull/755), [#756](https://github.com/voidzero-dev/vite-task/pull/756), [#757](https://github.com/voidzero-dev/vite-task/pull/757), [#764](https://github.com/voidzero-dev/vite-task/pull/764), [#771](https://github.com/voidzero-dev/vite-task/pull/771), [#772](https://github.com/voidzero-dev/vite-task/pull/772)).
Expand Down
27 changes: 16 additions & 11 deletions crates/vt/src/session/reporter/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,18 +728,20 @@ pub fn format_full_summary(summary: &LastRunSummary) -> Vec<u8> {

let total = stats.total;
let cache_hits = stats.cache_hits;
let cache_misses = stats.cache_misses;
let cache_hits_count = count_noun(cache_hits, "cache hit", "cache hits");
let cache_hits_str = match stats.remote_cache_hits {
0 => vt_str::format!("• {cache_hits} cache hits"),
remote => vt_str::format!("• {cache_hits} cache hits ({remote} remote)"),
0 => vt_str::format!("• {cache_hits_count}"),
remote => vt_str::format!("• {cache_hits_count} ({remote} remote)"),
};
let _ = write!(
buf,
"{} {} {} {}",
"Statistics:".style(Style::new().bold()),
vt_str::format!(" {total} tasks").style(Style::new().bright_white()),
vt_str::format!(" {}", count_noun(total, "task", "tasks"))
.style(Style::new().bright_white()),
cache_hits_str.style(Style::new().green()),
vt_str::format!("• {cache_misses} cache misses").style(CACHE_MISS_STYLE),
vt_str::format!("• {}", count_noun(stats.cache_misses, "cache miss", "cache misses"))
.style(CACHE_MISS_STYLE),
);
if !cache_disabled_str.is_empty() {
let _ = write!(buf, " {cache_disabled_str}");
Expand Down Expand Up @@ -883,6 +885,11 @@ fn write_error_lines(buf: &mut Vec<u8>, label: impl Display, error: &SavedError,
write_causes(buf, &error.causes, style);
}

/// Format `count` followed by `singular` if it is 1, or by `plural` otherwise.
fn count_noun(count: usize, singular: &str, plural: &str) -> Str {
vt_str::format!("{count} {}", if count == 1 { singular } else { plural })
}

/// Write each cause on its own line, below a task detail line.
fn write_causes(buf: &mut Vec<u8>, causes: &[Str], style: Style) {
for cause in causes {
Expand Down Expand Up @@ -1000,7 +1007,7 @@ pub fn format_compact_summary(summary: &LastRunSummary, program_name: &str) -> V
buf
}

/// Write the "not cached because it modified its input" notice inline.
/// Write the "not cached because it modified its inputs" notice inline.
fn format_input_modified_notice(buf: &mut Vec<u8>, task_names: &[Str]) {
let _ = write!(buf, " ");

Expand All @@ -1012,7 +1019,7 @@ fn format_input_modified_notice(buf: &mut Vec<u8>, task_names: &[Str]) {
}

if task_names.len() == 1 {
let _ = write!(buf, " not cached because it modified its input.");
let _ = write!(buf, " not cached because it modified its inputs.");
} else {
let _ = write!(buf, " not cached because they modified their inputs.");
}
Expand Down Expand Up @@ -1149,9 +1156,7 @@ mod tests {
cache_miss_task("c"),
]);
let lines: Vec<&str> = summary.as_str().lines().collect();
assert!(
lines.contains(&"Statistics: 3 tasks • 2 cache hits (1 remote) • 1 cache misses")
);
assert!(lines.contains(&"Statistics: 3 tasks • 2 cache hits (1 remote) • 1 cache miss"));
assert!(lines.contains(&" → Cache hit - output replayed - 1s saved"));
assert!(lines.contains(&" → Remote cache hit - output replayed - 1s saved"));

Expand All @@ -1160,7 +1165,7 @@ mod tests {
summary
.as_str()
.lines()
.any(|line| line == "Statistics: 1 tasks • 1 cache hits • 0 cache misses")
.any(|line| line == "Statistics: 1 task • 1 cache hit • 0 cache misses")
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ stat 20000
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand All @@ -42,7 +42,7 @@ stat 20000
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[e2e]]
name = "single_read_write_task_shows_not_cached_message"
comment = """
A single task that reads and writes the same file (fspy sees both ops) should be flagged as "not cached because it modified its input" in the compact summary.
A single task that reads and writes the same file (fspy sees both ops) should be flagged as "not cached because it modified its inputs" in the compact summary.
"""
cwd = "packages/rw-pkg"
steps = [["vt", "run", "task"], ["vt", "run", "task"]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Opening a single file with `O_RDWR` (e.g. `touch` keeping the file) should count
~/packages/touch-pkg$ vtt touch-file src/data.txt

---
vt run: @test/touch-pkg#task not cached because it modified its input. (Run `vt run --last-details` for full details)
vt run: @test/touch-pkg#task not cached because it modified its inputs. (Run `vt run --last-details` for full details)
```

## `vt run task`
Expand All @@ -17,5 +17,5 @@ vt run: @test/touch-pkg#task not cached because it modified its input. (Run `vt
~/packages/touch-pkg$ vtt touch-file src/data.txt

---
vt run: @test/touch-pkg#task not cached because it modified its input. (Run `vt run --last-details` for full details)
vt run: @test/touch-pkg#task not cached because it modified its inputs. (Run `vt run --last-details` for full details)
```
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# single_read_write_task_shows_not_cached_message

A single task that reads and writes the same file (fspy sees both ops) should be flagged as "not cached because it modified its input" in the compact summary.
A single task that reads and writes the same file (fspy sees both ops) should be flagged as "not cached because it modified its inputs" in the compact summary.

## `vt run task`

```
~/packages/rw-pkg$ vtt replace-file-content src/data.txt i !

---
vt run: @test/rw-pkg#task not cached because it modified its input. (Run `vt run --last-details` for full details)
vt run: @test/rw-pkg#task not cached because it modified its inputs. (Run `vt run --last-details` for full details)
```

## `vt run task`
Expand All @@ -17,5 +17,5 @@ vt run: @test/rw-pkg#task not cached because it modified its input. (Run `vt run
~/packages/rw-pkg$ vtt replace-file-content src/data.txt i !

---
vt run: @test/rw-pkg#task not cached because it modified its input. (Run `vt run --last-details` for full details)
vt run: @test/rw-pkg#task not cached because it modified its inputs. (Run `vt run --last-details` for full details)
```
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Under `-v`, the full summary should list the exact overlapping path that caused
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ summary reports the replayed cache hit
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 1 cache hits • 0 cache misses
Statistics: 1 task • 1 cache hit • 0 cache misses
Performance: 100% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ summary reports the replayed cache hit
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 1 cache hits • 0 cache misses
Statistics: 1 task • 1 cache hit • 0 cache misses
Performance: 100% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[e2e]]
name = "node_compile_cache_does_not_poison_workspace"
comment = """
Runs a small Node script that turns on Node's compile cache. The cache should land in the OS temp directory (outside the workspace), so two `vt run --cache build` calls should be a miss then a hit. On Windows, if the spawned task env doesn't have `LOCALAPPDATA`, Node puts the cache inside the workspace instead, the runner sees the same files both written and read, and refuses to cache the run — so the second call becomes another miss with a "not cached because it modified its input" message.
Runs a small Node script that turns on Node's compile cache. The cache should land in the OS temp directory (outside the workspace), so two `vt run --cache build` calls should be a miss then a hit. On Windows, if the spawned task env doesn't have `LOCALAPPDATA`, Node puts the cache inside the workspace instead, the runner sees the same files both written and read, and refuses to cache the run — so the second call becomes another miss with a "not cached because it modified its inputs" message.
"""
ignore = true
steps = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# node_compile_cache_does_not_poison_workspace

Runs a small Node script that turns on Node's compile cache. The cache should land in the OS temp directory (outside the workspace), so two `vt run --cache build` calls should be a miss then a hit. On Windows, if the spawned task env doesn't have `LOCALAPPDATA`, Node puts the cache inside the workspace instead, the runner sees the same files both written and read, and refuses to cache the run — so the second call becomes another miss with a "not cached because it modified its input" message.
Runs a small Node script that turns on Node's compile cache. The cache should land in the OS temp directory (outside the workspace), so two `vt run --cache build` calls should be a miss then a hit. On Windows, if the spawned task env doesn't have `LOCALAPPDATA`, Node puts the cache inside the workspace instead, the runner sees the same files both written and read, and refuses to cache the run — so the second call becomes another miss with a "not cached because it modified its inputs" message.

## `vt run --cache build`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The details include the underlying error.
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The details include the underlying error.
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ vtt write-file dist/output.txt built ○ cache miss: remote cache fetch failed
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The details include the underlying error.
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The details include the underlying error.
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ display saved summary
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ built-a
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 1 cache misses
Statistics: 1 task • 0 cache hits • 1 cache miss
Performance: 0% cache hit rate

Task Details:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build app
Vite+ Task Runner • Execution Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled
Statistics: 1 task • 0 cache hits • 0 cache misses • 1 cache disabled
Performance: 0% cache hit rate

Task Details:
Expand Down
Loading