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

Include the client version in BundleUploads #101

Merged
merged 7 commits into from
Oct 8, 2024
Merged

Include the client version in BundleUploads #101

merged 7 commits into from
Oct 8, 2024

Conversation

matt-fff
Copy link
Contributor

@matt-fff matt-fff commented Sep 19, 2024

Summary:

Adding client version information for upload bundles will allow
us to help Flaky Test users who may be using outdated versions
of the Analytics CLI.

If a user is running into an old bug, we can direct them to update
their tooling version. Should help with onboarding.

Can't be merged until the corresponding API change (https://github.com/trunk-io/trunk/pull/16896) is in.

Closes TRUNK-12763

EDIT (10/8/24) - manually tested against prod, confirmed working https://api.trunk.io/metabase/question#eyJkYXRhc2V0X3F1ZXJ5Ijp7ImRhdGFiYXNlIjo1LCJ0eXBlIjoicXVlcnkiLCJxdWVyeSI6eyJzb3VyY2UtdGFibGUiOjE3ODgsImZpbHRlciI6WyJub3QtZW1wdHkiLFsiZmllbGQiLDg5MzIzLHsiYmFzZS10eXBlIjoidHlwZS9UZXh0In1dXX19LCJkaXNwbGF5IjoidGFibGUiLCJ2aXN1YWxpemF0aW9uX3NldHRpbmdzIjp7fX0=

Copy link
Member

@dfrankland dfrankland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work! ✨

cli/src/main.rs Outdated
Comment on lines 450 to 456
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why the Trunk Check runner isn't working, but it seems you need to run trunk check -y on this PR

Comment on lines 75 to 91
let request = requests_iter.next().unwrap();
if let RequestPayload::CreateBundleUpload(upload_request) = request {
assert_eq!(
upload_request.repo,
Repo {
host: String::from("github.com"),
owner: String::from("trunk-io"),
name: String::from("analytics-cli"),
},
org_url_slug: String::from("test-org"),
})
);
}
);
assert_eq!(upload_request.org_url_slug, String::from("test-org"));
assert!(upload_request.client_version.starts_with("trunk-analytics-cli cargo="));
assert!(upload_request.client_version.contains(" git="));
assert!(upload_request.client_version.contains(" rustc="));
} else {
panic!("Expected CreateBundleUpload request, got {:?}", request);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You can use the fancy assert_matches macro to do the failure for when the pattern isn't matched here

Suggested change
let request = requests_iter.next().unwrap();
if let RequestPayload::CreateBundleUpload(upload_request) = request {
assert_eq!(
upload_request.repo,
Repo {
host: String::from("github.com"),
owner: String::from("trunk-io"),
name: String::from("analytics-cli"),
},
org_url_slug: String::from("test-org"),
})
);
}
);
assert_eq!(upload_request.org_url_slug, String::from("test-org"));
assert!(upload_request.client_version.starts_with("trunk-analytics-cli cargo="));
assert!(upload_request.client_version.contains(" git="));
assert!(upload_request.client_version.contains(" rustc="));
} else {
panic!("Expected CreateBundleUpload request, got {:?}", request);
}
let upload_request =
assert_matches!(requests_iter.next().unwrap(), RequestPayload::CreateBundleUpload(ur) => ur);
assert_eq!(
upload_request.repo,
Repo {
host: String::from("github.com"),
owner: String::from("trunk-io"),
name: String::from("analytics-cli"),
}
);
assert_eq!(upload_request.org_url_slug, String::from("test-org"));
assert!(upload_request.client_version.starts_with("trunk-analytics-cli cargo="));
assert!(upload_request.client_version.contains(" git="));
assert!(upload_request.client_version.contains(" rustc="));

Copy link

trunk-staging-io bot commented Sep 20, 2024

354 tests were run on 62db3693. ✅ 354 Passed. View Full Report ↗︎

settings

Summary:

Adding client version information for upload bundles will allow
us to help Flaky Test users who may be using outdated versions
of the Analytics CLI.

If a user is running into an old bug, we can direct them to update
their tooling version. Should help with onboarding.

Closes TRUNK-12763
@max-trunk max-trunk requested a review from dfrankland October 8, 2024 16:09
Comment on lines 11 to 12
use test_utils::{
mock_git_repo::setup_repo_with_commit,
mock_server::{spawn_mock_server, RequestPayload},
};
use test_utils::mock_git_repo::setup_repo_with_commit;
use test_utils::mock_server::{spawn_mock_server, RequestPayload};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to split these up

);
assert_eq!(upload_request.org_url_slug, String::from("test-org"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional, nit: you shouldn't need String::from() here, the string literal is just fine

@max-trunk max-trunk merged commit 672e4c8 into main Oct 8, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants