Skip to content
Closed
Show file tree
Hide file tree
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
16 changes: 9 additions & 7 deletions api/src/call_api.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::mpsc::Sender;
use std::sync::Arc;
use std::sync::mpsc::Sender;
use std::{env, time::Duration};

use constants::TRUNK_API_CLIENT_RETRY_COUNT_ENV;
use display::message::{send_message, DisplayMessage, ProgressMessage};
use display::message::{DisplayMessage, ProgressMessage, send_message};
use http::StatusCode;
use tokio::time::{self, Instant};
use tokio_retry::{strategy::ExponentialBackoff, Action, RetryIf};
use tokio_retry::{Action, RetryIf, strategy::ExponentialBackoff};

use crate::client::{NOT_FOUND_CONTEXT, UNAUTHORIZED_CONTEXT};

Expand All @@ -26,7 +26,9 @@ const fn enforce_increment_check_progress_interval_secs(
return report_slow_progress_timeout_secs;
}
// NOTE: This is a build time error due to `const fn`
panic!("`report_slow_progress_timeout_secs` must be an increment of `CHECK_PROGRESS_INTERVAL_SECS`")
panic!(
"`report_slow_progress_timeout_secs` must be an increment of `CHECK_PROGRESS_INTERVAL_SECS`"
)
}

fn default_delay() -> std::iter::Take<ExponentialBackoff> {
Expand Down Expand Up @@ -199,8 +201,8 @@ where
mod tests {
use std::{
sync::{
atomic::{AtomicUsize, Ordering},
Arc, Mutex,
atomic::{AtomicUsize, Ordering},
},
time::Duration,
};
Expand All @@ -211,10 +213,10 @@ mod tests {
use tokio::time;

use super::{
CallApi, CHECK_PROGRESS_INTERVAL_SECS, REPORT_SLOW_PROGRESS_TIMEOUT_SECS,
CHECK_PROGRESS_INTERVAL_SECS, CallApi, REPORT_SLOW_PROGRESS_TIMEOUT_SECS,
RETRY_COUNT_DEFAULT,
};
use crate::client::{status_code_help, CheckNotFound, CheckUnauthorized};
use crate::client::{CheckNotFound, CheckUnauthorized, status_code_help};
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq, Eq)]
struct EmptyResponse {}

Expand Down
11 changes: 7 additions & 4 deletions bundle/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn unzip_tarball(bundle_path: &PathBuf, unpack_dir: &PathBuf) -> anyhow::Res
}

impl<'a> BundlerUtil<'a> {
const ZSTD_COMPRESSION_LEVEL: i32 = 15; // This gives roughly 10x compression for text, 22 gives 11x.
const ZSTD_COMPRESSION_LEVEL: i32 = 1; // Use low compression level for faster compression/decompression.

pub fn new(meta: &'a BundleMeta, bep_result: Option<BepParseResult>) -> Self {
Self { meta, bep_result }
Expand Down Expand Up @@ -521,7 +521,8 @@ mod tests {

{
let tar_file = std::fs::File::create(&new_bundle_path).unwrap();
let zstd_encoder = zstd::Encoder::new(tar_file, 15).unwrap();
let zstd_encoder =
zstd::Encoder::new(tar_file, BundlerUtil::ZSTD_COMPRESSION_LEVEL).unwrap();
let mut tar_builder = tar::Builder::new(zstd_encoder);

for mut entry in entries_with_internal_bin_last {
Expand Down Expand Up @@ -677,7 +678,8 @@ mod tests {

{
let tar_file = std::fs::File::create(&tarball_path).unwrap();
let zstd_enc = zstd::Encoder::new(tar_file, 15).unwrap();
let zstd_enc =
zstd::Encoder::new(tar_file, BundlerUtil::ZSTD_COMPRESSION_LEVEL).unwrap();
let mut tar_builder = tar::Builder::new(zstd_enc);

let content = b"not a real protobuf";
Expand Down Expand Up @@ -709,7 +711,8 @@ mod tests {

{
let tar_file = std::fs::File::create(&tarball_path).unwrap();
let zstd_enc = zstd::Encoder::new(tar_file, 15).unwrap();
let zstd_enc =
zstd::Encoder::new(tar_file, BundlerUtil::ZSTD_COMPRESSION_LEVEL).unwrap();
let tar_builder = tar::Builder::new(zstd_enc);
tar_builder.into_inner().unwrap().finish().unwrap();
}
Expand Down
8 changes: 4 additions & 4 deletions cli/src/test_command.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use std::{
env,
process::{Command, Stdio},
sync::{mpsc::Sender, Arc},
sync::{Arc, mpsc::Sender},
time::SystemTime,
};

use clap::Args;
use constants::EXIT_FAILURE;
use display::{
end_output::EndOutput,
message::{send_message, DisplayMessage},
message::{DisplayMessage, send_message},
};
use superconsole::{
style::{Attribute, Stylize},
Line, Span,
style::{Attribute, Stylize},
};

use crate::{
context::{gather_debug_props, gather_initial_test_context},
upload_command::{run_upload, UploadArgs, UploadRunResult},
upload_command::{UploadArgs, UploadRunResult, run_upload},
};

enum RunOutput {
Expand Down
6 changes: 5 additions & 1 deletion codeowners/src/codeowners.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{

Check failure on line 1 in codeowners/src/codeowners.rs

View workflow job for this annotation

GitHub Actions / Trunk Check

rustfmt

Incorrect formatting, autoformat by running 'trunk fmt'
fs::File,
path::{Path, PathBuf},
sync::Arc,
Expand Down Expand Up @@ -317,7 +317,11 @@
U: AsRef<Path>,
{
let file = repo_root.as_ref().join(location).join(CODEOWNERS);
if file.is_file() { Some(file) } else { None }
if file.is_file() {
Some(file)
} else {
None
}
}

#[cfg(test)]
Expand Down
5 changes: 2 additions & 3 deletions codeowners/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
mod codeowners;

Check failure on line 1 in codeowners/src/lib.rs

View workflow job for this annotation

GitHub Actions / Trunk Check

rustfmt

Incorrect formatting, autoformat by running 'trunk fmt'
mod github;
mod gitlab;
mod traits;

pub use codeowners::{
BindingsOwners, BindingsOwnersAndId, BindingsOwnersAndSource, CodeOwners, CodeOwnersFile,
Owners, OwnersSource, associate_codeowners, associate_codeowners_multithreaded,
flatten_code_owners,
associate_codeowners, associate_codeowners_multithreaded, flatten_code_owners, BindingsOwners,
BindingsOwnersAndId, BindingsOwnersAndSource, CodeOwners, CodeOwnersFile, Owners, OwnersSource,
};
pub use github::{BindingsGitHubOwners, GitHubOwner, GitHubOwners};
pub use gitlab::{BindingsGitLabOwners, GitLabOwner, GitLabOwners};
Expand Down
202 changes: 125 additions & 77 deletions context/src/bazel_bep/binary_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io::Read;
use std::path::PathBuf;

use bazel_bep::types::build_event_stream::BuildEvent;
use prost::bytes::Buf;
use prost::Message;
use prost::bytes::Buf;

use crate::bazel_bep::common::BepParseResult;

Expand Down Expand Up @@ -61,82 +61,130 @@ mod tests {
let empty_errors_vec: Vec<String> = Vec::new();

pretty_assertions::assert_eq!(
parse_result.uncached_xml_files(),
vec![
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/37d45ccef587444393523741a3831f4a1acbeb010f74f33130ab9ba687477558/449"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:27:25.037Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:27:27.605Z").unwrap().into(),
label: Some("//trunk/hello_world/bazel_pnpm:test".into())
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/46bbeb038d6f1447f6224a7db4d8a109e133884f2ee6ee78487ca4ce7e073de8/507"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:29:32.732Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:29:32.853Z").unwrap().into(),
label: Some("//trunk/hello_world/cc:hello_test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/d1f48dadf5679f09ce9b9c8f4778281ab25bc1dfdddec943e1255baf468630de/451"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:32.180Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:34.697Z").unwrap().into(),
label: Some("//trunk/hello_world/ts_proto:test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/38f1d4ce43242ed3cb08aedf1cc0c3133a8aec8e8eee61f5b84b85a5ba718bc8/1204"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:31.748Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:34.797Z").unwrap().into(),
label: Some("//trunk/hello_world/ts_grpc:test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/ac23080b9bf5599b7781e3b62be9bf9a5b6685a8cbe76de4e9e1731a318e9283/607"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:33:01.680Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:33:01.806Z").unwrap().into(),
label: Some("//trunk/hello_world/cdk:lib_typecheck_test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/9c1db1d25ca6a4268be4a8982784c525a4b0ca99cbc7614094ad36c56bb08f2a/463"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:52.714Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:33:17.945Z").unwrap().into(),
label: Some("//trunk/hello_world/prisma/app:test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/7b3ed061a782496c7418be853caae863a9ada9618712f92346ea9e8169b8acf0/1120"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:16.934Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:19.361Z").unwrap().into(),
label: Some("//trunk/hello_world/cc_grpc:client_test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from("bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/45ca1eed26b3cf1aafdb51829e32312d3b48452cc144aa041c946e89fa9c6cf6/175"),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:16.929Z").unwrap().into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:19.383Z").unwrap().into(),
label: Some("//trunk/hello_world/cc_grpc:server_test".into()),
})
}
]
);
parse_result.uncached_xml_files(),
vec![
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/37d45ccef587444393523741a3831f4a1acbeb010f74f33130ab9ba687477558/449"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:27:25.037Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:27:27.605Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/bazel_pnpm:test".into())
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/46bbeb038d6f1447f6224a7db4d8a109e133884f2ee6ee78487ca4ce7e073de8/507"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:29:32.732Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:29:32.853Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/cc:hello_test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/d1f48dadf5679f09ce9b9c8f4778281ab25bc1dfdddec943e1255baf468630de/451"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:32.180Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:34.697Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/ts_proto:test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/38f1d4ce43242ed3cb08aedf1cc0c3133a8aec8e8eee61f5b84b85a5ba718bc8/1204"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:31.748Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:34.797Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/ts_grpc:test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/ac23080b9bf5599b7781e3b62be9bf9a5b6685a8cbe76de4e9e1731a318e9283/607"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:33:01.680Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:33:01.806Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/cdk:lib_typecheck_test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/9c1db1d25ca6a4268be4a8982784c525a4b0ca99cbc7614094ad36c56bb08f2a/463"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:32:52.714Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:33:17.945Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/prisma/app:test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/7b3ed061a782496c7418be853caae863a9ada9618712f92346ea9e8169b8acf0/1120"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:16.934Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:19.361Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/cc_grpc:client_test".into()),
})
},
JunitReportFileWithTestRunnerReport {
junit_path: String::from(
"bytestream://buildbarn2.build.trunk-staging.io:1986/blobs/45ca1eed26b3cf1aafdb51829e32312d3b48452cc144aa041c946e89fa9c6cf6/175"
),
test_runner_report: Some(TestRunnerReport {
status: TestRunnerReportStatus::Passed,
start_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:16.929Z")
.unwrap()
.into(),
end_time: DateTime::parse_from_rfc3339("2025-05-16T19:35:19.383Z")
.unwrap()
.into(),
label: Some("//trunk/hello_world/cc_grpc:server_test".into()),
})
}
]
);
assert_eq!(parse_result.xml_file_counts(), (8, 0));
pretty_assertions::assert_eq!(parse_result.errors, empty_errors_vec);
}
Expand Down
2 changes: 1 addition & 1 deletion context/src/env/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use thiserror::Error;
use wasm_bindgen::prelude::*;

use super::parser::{BranchClass, CIInfo};
use crate::string_safety::{validate_field_len, FieldLen};
use crate::string_safety::{FieldLen, validate_field_len};

pub const MAX_BRANCH_NAME_LEN: usize = 36;
pub const MAX_EMAIL_LEN: usize = 254;
Expand Down
2 changes: 1 addition & 1 deletion context/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use pyo3_stub_gen::derive::gen_stub_pyclass;
use wasm_bindgen::prelude::*;

use crate::{
env::parser::{clean_branch, BranchClass, CIInfo},
env::parser::{BranchClass, CIInfo, clean_branch},
repo::BundleRepo,
};

Expand Down
2 changes: 1 addition & 1 deletion context/src/meta/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use wasm_bindgen::prelude::*;

use super::MetaContext;
use crate::env::validator::{
validate as env_validate, EnvValidationIssue, EnvValidationIssueSubOptimal,
EnvValidationIssue, EnvValidationIssueSubOptimal, validate as env_validate,
};

#[cfg_attr(feature = "pyo3", gen_stub_pyclass_enum, pyclass(eq, eq_int))]
Expand Down
2 changes: 1 addition & 1 deletion context/src/repo/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use thiserror::Error;
use wasm_bindgen::prelude::*;

use super::BundleRepo;
use crate::string_safety::{validate_field_len, FieldLen};
use crate::string_safety::{FieldLen, validate_field_len};

pub const MAX_BRANCH_NAME_LEN: usize = 36;
pub const MAX_EMAIL_LEN: usize = 254;
Expand Down
Loading
Loading