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** Tasks that list `node_modules`, the workspace root, or `node_modules/.vite` no longer miss the cache when pnpm's `node_modules/.pnpm-workspace-state-*.json`, Vite's `node_modules/.vite-temp`, the workspace root's `.git`, or the task cache directory appear or disappear. Direct accesses to `node_modules/.vite-temp` and `.DS_Store` are now skipped as well, so they are neither tracked as inputs nor archived as outputs ([#1014](https://github.com/voidzero-dev/vite-task/pull/1014)).
- **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)).
Expand Down
7 changes: 6 additions & 1 deletion crates/vt/src/session/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use super::{
event::RunKind,
execute::{
fingerprint::{PathFingerprint, PostRunFingerprint},
ignored_paths::relative_cache_root,
pipe::StdOutput,
},
};
Expand Down Expand Up @@ -468,7 +469,7 @@ pub fn split_path(path: &str) -> (Option<&str>, &str) {
/// its own cache warm across branch switches, and a cache from a different
/// version is simply ignored (it lives in a directory this build never looks
/// at) rather than aborting the run. Bumping the version starts a fresh cache.
const CACHE_SCHEMA_VERSION: u32 = 23;
const CACHE_SCHEMA_VERSION: u32 = 24;

/// Name of the per-version subdirectory (e.g. `v14`) under the task-cache
/// directory that holds the database and output archives for the current
Expand Down Expand Up @@ -551,6 +552,8 @@ struct Validation {
globbed_inputs: Arc<BTreeMap<RelativePathBuf, u64>>,
input_negative_globs: Arc<PathGlobSet<'static>>,
workspace_root: Arc<AbsolutePath>,
/// Workspace-relative task cache root, left out of directory listings.
cache_root: Option<RelativePathBuf>,
/// How many changed files to look for.
file_check: FileCheck,
}
Expand All @@ -563,6 +566,7 @@ impl Validation {
&self.globbed_inputs,
&self.input_negative_globs,
&self.workspace_root,
self.cache_root.as_deref(),
self.file_check,
)
}
Expand Down Expand Up @@ -649,6 +653,7 @@ impl ExecutionCache {
PathGlobSet::new(&cache_metadata.input_config.negative_globs)?.into_owned(),
),
workspace_root: Arc::clone(workspace_root),
cache_root: relative_cache_root(cache_dir, workspace_root),
file_check,
};

Expand Down
1 change: 1 addition & 0 deletions crates/vt/src/session/cache/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ mod tests {
&globbed_inputs,
&PathGlobSet::default(),
&workspace_root,
None,
FileCheck::First,
)
}
Expand Down
8 changes: 7 additions & 1 deletion crates/vt/src/session/cache/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{collections::BTreeMap, ffi::OsStr, sync::Arc};
use rustc_hash::{FxHashMap, FxHashSet};
use vt_casefold::EnvName;
use vt_glob::path::PathGlobSet;
use vt_path::{AbsolutePath, RelativePathBuf};
use vt_path::{AbsolutePath, RelativePath, RelativePathBuf};
use vt_plan::cache_metadata::SpawnFingerprint;

use super::{
Expand Down Expand Up @@ -35,6 +35,7 @@ impl CacheEntryValue {
globbed_inputs: &BTreeMap<RelativePathBuf, u64>,
input_negative_globs: &PathGlobSet<'_>,
workspace_root: &AbsolutePath,
cache_root: Option<&RelativePath>,
file_check: FileCheck,
) -> anyhow::Result<Checked> {
// Without `-v`, the first changed file is enough to know it's a miss.
Expand All @@ -45,6 +46,7 @@ impl CacheEntryValue {
let input_changes = self.post_run_fingerprint.input_changes(
workspace_root,
input_negative_globs,
cache_root,
file_check,
);
partial |= add_checked(&mut changes, input_changes, "inferred inputs")?;
Expand Down Expand Up @@ -232,6 +234,7 @@ mod tests {
&inputs,
&PathGlobSet::default(),
&workspace_root,
None,
FileCheck::First,
)
};
Expand Down Expand Up @@ -276,6 +279,7 @@ mod tests {
&BTreeMap::new(),
&PathGlobSet::default(),
&workspace_root,
None,
FileCheck::First,
)
.unwrap();
Expand Down Expand Up @@ -310,6 +314,7 @@ mod tests {
&current,
&PathGlobSet::default(),
&workspace_root,
None,
file_check,
)
.unwrap()
Expand Down Expand Up @@ -371,6 +376,7 @@ mod tests {
&BTreeMap::new(),
&PathGlobSet::default(),
&workspace_root,
None,
file_check,
)
};
Expand Down
25 changes: 14 additions & 11 deletions crates/vt/src/session/execute/cache_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
use rustc_hash::FxHashSet;
use tokio_util::sync::CancellationToken;
use vt_glob::path::PathGlobSet;
use vt_path::{AbsolutePath, RelativePathBuf};
use vt_path::{AbsolutePath, RelativePath, RelativePathBuf};
use vt_plan::cache_metadata::{CacheMetadata, EnvValueHash};
use vt_server::Reports;
use vt_str::Str;
Expand All @@ -19,6 +19,7 @@ use super::{
CacheState,
fingerprint::{PathRead, PostRunFingerprint, TrackedEnvQuery},
glob,
ignored_paths::relative_cache_root,
rebuildable::Rebuildable,
spawn::ChildOutcome,
};
Expand Down Expand Up @@ -112,6 +113,9 @@ pub(super) async fn update_cache(
return (CacheUpdateStatus::NotUpdated(CacheNotUpdatedReason::TrackingIncomplete), None);
};

// Every schema version's folder is in the task cache, not only this one.
let cache_root = relative_cache_root(cache_dir, workspace_root);

let fspy_outcome = observe_fspy(
#[cfg(fspy)]
path_accesses,
Expand All @@ -120,7 +124,7 @@ pub(super) async fn update_cache(
&ignored_input_rels,
&ignored_output_rels,
workspace_root,
cache_dir,
cache_root.as_deref(),
);

if fspy_outcome.is_none() && fspy.is_some() {
Expand All @@ -146,19 +150,19 @@ pub(super) async fn update_cache(
// Paths already in globbed_inputs are skipped: they are hashed before
// the run, so one that the task rewrote makes the next run miss instead
// of hitting a stale entry.
let empty_path_reads = HashMap::default();
let (empty_path_reads, no_writes, no_globs) =
(HashMap::default(), Rebuildable::default(), PathGlobSet::default());
let path_reads = fspy_outcome.as_ref().map_or(&empty_path_reads, |o| &o.path_reads);
let no_writes = Rebuildable::default();
let rebuildable = fspy_outcome.as_ref().map_or(&no_writes, |o| &o.rebuildable);
// Listings leave out the entries input exclusions match, as reads do.
let no_globs = PathGlobSet::default();
let input_negative_globs = fspy.map_or(&no_globs, |fspy| &fspy.input_negative_globs);
let post_run_fingerprint = match PostRunFingerprint::create(
path_reads,
rebuildable,
input_negative_globs,
&ignored_input_rels,
workspace_root,
cache_root.as_deref(),
&globbed_inputs,
tracked_envs,
tracked_env_queries,
Expand Down Expand Up @@ -229,21 +233,20 @@ fn observe_fspy(
ignored_input_rels: &FxHashSet<RelativePathBuf>,
ignored_output_rels: &FxHashSet<RelativePathBuf>,
workspace_root: &AbsolutePath,
cache_dir: &AbsolutePath,
cache_root: Option<&RelativePath>,
) -> Option<TrackingOutcome> {
#[cfg(fspy)]
{
use super::tracked_accesses::TrackedPathAccesses;

// Every schema version's folder is in the task cache, not only this one.
let cache_root = cache_dir.parent().unwrap_or(cache_dir);
path_accesses.map(|raw| {
let tracked = TrackedPathAccesses::from_raw(raw, workspace_root, cache_root);
let mut rebuildable = Rebuildable::new(
tracked.path_writes,
tracked.rename_targets,
tracked.mkdirs,
workspace_root,
cache_root,
);
let filtered_path_reads: HashMap<RelativePathBuf, PathRead> =
// fspy can be attached for auto-output-only tasks. In that
Expand Down Expand Up @@ -280,9 +283,9 @@ fn observe_fspy(
// without them, the archive still takes the empty folders the
// task made.
rebuildable = if filtered_path_reads.is_empty() {
rebuildable.with_empty_folders(workspace_root)
rebuildable.with_empty_folders(workspace_root, cache_root)
} else {
rebuildable.with_folders(workspace_root)
rebuildable.with_folders(workspace_root, cache_root)
};
TrackingOutcome {
path_reads: filtered_path_reads,
Expand All @@ -301,7 +304,7 @@ fn observe_fspy(
#[cfg(not(fspy))]
{
let _ =
(metadata, fspy, ignored_input_rels, ignored_output_rels, workspace_root, cache_dir);
(metadata, fspy, ignored_input_rels, ignored_output_rels, workspace_root, cache_root);
None
}
}
Expand Down
Loading
Loading