Skip to content
Unverified Commit f2041a42 authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Specify tilde version requirements for runtime crates in manifest files (#3009)

## Motivation and Context
This PR converts version requirements for runtime crates (those under
`aws/rust-runtime` and those under `rust-runtime`) in manifest files
into tilde requirements, allowing customers to safely incorporate only
patch versions (from [The Cargo
Book](https://doc.rust-lang.org/nightly/cargo/reference/specifying-dependencies.html)).

## Description
Prior to the PR, if one opens the manifest file for an SDK create, a
version requirement for a runtime crate looks like
[this](https://github.com/awslabs/aws-sdk-rust/blob/655d490682e97ef799da85703520b5501fe91574/sdk/s3/Cargo.toml#L24-L27).
Post general availability (GA), those runtime crates will have versions
like `1.X.X` and if specified as such in a manifest file, it will be
interpreted as `>=1.X.X, <2.0.0`. To protect customers from minor
version bumps from runtime crates, we want to change their version
requirements to [tilde
requirements](https://doc.rust-lang.org/nightly/cargo/reference/specifying-dependencies.html#tilde-requirements)
`~1.X`, which then supports a version range `>=1.X.0, <1.X+1.0`.

Note that the change being discussed here is only concerned with version
requirements of runtime crates. There is a runtime crate that depends on
SDK crates (e.g. `aws-config` depending on `aws-sdk-sts`). In that case,
we do _not_ want to turn the version requirement of the SDK crate into a
tilde version because customers may depend on that SDK crate by
themselves, causing multiple versions of it to be brought in to their
crate graph.

To support the above functionality, `publisher` has been updated.
Specifically, when the `fix-manifests` subcommand runs, for runtime
crates it will render the tilde version requirements into manifest
files. Regarding a implementation detail, since the `semver::Version`
used in `publisher` requires three components, `major.minor.patch`, to
appear when version requirements are turned into in-memory data
structure, it does not quite work well with non-semver version
requirements. To address it, our own `crate::package::Version` has been
introduced to handle both semver and versions that do not adhere to the
semver specification. It then boils down to the `parse_version` function
being updated to be able to parse an input string into
`crate::package::Version`, as specified at call sites through a generic
parameter `P: ParseIntoVersion`.

## Testing
- Updated an existing unit test `test_validate_packages` in the
`package` module.
- Added a new unit test
`sdk_crate_version_should_not_be_turned_into_tilde_requirement` to the
`fix-manifests` subcommand.
- Ran our internal release pipeline and confirmed the generated SDK
crates have tilde dependencies for runtime crates in their manifest
files.

## Checklist
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent 398ad9e5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment