Skip to content

Commit

Permalink
fetch & upload source archive before trying to build
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Jun 23, 2024
1 parent 34981d9 commit 9d67958
Showing 1 changed file with 44 additions and 15 deletions.
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

0 comments on commit 9d67958

Please sign in to comment.