-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update release tooling to handle both stable and unstable crates (#3082)
## Motivation and Context This PR updates our smithy-rs release tooling to prepare for handling both stable and unstable crates. Merging this PR to `main` does not make any of the runtime crates stable, instead we will just have a supporting mechanism in place, ready to be turned on by implementing `TODO(GA)`. ## Description At a high level, this PR will - update the `Release smithy-rs` workflow UI to have an additional input `Stable semantic version`: ![Screenshot 2023-10-24 at 10 19 07 PM](https://github.com/awslabs/smithy-rs/assets/15333866/097502e6-3193-43f6-b39b-dd231c2d14d7) - split an existing gradle property `smithy.rs.runtime.crate.version` into `smithy.rs.runtime.crate.stable.version` and `smithy.rs.runtime.crate.unstable.version`. - make `publisher upgrade-runtime-crates-version` take a new, optional (for backwards compatibility) command line argument `--stable-version` to use the said gradle property `smithy.rs.runtime.crate.stable.version`. This will allow the `publisher` to set a value passed via a workflow input `Stable semantic version` to `smithy.rs.runtime.crate.stable.version` in `gradle.properties` (and the same goes for unstable crates). - update `fixRuntimeCrateVersions` so that it fixes up runtime crate versions based on properties `smithy.rs.runtime.crate.stable.version` and `smithy.rs.runtime.crate.unstable.version`. **NOTE** There is a guard in place. When this PR gets merged and then we enter a stable crate version in the `Stable semantic version` text box, it will be overwritten by a version in `Unstable semantic version`, so that 1.x.y version will NOT be published to `crates.io` before GA and that also replicates today's release workflow's behavior (only publishing unstable crates). Just make sure we specify a 0.x.y in the `Untable semantic version` text box because that does get shipped. ### What happens once `TODO(GA)` has been implemented? Roughly, it will look like this. When we run the `Release smithy-rs` workflow (not a dry-run), providing a stable version (say 1.0.0) and a unstable version (say 0.57.0) in the workflow text boxes, 1. the workflow will create a new release branch `smithy-rs-release-1.x.y`. 2. the workflow will set 1.0.0 to `smithy.rs.runtime.crate.stable.version` and 0.57.0 to `smithy.rs.runtime.crate.unstable.version` in `gradle.properties`. 3. for whatever smithy runtime crates whose package metadata says ``` [package.metadata.smithy-rs-release-tooling] stable = true ``` their `Cargo.toml` will include `version = 1.0.0` (and `version = 0.57.0` if `smithy-rs-release-tooling` is not specified or if its value is `stable = false`). 4. the workflow will publish smithy runtime crates accordingly to `crates.io`. 5. releasing `aws-sdk-rust` subsequently will render `version = 1.0.0` in `Cargo.toml` for stable AWS runtime crates (again as specified by `smithy-rs-release-tooling`), will render `version = 1.1.0` for SDK crates (we will not go into details here as to why it's not `1.0.0`), and will publish those crates to `crates.io`. ## Testing In a [separate branch](https://github.com/awslabs/smithy-rs/tree/ysaito/stable-and-unstable-crates) that implemented `TODO(GA)`, I verified that - our internal release pipeline was executed without errors - a generated AWS SDK had following manifests (showing excerpts from arbitrary crates) ``` [package] name = "aws-sdk-s3" version = "1.1.0" ``` ``` [package] name = "aws-smithy-types" version = "1.0.0" ``` ``` [package] name = "aws-smithy-http" version = "0.57.0" ``` ``` [package] name = "aws-types" version = "1.0.0" ``` ``` [package] name = "aws-config" version = "1.0.0" ``` ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: John DiSanti <[email protected]>
- Loading branch information
1 parent
a42c818
commit 64857d9
Showing
25 changed files
with
445 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import CrateSet.AWS_SDK_RUNTIME | ||
import CrateSet.SERVER_SMITHY_RUNTIME | ||
import CrateSet.SMITHY_RUNTIME_COMMON | ||
import CrateSet.STABLE_VERSION_PROP_NAME | ||
import CrateSet.UNSTABLE_VERSION_PROP_NAME | ||
import com.moandjiezana.toml.Toml | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
import java.util.logging.Logger | ||
|
||
class CrateSetTest { | ||
private val logger: Logger = Logger.getLogger("CrateSetTest") | ||
|
||
/* | ||
* Checks whether `versionPropertyName` for a system under test, i.e. `Crate` in `CrateSet.kt`, | ||
* matches what `package.metadata.smithy-rs-release-tooling` says in the `Cargo.toml` | ||
* for the corresponding crate. | ||
*/ | ||
private fun sutStabilityMatchesManifestStability(versionPropertyName: String, stabilityInManifest: Boolean) { | ||
when (stabilityInManifest) { | ||
true -> assertEquals(STABLE_VERSION_PROP_NAME, versionPropertyName) | ||
false -> assertEquals(UNSTABLE_VERSION_PROP_NAME, versionPropertyName) | ||
} | ||
} | ||
|
||
/* | ||
* Checks whether each element in `crateSet` specifies the correct `versionPropertyName` according to | ||
* what `package.metadata.smithy-rs-release-tooling` says in the `Cargo.toml` for the corresponding crate, | ||
* located at `relativePathToRustRuntime`. | ||
* | ||
* If `package.metadata.smithy-rs-release-tooling` does not exist in a `Cargo.toml`, the implementation | ||
* will treat that crate as unstable. | ||
*/ | ||
private fun crateSetStabilitiesMatchManifestStabilities(crateSet: List<Crate>, relativePathToRustRuntime: String) { | ||
crateSet.forEach { | ||
val path = "$relativePathToRustRuntime/${it.name}/Cargo.toml" | ||
val contents = File(path).readText() | ||
val manifest = try { | ||
Toml().read(contents) | ||
} catch (e: java.lang.IllegalStateException) { | ||
// Currently, `aws-sigv4` cannot be read as a `TOML` because of the following error: | ||
// Invalid table definition on line 54: [target.'cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))'.dev-dependencies]] | ||
logger.info("failed to read ${it.name} as TOML: $e") | ||
Toml() | ||
} | ||
manifest.getTable("package.metadata.smithy-rs-release-tooling")?.entrySet()?.map { entry -> | ||
sutStabilityMatchesManifestStability(it.versionPropertyName, entry.value as Boolean) | ||
} ?: sutStabilityMatchesManifestStability(it.versionPropertyName, false) | ||
} | ||
} | ||
|
||
@Test | ||
fun `aws runtime stabilities should match those in manifest files`() { | ||
crateSetStabilitiesMatchManifestStabilities(AWS_SDK_RUNTIME, "../aws/rust-runtime") | ||
} | ||
|
||
@Test | ||
fun `common smithy runtime stabilities should match those in manifest files`() { | ||
crateSetStabilitiesMatchManifestStabilities(SMITHY_RUNTIME_COMMON, "../rust-runtime") | ||
} | ||
|
||
@Test | ||
fun `server smithy runtime stabilities should match those in manifest files`() { | ||
crateSetStabilitiesMatchManifestStabilities(SERVER_SMITHY_RUNTIME, "../rust-runtime") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.