Skip to content

Commit

Permalink
Don't generate a SDK for runtime-versioner patching (#3540)
Browse files Browse the repository at this point in the history
This PR removes the requirement of generating a SDK in order to patch
smithy-rs runtime crates into an already released SDK version for
testing. This is possible now that all the runtime crates are
independently versioned. The tool also takes multiple paths as input for
the runtime crate locations. This makes it possible to pass in the
`rust-runtime` and `aws/rust-runtime` directories from smithy-rs (done
by default by one of the subcommands).

Some of the publisher tool's package resolution code is moved into
smithy-rs-tool-common so it can be better shared across the tools, and
as part of this, the version in the package handle was made optional.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
jdisanti authored Apr 9, 2024
1 parent 7db0f73 commit 69efe3a
Show file tree
Hide file tree
Showing 19 changed files with 668 additions and 369 deletions.
149 changes: 146 additions & 3 deletions tools/ci-build/changelogger/Cargo.lock

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

13 changes: 12 additions & 1 deletion tools/ci-build/publisher/Cargo.lock

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

25 changes: 14 additions & 11 deletions tools/ci-build/publisher/src/cargo/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

use crate::package::PackageHandle;
use anyhow::Result;
use smithy_rs_tool_common::shell::{capture_error, output_text, ShellOperation};
use smithy_rs_tool_common::{
package::PackageHandle,
shell::{capture_error, output_text, ShellOperation},
};
use std::path::PathBuf;
use std::process::Command;
use tracing::info;
Expand All @@ -18,6 +20,10 @@ pub struct Publish {

impl Publish {
pub fn new(package_handle: PackageHandle, package_path: impl Into<PathBuf>) -> Publish {
assert!(
package_handle.version.is_some(),
"crate version number required; given {package_handle}"
);
Publish {
program: "cargo",
package_handle,
Expand All @@ -42,12 +48,12 @@ impl ShellOperation for Publish {
let (stdout, stderr) = output_text(&output);
let already_uploaded_msg = format!(
"error: crate version `{}` is already uploaded",
self.package_handle.version
self.package_handle.expect_version()
);
if stdout.contains(&already_uploaded_msg) || stderr.contains(&already_uploaded_msg) {
info!(
"{}-{} has already been published to crates.io.",
self.package_handle.name, self.package_handle.version
"{} has already been published to crates.io.",
self.package_handle
);
} else {
return Err(capture_error("cargo publish", &output));
Expand All @@ -69,7 +75,7 @@ mod tests {
program: "./fake_cargo/cargo_success",
package_handle: PackageHandle::new(
"aws-sdk-dynamodb",
Version::parse("0.0.22-alpha").unwrap(),
Version::parse("0.0.22-alpha").ok(),
),
package_path: env::current_dir().unwrap(),
}
Expand All @@ -82,10 +88,7 @@ mod tests {
async fn publish_fails() {
let result = Publish {
program: "./fake_cargo/cargo_fails",
package_handle: PackageHandle::new(
"something",
Version::parse("0.0.22-alpha").unwrap(),
),
package_handle: PackageHandle::new("something", Version::parse("0.0.22-alpha").ok()),
package_path: env::current_dir().unwrap(),
}
.spawn()
Expand All @@ -106,7 +109,7 @@ mod tests {
program: "./fake_cargo/cargo_publish_already_published",
package_handle: PackageHandle::new(
"aws-sdk-dynamodb",
Version::parse("0.0.22-alpha").unwrap(),
Version::parse("0.0.22-alpha").ok(),
),
package_path: env::current_dir().unwrap(),
}
Expand Down
Loading

0 comments on commit 69efe3a

Please sign in to comment.