-
Notifications
You must be signed in to change notification settings - Fork 23
feat(cache): add output globs for cache restoration #375
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d03bc0
feat(cache): add output globs for cache restoration
branchseer eb4ec37
docs(changelog): trim output field entry
branchseer 056bd46
refactor(cache/archive): use metadata error for existence check
branchseer 008f50a
refactor(cache): simplify fingerprint-mismatch detection
branchseer a7e4647
feat(cache): explain how to recover from corrupted output archive
branchseer f646282
refactor(execute/glob_inputs): share walker between input hashing and…
branchseer 404bcd9
test(e2e): verify old output archive is removed on re-run
branchseer 4bfa472
refactor(execute/glob): rename module and tighten walker API
branchseer 015a9a6
docs(config): flag from_user_output_config as a transient helper
branchseer 90fdf91
test(e2e): inline step comments + assert skip.txt is not restored
branchseer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| //! Output archive creation and extraction using tar + zstd compression. | ||
|
|
||
| use std::{fs::File, io}; | ||
|
|
||
| use vite_path::{AbsolutePath, RelativePathBuf}; | ||
|
|
||
| /// Create a tar.zst archive from workspace-relative output file paths. | ||
| /// | ||
| /// Files that no longer exist are silently skipped (the task may delete | ||
| /// temporary files during execution). | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns an error if creating the archive file or adding entries fails. | ||
| pub fn create_output_archive( | ||
| workspace_root: &AbsolutePath, | ||
| output_files: &[RelativePathBuf], | ||
| archive_path: &AbsolutePath, | ||
| ) -> anyhow::Result<()> { | ||
| let file = File::create(archive_path.as_path())?; | ||
| let encoder = zstd::Encoder::new(file, 0)?.auto_finish(); | ||
| let mut builder = tar::Builder::new(encoder); | ||
|
|
||
| for rel_path in output_files { | ||
| let abs_path = workspace_root.join(rel_path); | ||
| // Skip files that no longer exist (task may delete temp files between | ||
| // glob walk and archiving). Any other error is propagated. | ||
| let metadata = match std::fs::metadata(abs_path.as_path()) { | ||
| Ok(m) => m, | ||
| Err(err) if err.kind() == io::ErrorKind::NotFound => continue, | ||
| Err(err) => return Err(err.into()), | ||
| }; | ||
| if metadata.is_file() { | ||
| let mut file = File::open(abs_path.as_path())?; | ||
| let mut header = tar::Header::new_gnu(); | ||
| header.set_metadata(&metadata); | ||
| header.set_cksum(); | ||
| builder.append_data(&mut header, rel_path.as_str(), &mut file)?; | ||
| } | ||
| } | ||
|
|
||
| builder.finish()?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| /// Extract a tar.zst archive, restoring files relative to workspace root. | ||
| /// | ||
| /// Parent directories are created automatically. Existing files are overwritten. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns an error if opening the archive or extracting entries fails. | ||
| pub fn extract_output_archive( | ||
| workspace_root: &AbsolutePath, | ||
| archive_path: &AbsolutePath, | ||
| ) -> anyhow::Result<()> { | ||
| let file = File::open(archive_path.as_path())?; | ||
| let decoder = zstd::Decoder::new(file)?; | ||
| let mut archive = tar::Archive::new(decoder); | ||
|
|
||
| archive.unpack(workspace_root.as_path())?; | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.