Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions api/src/urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use url::{ParseError, Url, form_urlencoded};

pub fn url_for_test_case(
public_api_address: &str,
org_url_slug: &String,
org_url_slug: &str,
repo: &RepoUrlParts,
test_case: &Test,
) -> Result<String, ParseError> {
Expand All @@ -18,7 +18,7 @@ fn convert_to_app_url(public_api_address: &str) -> String {
public_api_address.replace("https://api.", "https://app.")
}

fn test_path(org_url_slug: &String, test_case: &Test) -> String {
fn test_path(org_url_slug: &str, test_case: &Test) -> String {
format!("{}/flaky-tests/test/{}", org_url_slug, test_case.id)
}

Expand Down Expand Up @@ -50,8 +50,8 @@ fn test_url_generated() {
};

let actual = url_for_test_case(
&String::from("https://api.trunk-staging.io"),
&String::from("bad-app-org"),
"https://api.trunk-staging.io",
"bad-app-org",
&repo,
&test,
);
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ sentry-tracing = "0.36.0"
openssl = { version = "0.10.78", features = ["vendored"] }
openssl-src = { version = "=300.3.1", optional = true }
quick-junit = "0.5.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
clap-verbosity-flag = "3.0.2"
proto = { path = "../proto" }
Expand Down
39 changes: 23 additions & 16 deletions cli/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use context::{
};
use github_actions::extract_github_external_id;
use lazy_static::lazy_static;
use prost::Message;
use proto::test_context::test_run::test_case_run::TestRunnerInformation;
use proto::test_context::test_run::{
BazelAttemptNumber, BazelBuildInformation, BazelRunInformation, TestBuildResult, TestReport,
Expand Down Expand Up @@ -325,10 +326,10 @@ fn write_test_report_to_file(
test_results: Vec<TestResult>,
variant: Option<String>,
temp_dir: &TempDir,
) -> anyhow::Result<BundledFile> {
) -> anyhow::Result<(BundledFile, TestReport)> {
let test_report = TestReport {
uploader_metadata: Some(UploaderMetadata {
variant: variant.unwrap_or_default(),
variant: variant.clone().unwrap_or_default(),
..Default::default()
}),
test_results,
Expand All @@ -339,14 +340,17 @@ fn write_test_report_to_file(
let test_report_path = temp_dir.path().join(INTERNAL_BIN_FILENAME);
std::fs::write(&test_report_path, buf)?;

Ok(BundledFile {
original_path: test_report_path.to_string_lossy().to_string(),
original_path_rel: None,
owners: vec![],
path: INTERNAL_BIN_FILENAME.to_string(),
// last_modified_epoch_ns does not serialize so the compiler complains it does not exist
..Default::default()
})
Ok((
BundledFile {
original_path: test_report_path.to_string_lossy().to_string(),
original_path_rel: None,
owners: vec![],
path: INTERNAL_BIN_FILENAME.to_string(),
// last_modified_epoch_ns does not serialize so the compiler complains it does not exist
..Default::default()
},
test_report,
))
}

struct BuildResultFromBep {
Expand Down Expand Up @@ -392,6 +396,7 @@ pub fn generate_internal_file_from_bep(
use_bazel_target_for_codeowners: bool,
) -> anyhow::Result<(
BundledFile,
TestReport,
BTreeMap<String, anyhow::Result<JunitReportValidation>>,
)> {
let mut junit_validations = BTreeMap::new();
Expand Down Expand Up @@ -498,9 +503,9 @@ pub fn generate_internal_file_from_bep(
));
}

let bundled_file = write_test_report_to_file(test_results, variant, temp_dir)?;
let (bundled_file, test_report) = write_test_report_to_file(test_results, variant, temp_dir)?;

Ok((bundled_file, junit_validations))
Ok((bundled_file, test_report, junit_validations))
}

pub fn generate_internal_file(
Expand All @@ -515,6 +520,7 @@ pub fn generate_internal_file(
use_bazel_target_for_codeowners: bool,
) -> anyhow::Result<(
BundledFile,
Option<TestReport>,
BTreeMap<String, anyhow::Result<JunitReportValidation>>,
)> {
let mut junit_validations = BTreeMap::new();
Expand All @@ -530,8 +536,9 @@ pub fn generate_internal_file(
"Internal file set contains more than one file"
));
}
// Internal file set, we should just use that directly and assume it's valid
return Ok((file_set.files[0].clone(), BTreeMap::new()));
// Internal file sets are pre-encoded proto files; pass through as-is.
let bundled_file = file_set.files[0].clone();
return Ok((bundled_file, None, BTreeMap::new()));
} else {
for file in &file_set.files {
if file.original_path.ends_with(".xml") {
Expand Down Expand Up @@ -574,9 +581,9 @@ pub fn generate_internal_file(
None, // No build information for non-BEP files
)];

let bundled_file = write_test_report_to_file(test_results, variant, temp_dir)?;
let (bundled_file, test_report) = write_test_report_to_file(test_results, variant, temp_dir)?;

Ok((bundled_file, junit_validations))
Ok((bundled_file, Some(test_report), junit_validations))
}

pub fn fall_back_to_binary_parse(
Expand Down
1 change: 1 addition & 0 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub mod context_quarantine;
pub mod error_report;
pub mod print;
mod report_limiting;
pub mod summary_output;
pub mod test_command;
pub mod upload_command;
pub mod validate_command;
Loading