Skip to content
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

Fix parsing of docker STDOUT #1526

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]


### Added
- Export `ink_metadata` types in `transcode` crate - [#1522](https://github.com/paritytech/cargo-contract/pull/1522)

### Fixed
- Fix parsing of docker STDOUT - [#1526](https://github.com/paritytech/cargo-contract/pull/1526)

## [4.0.0-rc.3]

### Fixed
Expand Down
27 changes: 16 additions & 11 deletions crates/build/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ async fn create_container(
let container_option = containers.first();

if container_option.is_some() {
return Ok(container_name)
return Ok(container_name);
}

let mount = Mount {
Expand Down Expand Up @@ -414,17 +414,11 @@ async fn run_build(
let stderr = std::io::stderr();
let mut stderr = stderr.lock();
let mut build_result = None;
let mut build_bytes: Vec<u8> = vec![];
SkymanOne marked this conversation as resolved.
Show resolved Hide resolved
ascjones marked this conversation as resolved.
Show resolved Hide resolved
while let Some(Ok(output)) = output.next().await {
match output {
LogOutput::StdOut { message } => {
build_result = Some(
serde_json::from_reader(BufReader::new(message.as_ref())).context(
format!(
"Error decoding BuildResult:\n {}",
std::str::from_utf8(&message).unwrap()
),
),
);
build_bytes.extend(&message);
}
LogOutput::StdErr { message } => {
stderr.write_all(message.as_ref())?;
Expand All @@ -434,9 +428,20 @@ async fn run_build(
panic!("LogOutput::Console")
}
LogOutput::StdIn { message: _ } => panic!("LogOutput::StdIn"),
}
};
}

if !build_bytes.is_empty() {
build_result = Some(
serde_json::from_reader(BufReader::new(build_bytes.as_slice())).context(
format!(
"Error decoding BuildResult:\n {}",
std::str::from_utf8(&build_bytes).unwrap()
),
),
)
};

if let Some(build_result) = build_result {
build_result
} else {
Expand Down Expand Up @@ -525,7 +530,7 @@ async fn show_pull_progress(
let status = info.status.unwrap_or_default();
if status.starts_with("Digest:") || status.starts_with("Status:") {
eprintln!("{}", status);
continue
continue;
}

if let Some(id) = info.id {
Expand Down
Loading