Skip to content

Commit

Permalink
packing directory in the archive, not just directory subtree
Browse files Browse the repository at this point in the history
  • Loading branch information
mwu-tow committed Jan 10, 2023
1 parent a0587ae commit 4780dea
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/ci_utils/src/actions/artifacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub async fn upload_compressed_directory(
let archive_path = tempdir.path().join(format!("{artifact_name}.tar.gz"));

info!("Packing {} to {}", path_to_upload.as_ref().display(), archive_path.display());
crate::archive::compress_directory(&archive_path, path_to_upload).await?;
crate::archive::compress_directory_contents(&archive_path, path_to_upload).await?;

info!("Starting upload of {artifact_name}.");
upload_single_file(&archive_path, artifact_name).await?;
Expand Down
5 changes: 4 additions & 1 deletion build/ci_utils/src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ pub fn is_archive_name(path: impl AsRef<Path>) -> bool {
Format::from_filename(path).is_ok()
}

/// Create an archive with directory contents.
///
/// Note that the archive will contain directory's children, not the directory itself.
#[tracing::instrument(
name="Packing directory.",
skip_all,
fields(src=%root_directory.as_ref().display(), dest=%output_archive.as_ref().display()),
err)]
pub async fn compress_directory(
pub async fn compress_directory_contents(
output_archive: impl AsRef<Path>,
root_directory: impl AsRef<Path>,
) -> Result {
Expand Down
2 changes: 1 addition & 1 deletion build/ci_utils/src/github/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub trait IsReleaseExt: IsRelease + Sync {
let temp_dir = tempfile::tempdir()?;
let archive_path =
custom_name.with_parent(temp_dir.path()).with_appended_extension(ARCHIVE_EXTENSION);
crate::archive::compress_directory(&archive_path, &dir_to_upload).await?;
crate::archive::create(&archive_path, [&dir_to_upload]).await?;
self.upload_asset_file(archive_path).await
}

Expand Down
4 changes: 2 additions & 2 deletions build/ci_utils/src/programs/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl Tar {
#[cfg(test)]
pub mod tests {
use super::*;
use crate::archive::compress_directory;
use crate::archive::compress_directory_contents;
use crate::archive::extract_to;
use crate::log::setup_logging;

Expand Down Expand Up @@ -296,7 +296,7 @@ pub mod tests {
let linked_temp = archive_temp.path().join("linked");
symlink::symlink_dir(temp.path(), &linked_temp)?;

compress_directory(&archive_path, &linked_temp).await?;
compress_directory_contents(&archive_path, &linked_temp).await?;
assert!(archive_path.exists());
assert!(archive_path.metadata()?.len() > 0);

Expand Down

0 comments on commit 4780dea

Please sign in to comment.