diff --git a/bundle/src/bundle_meta.rs b/bundle/src/bundle_meta.rs index 9c6f87a1..bf2c20b7 100644 --- a/bundle/src/bundle_meta.rs +++ b/bundle/src/bundle_meta.rs @@ -33,6 +33,7 @@ pub struct BundleMetaBaseProps { pub version: String, pub cli_version: String, pub org: String, + pub test_collection_short_id: Option, pub repo: BundleRepo, pub bundle_upload_id: String, pub tags: Vec, diff --git a/bundle/src/bundler.rs b/bundle/src/bundler.rs index 6c3d4232..a407a2f8 100644 --- a/bundle/src/bundler.rs +++ b/bundle/src/bundler.rs @@ -399,6 +399,7 @@ mod tests { base_props: BundleMetaBaseProps { version: META_VERSION.to_string(), org: "org".to_string(), + test_collection_short_id: None, repo: repo.clone(), cli_version: "0.0.1".to_string(), bundle_upload_id: "00".to_string(), diff --git a/cli/src/context.rs b/cli/src/context.rs index 7f5eda02..3a2ac781 100644 --- a/cli/src/context.rs +++ b/cli/src/context.rs @@ -118,6 +118,7 @@ pub fn gather_initial_test_context( bazel_bep_path, test_reports, org_url_slug, + test_collection_short_id, repo_root, repo_url, repo_head_sha, @@ -167,6 +168,7 @@ pub fn gather_initial_test_context( base_props: BundleMetaBaseProps { version: META_VERSION.to_string(), org: org_url_slug, + test_collection_short_id, repo, cli_version: format!( "cargo={} git={} rustc={}", @@ -302,7 +304,6 @@ fn create_test_result( ) -> TestResult { TestResult { test_case_runs, - // trunk-ignore(clippy/deprecated) uploader_metadata: Some(UploaderMetadata { variant: variant.unwrap_or_default(), ..Default::default() diff --git a/cli/src/upload_command.rs b/cli/src/upload_command.rs index 6ee2ca60..41b2805b 100644 --- a/cli/src/upload_command.rs +++ b/cli/src/upload_command.rs @@ -71,6 +71,14 @@ pub struct UploadArgs { pub test_reports: Vec, #[arg(long, env = constants::TRUNK_ORG_URL_SLUG_ENV, help = "Organization url slug.")] pub org_url_slug: String, + #[arg( + long, + env = constants::TRUNK_TEST_COLLECTION_SHORT_ID_ENV, + help = "Optional test collection short ID to attach to the uploaded bundle for collection-aware ingestion.", + required = false, + num_args = 1 + )] + pub test_collection_short_id: Option, #[arg( long, required = true, @@ -488,7 +496,6 @@ pub async fn run_upload( .quarantine_results .clone(); - // trunk-ignore(clippy/assigning_clones) meta.failed_tests = quarantine_context.failures.clone(); let upload_started_at = chrono::Utc::now(); diff --git a/constants/src/lib.rs b/constants/src/lib.rs index d25c7d04..ddd7c0a7 100644 --- a/constants/src/lib.rs +++ b/constants/src/lib.rs @@ -27,6 +27,7 @@ pub const TRUNK_API_CLIENT_RETRY_COUNT_ENV: &str = "TRUNK_API_CLIENT_RETRY_COUNT // Trunk CLI environment variable names for configuration overrides pub const TRUNK_API_TOKEN_ENV: &str = "TRUNK_API_TOKEN"; pub const TRUNK_ORG_URL_SLUG_ENV: &str = "TRUNK_ORG_URL_SLUG"; +pub const TRUNK_TEST_COLLECTION_SHORT_ID_ENV: &str = "TRUNK_TEST_COLLECTION_SHORT_ID"; pub const TRUNK_REPO_ROOT_ENV: &str = "TRUNK_REPO_ROOT"; pub const TRUNK_REPO_URL_ENV: &str = "TRUNK_REPO_URL"; pub const TRUNK_REPO_HEAD_SHA_ENV: &str = "TRUNK_REPO_HEAD_SHA"; diff --git a/context-js/tests/parse_compressed_bundle.test.ts b/context-js/tests/parse_compressed_bundle.test.ts index 3e90c61a..310e8dec 100644 --- a/context-js/tests/parse_compressed_bundle.test.ts +++ b/context-js/tests/parse_compressed_bundle.test.ts @@ -127,6 +127,7 @@ const generateBundleMeta = (): TestBundleMeta => ({ use_uncloned_repo: null, upload_time_epoch: faker.number.int(), tags: [], + test_collection_short_id: null, test_command: faker.hacker.verb(), }); @@ -287,9 +288,9 @@ describe("context-js", () => { includeInternalBin: RUBY_INTERNAL_BIN, }); - await expect( - async () => await parse_meta_from_tarball(readableStream), - ).rejects.toThrow("missing field `version`"); + await expect(parse_meta_from_tarball(readableStream)).rejects.toThrowError( + "missing field `version`", + ); }); it("decompresses and parses internal.bin", async () => { @@ -410,7 +411,7 @@ describe("context-js", () => { await expect( parse_internal_bin_and_meta_from_tarball(readableStream), - ).rejects.toThrow("No internal.bin file found in the tarball"); + ).rejects.toThrowError("No internal.bin file found in the tarball"); }); it("correctly gets and sets variant", async () => { diff --git a/context-py/tests/test_parse_meta.py b/context-py/tests/test_parse_meta.py index 08271758..c8771691 100644 --- a/context-py/tests/test_parse_meta.py +++ b/context-py/tests/test_parse_meta.py @@ -293,6 +293,7 @@ def test_parse_and_dump_meta_roundtrip(): }, "schema": "V0_5_29", "tags": [], + "test_collection_short_id": None, "test_command": None, "upload_time_epoch": 1721095230, "use_uncloned_repo": None,