Skip to content

fetch & upload source archive before trying to build #2529

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 1 commit into from
Jun 23, 2024
Merged
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
59 changes: 44 additions & 15 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,22 @@ impl RustwideBuilder {
let successful = build_dir
.build(&self.toolchain, &krate, self.prepare_sandbox(&limits))
.run(|build| {
let mut algs = HashSet::new();

debug!("adding sources into database");
let files_list = {
let (files_list, new_alg) = self
.runtime
.block_on(add_path_into_remote_archive(
&self.async_storage,
&source_archive_path(name, version),
build.host_source_dir(),
false,
))
.map_err(|e| failure::Error::from_boxed_compat(e.into()))?;
algs.insert(new_alg);
files_list
};
let metadata = Metadata::from_crate_root(build.host_source_dir())?;
let BuildTargets {
default_target,
Expand Down Expand Up @@ -528,7 +544,6 @@ impl RustwideBuilder {
}
}

let mut algs = HashSet::new();
let mut target_build_logs = HashMap::new();
if has_docs {
debug!("adding documentation for the default target to the database");
Expand Down Expand Up @@ -564,20 +579,6 @@ impl RustwideBuilder {
algs.insert(new_alg);
};

// Store the sources even if the build fails
debug!("adding sources into database");
let files_list = {
let (files_list, new_alg) =
self.runtime.block_on(add_path_into_remote_archive(
&self.async_storage,
&source_archive_path(name, version),
build.host_source_dir(),
false,
))?;
algs.insert(new_alg);
files_list
};

let has_examples = build.host_source_dir().join("examples").is_dir();
if res.result.successful {
self.metrics.successful_builds.inc();
Expand Down Expand Up @@ -1369,6 +1370,34 @@ mod tests {
});
}

#[test]
#[ignore]
fn test_sources_are_added_even_for_build_failures_before_build() {
wrapper(|env| {
// https://github.com/rust-lang/docs.rs/issues/2523
// package with invalid cargo metadata.
// Will succeed in the crate fetch step, so sources are
// added. Will fail when we try to build.
let crate_ = "simconnect-sys";
let version = "0.23.1";
let mut builder = RustwideBuilder::init(env).unwrap();
builder.update_toolchain()?;

// `Result` is `Ok`, but the build-result is `false`
assert!(!builder.build_package(crate_, version, PackageKind::CratesIo)?);

// source archice exists
let source_archive = source_archive_path(crate_, version);
assert!(
env.storage().exists(&source_archive)?,
"archive doesnt exist: {}",
source_archive
);

Ok(())
});
}

#[test]
#[ignore]
fn test_build_failures_before_build() {
Expand Down
Loading