Skip to content

Commit

Permalink
Fail build if cargo build does not succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
nikarh committed Oct 8, 2023
1 parent 9660861 commit 308b44e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 49 deletions.
94 changes: 47 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl<'a> BuildContext<'a> {
}
}

#[derive(Debug)]
struct ExecutableArtifact {
artifact: Artifact,
meta: PackageMetadata,
Expand Down Expand Up @@ -273,15 +274,21 @@ impl<'a> BuildContext<'a> {
.collect::<io::Result<_>>()
.context("Unable to parse build stdout")?;

messages
let artifacts = messages
.iter()
.rev()
.filter_map(|m| match m {
Message::CompilerArtifact(art) if art.executable.is_some() => Some(art.clone()),
_ => None,
})
.map(ExecutableArtifact::new)
.collect()
.collect::<anyhow::Result<_>>()?;

if !process.wait_with_output()?.status.success() {
bail!("cargo build failed")
}

Ok(artifacts)
}

fn strip(&self, art: &ExecutableArtifact) -> anyhow::Result<()> {
Expand Down

0 comments on commit 308b44e

Please sign in to comment.