-
Notifications
You must be signed in to change notification settings - Fork 247
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
Implement initial tool for publishing to crates.io #251
Conversation
tools/publisher/src/main.rs
Outdated
pub const REPO_NAME: &'static str = "aws-sdk-rust"; | ||
pub const REPO_CRATE_PATH: &'static str = "sdk"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noting the static lifetime is no longer required by the compiler, &str
is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's going to take me a long time to break that habit 😅
use tracing::info; | ||
|
||
const BACKOFF: Duration = Duration::from_millis(30); | ||
const MAX_CONCURRENCY: usize = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking that up, that's good to know. I think I'm going to cap this at the number of physical CPUs since cargo publish
seems to actually invoke rustc
.
info!("Discovering crates to publish..."); | ||
let repo = discover_repository(REPO_NAME, REPO_CRATE_PATH)?; | ||
let batches = discover_package_batches(Fs::Real, &repo.crates_root).await?; | ||
info!("Crates discovered."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be cool if this could print the number of runtime crates and number of sdk crates just as a sanity check helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea! Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! a really impressive piece of work, excited to see it in action!
#[derive(Default)] | ||
pub struct Cmd { | ||
parts: Vec<String>, | ||
working_dir: Option<PathBuf>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow...is there no library that does this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started off using async-process, but it was more complicated than I wanted to access stdout/stderr with that.
} | ||
|
||
/// Runs the command asynchronously. | ||
pub async fn spawn(mut self) -> Result<Output> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to do this async? Seems like we may want to block on these commands running
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see, we use a semaphore later. 👍🏻
tools/publisher/src/package.rs
Outdated
|
||
/// Validates that all of the publishable crates use consistent version numbers | ||
/// across all of their local dependencies. | ||
fn validate_packages(packages: &Vec<Package>) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clippy won't let you do this, &[Package]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I should run clippy on this... and also add it to CI 😄
tools/publisher/src/repo.rs
Outdated
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
//! Repository discovery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add the word "git" here and mention that it's on the local file system? wasn't clear to me what kind of repository this was talking about
enum Error { | ||
#[error("dependency cycle detected")] | ||
DependencyCycle, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, this should be impossible because cargo won't allow it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is an initial implementation of a tool to publish the SDK to crates.io. It has two subcommands:
fix-manifests
: This is to be run after importing the latest generated code from smithy-rs. It will add versions to all path dependencies for all crates.publish
: This will be run when ready to actually publish to crates.io. It figures out the correct order to publish the crates in, chunks them into batches, and runs them with some throttled concurrency. It currently doesn't retry on failure, but this can be added later.I tested everything works correctly except for the final publish, which, can't be tested until we actually publish. Doing a dry-run publish succeeds for the first few crates that don't have any path dependencies.
Sample output of the publish command:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.