Skip to content

flowey: support directories in typed artifacts #1277

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jstarks
Copy link
Member

@jstarks jstarks commented May 1, 2025

Most artifacts contain an explicit list of files and are produced and consumed as such. But some artifacts, such as the output of rustdoc, are produced and consumed as an opaque directory. Today, only untyped artifacts support this.

Support this in typed artifacts by also storing a marker file indicating that this is an opaque directory.

Most artifacts contain an explicit list of files and are produced and
consumed as such. But some artifacts, such as the output of rustdoc,
are produced and consumed as an opaque directory. Today, only untyped
artifacts support this.

Support this in typed artifacts by also storing a marker file indicating
that this is an opaque directory.
@jstarks jstarks requested review from a team as code owners May 1, 2025 22:29
pub trait Artifact: Serialize + DeserializeOwned {
/// If present, the artifact should consist of a tar.gz file containing the
/// contents of the artifact. This is used when the artifact contents are
/// too large for Azure DevOps to handle directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful about writing docs that elevate one backend over any other. This feature is - presumably - functional across all backends (gh actions, and local included). If so - having a clearer delineation in the docs between "here is what this does", and "here is why you may want to use, depending on what backend you're targeting" is good

use std::path::Path;

/// Copies the contents of `src` into the directory `dst`.
pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to do this, my suggestion is to have these functions accept a _rt: &mut RustRuntimeServices<'_> parameter, to act as a "proof" that the function is only called at runtime.

The long-term alternative would be to invest in some more interesting sandboxing during pipeline resolution time (e.g: seccomp filters to fail pipeline compilation if the code attempts to read/write the fs at compile time), but in the meantime, having some guard rails via type-system proof would be good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note that other utils in the mod you pulled this from already follow this pattern, so this might've just been an oversight on my part)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, man, we already can't stop people from reaching for fs_err::copy for single files.

I think the fact that you just don't have the paths to copy to/from is probably enough, in practice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was approaching it more from the lens of API consistency (wrt. some of the other helper APIs that surround it), but sure, these particular filesystem manipulation APIs are probably not going to be misused

@daniel5151
Copy link
Contributor

Does this resolve all outstanding uses of the untyped artifact APIs?

@jstarks
Copy link
Member Author

jstarks commented May 2, 2025

Does this resolve all outstanding uses of the untyped artifact APIs?

Almost. The "set of IGVM files" artifact is still untyped. That one will probably require some manual serde impls, because it wants each IGVM file to be named according to its recipe. I am still thinking about the best way to implement that.

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.

2 participants