Go to file
Landon James 9af72f5f2a
Add customization to ensure S3 `Expires` field is always a `DateTime` (#3730)
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
At some point in the near future (after this customization is applied to
all existing SDKs) the S3 model will change the type of `Expires`
members to `String` from the current `Timestamp`. This change would
break backwards compatibility for us.

## Description
<!--- Describe your changes in detail -->
Add customization to ensure S3 `Expires` field is always a `Timestamp`
and ass a new synthetic member `ExpiresString` that persists the
un-parsed data from the `Expires` header.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Added tests to ensure that the model is pre-processed correctly. Added
integration tests for S3. Considered making this more generic codegen
tests, but since this customization will almost certainly only ever
apply to S3 and I wanted to ensure that it was properly applied to the
generated S3 SDK I opted for this route.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [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._
2024-07-01 18:48:05 +00:00
.cargo Remove sparse registry config (#2990) 2023-09-19 13:50:11 +00:00
.github chore(ci): Only dry run a release, and only publish github pages, when ci workflow is triggered from main smithy-rs repository (#3663) 2024-05-24 16:51:47 +00:00
.pre-commit-hooks Run runtime crate version audit as part of pre-commit (#3450) 2024-02-28 22:10:02 +00:00
aws Add customization to ensure S3 `Expires` field is always a `DateTime` (#3730) 2024-07-01 18:48:05 +00:00
buildSrc Do not set `RUSTFLAGS` environment variable when invoking Cargo commands via Gradle tasks (#3678) 2024-06-21 14:26:22 +00:00
codegen-client Improve broken protocol test generation (#3726) 2024-07-01 09:23:16 +00:00
codegen-client-test Do not set `RUSTFLAGS` environment variable when invoking Cargo commands via Gradle tasks (#3678) 2024-06-21 14:26:22 +00:00
codegen-core Add customization to ensure S3 `Expires` field is always a `DateTime` (#3730) 2024-07-01 18:48:05 +00:00
codegen-server Improve broken protocol test generation (#3726) 2024-07-01 09:23:16 +00:00
codegen-server-test Allow expected content-type to ignore parameters (#3724) 2024-06-28 15:25:23 +00:00
design behavior version 2024-03-28 (#3617) 2024-05-02 12:47:07 +00:00
examples Fix broken link on example's smithy model (#3725) 2024-07-01 16:02:52 +00:00
gradle/wrapper Upgrade to Gradle 8.3 (#2984) 2023-09-14 19:34:55 +00:00
rust-runtime Allow expected content-type to ignore parameters (#3724) 2024-06-28 15:25:23 +00:00
tools Update canary build tool (#3701) 2024-06-19 16:36:57 +00:00
.cargo-deny-config.toml Pin `httparse` to =1.8 to avoid unit test failures in runtime crates (#3687) 2024-06-10 18:49:53 +00:00
.editorconfig Upgrade Kotlin to 1.9.20 and Ktlint to 1.0.1 (#3320) 2023-12-14 12:35:18 -08:00
.git-blame-ignore-revs Create initial `.git-blame-ignore-revs` (#1726) 2022-09-09 14:09:06 -07:00
.gitignore add Sigv4A support (#2939) 2023-09-28 17:50:33 +00:00
.pre-commit-config.yaml Run runtime crate version audit as part of pre-commit (#3450) 2024-02-28 22:10:02 +00:00
CHANGELOG.md Update changelog 2024-06-19 18:35:26 +00:00
CHANGELOG.next.toml Add customization to ensure S3 `Expires` field is always a `DateTime` (#3730) 2024-07-01 18:48:05 +00:00
CODEOWNERS Fix repo org move issues (#3166) 2023-11-10 18:51:04 +00:00
CODE_OF_CONDUCT.md Initial commit 2020-10-28 06:37:45 -07:00
CONTRIBUTING.md Add a new step description under `Contributing via Pull Requests` (#3582) 2024-04-17 15:37:12 +00:00
LICENSE Initial commit 2020-10-28 06:37:45 -07:00
NOTICE Initial commit 2020-10-28 06:37:45 -07:00
README.md Renaming gradle task `:aws:sdk:test` to `sdkTest` avoid task name collision (#3650) 2024-05-20 21:51:24 +00:00
build.gradle.kts Allow 'null' variants in unions (#3481) 2024-03-15 22:36:42 +00:00
ci Upgrade CI to use docker-compose v2 (#3543) 2024-04-02 16:12:02 +00:00
ci.mk TLS tests in CI (#2886) 2023-08-09 14:21:55 +00:00
clippy-root.toml Add clippy.toml with forbidden methods & fix SystemTime usages (#2882) 2023-07-28 17:16:44 +00:00
gradle.properties Do not set `RUSTFLAGS` environment variable when invoking Cargo commands via Gradle tasks (#3678) 2024-06-21 14:26:22 +00:00
gradlew Upgrade to Gradle 8.3 (#2984) 2023-09-14 19:34:55 +00:00
gradlew.bat Upgrade to Gradle 8.3 (#2984) 2023-09-14 19:34:55 +00:00
rust-toolchain.toml Bumping MSRV to 1.76.0 2024-05-20 11:58:10 -07:00
settings.gradle.kts Upgrade Smithy Gradle Plugin to 0.9 (#3394) 2024-02-07 22:18:49 +00:00

README.md

Smithy Rust CI on Branch main

Smithy code generators for Rust that generate clients, servers, and the entire AWS SDK. The latest unreleased SDK build can be found in aws-sdk-rust/next.

Design documentation

All internal and external interfaces are considered unstable and subject to change without notice.

Setup

  1. ./gradlew will setup gradle for you. JDK 17 is required.
  2. Running tests requires a working Rust installation. See Rust docs for installation instructions on your platform. The MSRV (Minimum Supported Rust Version) for the crates in this project is stable-2, i.e. the current stable Rust version and the prior two versions. Older versions may work.

Development

For development, pre-commit hooks make it easier to pass automated linting when opening a pull request. Setup:

brew install pre-commit # (or appropriate for your platform: https://pre-commit.com/)
pre-commit install

Project Layout

  • aws: AWS specific codegen & Rust code (signing, endpoints, customizations, etc.) Common commands:
    • ./gradlew :aws:sdk:assemble: Generate (but do not test / compile etc.) a fresh SDK into sdk/build/aws-sdk
    • ./gradlew :aws:sdk:sdkTest: Generate & run all tests for a fresh SDK. (Note that these tests require Go to be installed for FIP support to compile properly)
    • ./gradlew :aws:sdk:{cargoCheck, cargoTest, cargoDocs, cargoClippy}: Generate & run specified cargo command.
  • codegen-core: Common code generation logic useful for clients and servers
  • codegen-client: Whitelabel Smithy client code generation
  • codegen-client-test: Smithy protocol test generation & integration tests for Smithy client whitelabel code
  • design: Design documentation. See the design/README.md for details about building / viewing.
  • codegen-server: Whitelabel Smithy server code generation
  • codegen-server-test: Smithy protocol test generation & integration tests for Smithy server whitelabel code
  • examples: A collection of server implementation examples

Testing

Running all of smithy-rs's tests can take a very long time, so it's better to know which parts to test based on the changes being made, and allow continuous integration to find other issues when posting a pull request.

In general, the components of smithy-rs affect each other in the following order (with earlier affecting later):

  1. rust-runtime
  2. codegen and codegen-server
  3. aws/rust-runtime
  4. aws/sdk-codegen

Some components, such as codegen-client-test and codegen-server-test, are purely for testing other components.

Testing rust-runtime and aws/rust-runtime

To test the rust-runtime crates:

# Run all Rust tests for `rust-runtime/` (from repo root):
cargo test --manifest-path=rust-runtime/Cargo.toml
# Run clippy for `rust-runtime/` (from repo root):
cargo clippy --manifest-path=rust-runtime/Cargo.toml

# Or
cd rust-runtime
cargo test
cargo clippy

To test the aws/rust-runtime crates:

# Run all Rust tests for `aws/rust-runtime/` (from repo root):
cargo test --manifest-path=aws/rust-runtime/Cargo.toml
# Run clippy for `aws/rust-runtime/` (from repo root):
cargo clippy --manifest-path=aws/rust-runtime/Cargo.toml

# Or
cd aws/rust-runtime
cargo test
cargo clippy

Some runtime crates have a additional-ci script that can also be run. These scripts often require cargo-hack and cargo-udeps to be installed.

Testing Client/Server Codegen

To test the code generation, the following can be used:

# Run Kotlin codegen unit tests
./gradlew codegen-core:check
./gradlew codegen-client:check
./gradlew codegen-server:check
# Run client codegen tests
./gradlew codegen-client-test:check
# Run server codegen tests
./gradlew codegen-server-test:check

Several Kotlin unit tests generate Rust projects and compile them. When these fail, they typically output links to the location of the generated code so that it can be inspected.

To look at generated code when the codegen tests fail, check these paths depending on the test suite that's failing:

  • For codegen-client-test: codegen-client-test/build/smithyprojections/codegen-client-test
  • For codegen-server-test: codegen-server-test/build/smithyprojections/codegen-server-test

Testing SDK Codegen

See the readme in aws/sdk/ for more information about these targets as they can be configured to generate more or less AWS service clients.

# Run Kotlin codegen unit tests
./gradlew aws:sdk-codegen:check
# Generate an SDK, but do not attempt to compile / run tests. Useful for inspecting generated code
./gradlew :aws:sdk:assemble
# Run all the tests
./gradlew :aws:sdk:sdkTest
# Validate that the generated code compiles
./gradlew :aws:sdk:cargoCheck
# Validate that the generated code passes Clippy
./gradlew :aws:sdk:cargoClippy
# Validate the generated docs
./gradlew :aws:sdk:cargoDoc

The generated SDK will be placed in aws/sdk/build/aws-sdk.