Skip to content

feat(cache): skip reads inside directories tagged with CACHEDIR.TAG - #794

Open
lifeiscontent wants to merge 2 commits into
voidzero-dev:mainfrom
lifeiscontent:feat/cachedir-tag
Open

lifeiscontent wants to merge 2 commits into
voidzero-dev:mainfrom
lifeiscontent:feat/cachedir-tag

Conversation

@lifeiscontent

Copy link
Copy Markdown
Contributor

Motivation

Closes #793. Tools that rewrite their own cache on every run, like Vitest, make their task read a file it also writes, so it's never cached. CACHEDIR.TAG lets a tool mark that directory without depending on a runner-specific client.

Changes

  • After a run, the directories of each tracked read inside the workspace are checked once for a valid CACHEDIR.TAG. Reads inside a tagged directory are dropped from automatic inputs, the same way as ignoreInput.
  • Writes there are still outputs and are restored on a cache hit, so tagged build directories like Cargo's target/ keep working.
  • Adds RelativePath::parent, a section in docs/inputs.md, and e2e tests for a tagged directory, no tag, invalid tags, and output restore.

Tools like Vitest read and rewrite their own cache on every run, so a task
that uses them reads a file it also writes and is never cached. The Cache
Directory Tagging spec gives tools a runner-agnostic way to mark such
directories, and Cargo already writes the tag in target/.

After a run, the directories of each tracked read inside the workspace are
checked once for a valid CACHEDIR.TAG, and reads inside a tagged directory
are dropped from automatic inputs, like paths reported through ignoreInput.
Writes there are still outputs, so a cache hit restores them.
@lifeiscontent

Copy link
Copy Markdown
Contributor Author

Vitest now writes CACHEDIR.TAG into its results and module cache directories (vitest-dev/vitest#11461, merged, not released yet). With this PR, vitest run tasks can be cached without the results.json exclude Vite+ adds for vp test.

This branch has not been deployed

No deployments
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.

Let tools mark cache directories with CACHEDIR.TAG

1 participant