Commit Graph

1143 Commits

Author SHA1 Message Date
John DiSanti 52c1174ac3
Decouple `aws-sdk-rust` release from `smithy-rs` release (#1495)
* Remove smoketest/fullsdk model classifications
* Generate full SDK for CI using models in aws-sdk-rust
* Move the changelog renderer out of `sdk-lints` and add changelog splitter
* Save revision information into split off SDK changelog
* Replace common git impl with `sdk-sync`'s impl
* Filter SDK changelog entries on changelog render
* Add smithy-rs release workflow
* Add initial next SDK changelog
* Update `sdk-sync` to understand new models location
2022-06-27 19:16:48 +00:00
david-perez ae2a74b598
Non-functional miscellaneous improvements (#1445)
This commit contains non-functional (i.e. mostly stylistic, small
refactors, documentation and consistency) improvements that I've batched
and rolled up while working on #1342.

* Make `extraDependencies` from `InlineDependency` class private
* Miscellaneous improvements to `RustTypes.kt`
* Remove dead code from `RuntimeTypes.kt`
* Style change in `RuntimeTypes.kt`
* Miscellaneous improvements to `SymbolVisitor.kt`
* Miscellaneous improvements to `BuilderGenerator.kt`
    - Make it consistent with the `ServerBuilderGenerator` from #1342.
* Miscellaneous improvements to `TestHelpers.kt`
* Add docs to `headers_for_prefix` function
    - I keep rereading the implementation to see what this returns; it's
      not intuitive from the function name.
2022-06-27 18:19:19 +02:00
david-perez a89a0832d1
Rewrite `ServerOperationRegistryGenerator` (#1491)
This code was written a long time ago, and made heavy use of string
interpolation instead of the more robust Rust templating primitives from
`RustWriter.kt`.
2022-06-24 16:12:47 +02:00
Russell Cohen b88d72e237
Add a trailing slash to iam/security-credentials/ when querying IMDS (#1487) 2022-06-23 20:09:54 +00:00
John DiSanti 6bc8154fae
Change `sdk-sync` failure to warning to help release decoupling (#1494) 2022-06-23 10:44:08 -07:00
Russell Cohen edb1394561
Upgrade to Gradle 7 (#1411)
* Upgrade to Gradle 7

* Document the upgrade and update changelogs
2022-06-23 12:27:43 -04:00
AWS SDK Rust Bot 5b49350037 Update changelogs 2022-06-22 21:20:42 +00:00
Russell Cohen bf25694ccd
Release 6/22 (#1486)
* Update models

* Update versions
2022-06-22 20:15:35 +00:00
david-perez 9f470718f7
Fix server routing matching URIs with prefixes (#1484)
We are incorrectly matching URIs to the spec when the URI has a prefix
that is not in the spec.

This is because when generating the regex describing the spec, we're not
using the `^` anchor to match from the beginning of the text.

Fixes #1483.
2022-06-22 14:06:19 +02:00
david-perez 5d6d8843cd
Split `CodegenContext` and children (#1473)
This commit splits each of:

* `CodegenContext`,
* `RustSettings`; and
* `CodegenConfig`

into two variants: one for the `rust-codegen` client plugin and another
for the `rust-server-codegen` plugin.

(`CodegenConfig` is a property of `RustSettings`, which is a property of
`CodegenContext`; they constitute pervasive read-only global data that
gets passed around to the code generators).

This allows each plugin to evolve separately, defining different
settings and passing around a tailor-made code-generation context.

Client-specific generators should now use:

* `ClientCodegenContext`,
* `ClientRustSettings`; and
* `ClientCodegenConfig`.

Likewise, server-specific generators should now use:

* `ServerCodegenContext`,
* `ServerRustSettings`; and
* `ServerCodegenConfig`.

This is a more robust and maintainable approach than the current one,
where both generator types have to read possibly null values (because
they don't make sense for a client/server target), and plugins have to
populate settings that are not relevant for the crate they're
generating. For example, the server plugin has to populate and pass
around the settings `renameExceptions`, `includeFluentClient` and
`addMessageToErrors` even though it never uses them and don't make sense
for it.

As of writing these client and server specific classes are very similar,
but in the future they will evolve in separate ways (for example, #1342
will add symbol providers for constrained shapes that only make sense in
a server code-generation context).

Common properties have not been duplicated however. Instead, utilizing
inheritance, code-generation context that is common to _all_ plugins can
be placed in:

* `CoreCodegenContext`,
* `CoreRustSettings`; and
* `CoreCodegenConfig`.

This way, generators that are shared by both client and server can take
in `CoreCodegenContext`. If they need to tweak the code they generate in
small and self-contained places, they can utilize the `CodegenTarget`
flag-like enum to disambiguate, like they have always been doing.

Note this change also makes `RustDecorator`s be targeted for clients or
servers, by making them generic over the code-generation context. When
loading the decorators from the classpath and combining them into one in
the executed smithy-rs plugin, all of them need to either target clients
or target servers. This makes sense: after all, all of the decorators
that conform the AWS Rust SDK are client-specific.

Closes #828.
2022-06-21 19:12:31 +00:00
Russell Cohen 1446681c0a
Add support for retrying individual call timeouts (#1478)
When timeout support was added initially, the resulting error `SdkError::TimeoutError` was never added to the retry policy which prevented these errors from being retried. This was a bug—This commit rectifies the and adds two integration-level tests that ensure that timeouts are properly retried.
2022-06-21 17:37:04 +00:00
Fahad Zubair a3c7902d7c
Refactor: Attribute.class used instead of helper methods in PythonSer… (#1475)
* Refactor: Attribute.class used instead of helper methods in PythonServerAttributeUtils

Helper methods in PythonServerAttributeUtils have been deprecated in favor of using Attribute.class directly

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>

* Smithy Python: PyException removed from enum

Smithy enums do not have ErrorTrait so there is no need to check and generate code for pyo3::exceptions::PyException

Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-06-21 17:17:21 +01:00
david-perez a91b813e43
Fix `modifyMtime` task when `generateSmithyBuild` task is up to date (#1471)
When `generateSmithyBuild` task is up to date, the hashes of the build
are not calculated, so `modifyMtime` fails, because it expects them to
be registered in Gradle's project properties. This can happen if you run
a command like `./gradlew codegen-server-test:test` twice consecutively.

In this case, we should skip the `modifyMtime` task altogether.
Everything is up to date, so no codegen will run, and no artifacts will
change.
2022-06-17 16:12:56 +00:00
david-perez 5af3b106a0
Remove `#[doc(hidden)]` from `aws_smithy_http_server::body::BoxBody` (#1453)
And from the `boxed` body function.

These are necessary if users need to implement middleware
(`tower::Layer`s) that use the request's body.
2022-06-17 13:44:58 +00:00
Zelda Hessler 2f2db5a637
rename: hosted_zone_preprocessor.rs to route53_resource_id_preprocess… (#1472)
* rename: hosted_zone_preprocessor.rs to route53_resource_id_preprocessor.rs
update: trim_hosted_zone to work for more resource ids
add: new Route53 protocol test for GetChange resource id trimming
update: InlineDependency.forRustFile to accept filenames with a ".rs" extension
add: CHANGELOG.next.toml entry
2022-06-16 14:37:01 -05:00
david-perez 40f22207ad
Avoid unnecessary Cargo crate rebuilds (#1422)
Avoid unnecessary Cargo crate rebuilds

This commit modifies the Gradle buildscripts to avoid unnecessary Cargo
rebuilds of the generated crates, decreasing development iteration
cycles.

Prior to this commit, if you ran a crate-generating command _twice_ on
any of the `codegen-test`, `codegen-server-test`, `sdk-codegen-test`,
and `codegen-server-test:python` subprojects (without making any changes
to the codegen code), both invocations would take the same time: Cargo
would recompile the crate and its dependencies, even when the generated
crate is identical. This is because Gradle deletes everything under
`buildDir` when running the `generateSmithyBuild` task:

```
> Task :codegen-server-test:smithyBuildJar
Deleting stale output file: /local/home/davidpz/workplace/smithy-ws/src/SmithyRsSource/codegen-server-test/build/smithyprojections/codegen-server-test
```

So the files get recreated each time.

While developing, it is likely that only a small number of the generated
crate files are modified across rebuilds. [Cargo uses
`mtime`](https://github.com/rust-lang/cargo/issues/6529) (among other
factors) to determine whether it needs to recompile a unit. Indeed,
running with `CARGO_LOG=cargo::core::compiler::fingerprint=trace` yields
`err: current filesystem status shows we're outdated`. This commit adds
a Gradle task that compares the hashes of the newly generated files with
the (previously cached) old ones, and restores their `mtime`s if the
hashes coincide.

Another issue was causing unnecessary crate rebuilds. Prior to this
commit, we were sending `RUSTFLAGS=-D warnings` when invoking Cargo.
However, a common thing to do after generating a crate is to open its
contents in an editor. The editor's `rust-analyzer` would compile the
crate and its dependencies without the `RUSTFLAGS` we had used earlier.
The next time you rebuilt the crate, Cargo would claim `err: RUSTFLAGS
has changed: previously [], now ["-D", "warnings"]` and recompile
everything again. This commit refactors the Gradle tasks so as to not
send these flags when invoking Cargo, instead generating a
`.cargo/config.toml` containing these flags. This way, `rust-analyzer`
also picks them up and does not need to recompile the crates.

With both patches, Cargo avoids unnecessary crate rebuilds. All in all,
the second invocation of a `./gradlew --info -P modules='simple' -P
cargoCommands='test' codegen-server-test:build` command now takes 15
seconds less than the first invocation on my `c5.4xlarge` machine; Cargo
does not need to do _any_ work on the second invocation.

This commit also refactors the `build.gradle.kts` files of the `sdk`,
`sdk-codegen-test`, `codegen-test`, `codegen-server-test`, and
`codegen-server-test:python` subprojects to make them DRYer and more
consistent. The last 4 subprojects' buildscripts are now much shorter,
with all the common logic having been moved to `CodegenTestCommon.kt`.
Note that we have made the last 4 subprojects' `cargo check` and `cargo
doc` invocations use the same set of flags than in the `sdk` subproject
for consistency.

Closes #1378.
Closes #1412.
2022-06-15 22:06:25 +00:00
Zelda Hessler 04eeb4ff13
update: simplify and fix a latent issue with bytestream's streaming impl (#1461)
update: print helpful panic message for users on 32bit systems that try to stream large bodies
update: CHANGELOG.next.toml
2022-06-15 20:18:20 +00:00
Russell Cohen 898dc7060b
Writer fixes (#1469)
* Fixes for RustWriter bugs #1465 & #1459

* Fix behavior causing extra newlines in docs
2022-06-15 13:27:45 -05:00
Russell Cohen b45c1f03d8
Fixes for RustWriter bugs #1465 & #1459 (#1467) 2022-06-15 16:20:47 +00:00
John DiSanti c3f37303fa
Remove deprecated v1 arg format from `sdk-versioner` (#1456) 2022-06-14 18:52:27 +00:00
John DiSanti 4a8da5f7a6
Fix issues with setting crate ownership during publish (#1454) 2022-06-14 17:42:38 +00:00
Matteo Bigoi 8e84ee2eff
Codegenerate StructureShape, BlobShape, application, server and Python runtime (#1403)
We are introducing code-generation for Python bindings of StructureShape, BlobShape, EnumShape, OperationShape.

This PR also add a runtime server implementation to support serving Python business logic directly and with an idiomatic experience.

Co-authored-by: david-perez <d@vidp.dev>
2022-06-14 16:16:35 +00:00
Harry Barber 8911e86515
Make unitTest accept a closure using RustWriter (#1450)
* Make `unitTest` take `RustWriter.() -> Unit`

* Convert `unitTests` which use dependencies to use `unitTest` with `RustWriter.() -> Unit`
2022-06-14 15:38:15 +00:00
John DiSanti 66ff2bd0e7
Pin the `clap` version used to prevent future deprecation warnings (#1464)
Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-06-14 09:29:35 -05:00
John DiSanti 26316db7b2
Implement feature-gated independent SDK crate versioning (#1435)
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
2022-06-14 01:19:40 +00:00
John DiSanti 9156aca9fd
Add observability and more configuration to `sdk-sync` (#1452)
* Make `sdk-sync` Gradle heap/metaspace constraints configurable
* Dump process info on `sdk-sync` codegen failure
* Periodically log progress information in `sdk-sync`
* Enable verbose GC for codegen and use serial GC
2022-06-13 22:01:28 +00:00
John DiSanti ea2ae7bfc6
Add lints to `aws-config` (#1421)
* Add `unreachable_pub` lint to `aws-config`
* Add `missing_debug_implementations` lint to `aws-config`
* Add `rust_2018_idioms` lint to `aws-config`
* Update changelog
2022-06-13 20:34:11 +00:00
John DiSanti 3c1b71f3b9
Fix deprecation warnings in `aws-smithy-http-server` examples (#1462) 2022-06-13 12:55:33 -07:00
Russell Cohen 6e3e010e91
Relax behavior of profile parser (#1458)
- Fixes aws-sdk-rust#547

Previously, if no default profile was defined and no explicit profile was selected, the profile file provider would return an error. This relaxes that behavior to allow provider chains to move onto the next provider when that is the case.
2022-06-13 14:47:59 +00:00
82marbag c78c67e3fe
Comply with content types for the accept header (#1424)
* Verify accept header for payloads with `@mediaType`

Comply with content-types as described in the documentation [0]

[0] https://awslabs.github.io/smithy/1.0/spec/aws/aws-restjson1-protocol.html#content-type

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.com>
2022-06-13 09:17:02 +00:00
Chris Morin b7506ec2e5
Fix typo in documentation (#1455) 2022-06-12 20:28:31 -04:00
Zelda Hessler 4d4f91a007
add: RFC for supporting flexible checksums (#1451)
* add: RFC for supporting flexible checksums
add: link to RFC0016 in SUMMARY.md
fix: too many zeroes in RFC filenames

* update: sigv4 update section language

* update: RFC overview
remove: arbitrary chunk size limit

* update: RFC code to be safe from num conversion panics
2022-06-10 15:32:43 -05:00
AWS SDK Rust Bot 7b5954ed8f Update changelogs 2022-06-09 22:53:53 +00:00
david-perez 336c1a2925
Add the ability to generate `pub(crate)` values (#1444)
A small commit adding the ability to generate `pub(crate)` values.
Currently we don't need to, but this is used in #1342. It's also nicer
to use an enum instead of passing around a boolean.
2022-06-09 18:14:04 +02:00
Harry Barber 8cefacffa8
Temporarily disable benchmarking in CI (#1447) 2022-06-09 10:10:54 -04:00
John DiSanti 2986c93b0d
Configure Gradle parallelism and Kotlin compiler in `sdk-sync` (#1448) 2022-06-08 20:40:55 +00:00
david-perez 2d5bf6fc2c
Only generate `@error` `message` getter when defined in the model (#1441)
We are currently generating a useless `message` getter that returns
`None` even when the `message` field is not defined in the model.
Granted, in the client this field is _almost always_ there, because the
`AddErrorMessage` model transformer is applied unless the user opts out
in their `smithy-build.json`.
2022-06-08 18:01:20 +00:00
Harry Barber 1875448dbb
Use Vec for route resolution when number of routes <15 (#1429)
* Add `TinyMap` collection, which is a map backed by either `Vec` or `HashMap` depending on the number of entries.

* Replace `HashMap` with  `TinyMap` for `Routes::AwsJson10` and `Routes::AwsJson11`.
2022-06-07 10:58:19 +01:00
John DiSanti f1a4782614
Reintroduce `sdk-sync` parallelism by disabling Smithy parallelism (#1443)
* Revert "remove parallelism from the sync tool (#1436)"

This reverts commit f0568e1f18.

* Reintroduce `sdk-sync` parallelism by disabling Smithy parallelism

* Make the Smithy parallelism configurable
2022-06-06 19:17:31 +00:00
david-perez a49076a1e4
`#[allow(clippy::type_complexity)]` globally (#1440)
Because some models have shapes that generate complex Rust types (e.g.
nested collection and map shapes).

I've also taken the opportunity to homogenize the comments in
`AllowLintsGenerator.kt`.
2022-06-03 18:53:50 +02:00
Russell Cohen 242e6bcd67
make build image commit has configurable (#1437) 2022-06-02 19:20:31 +00:00
Russell Cohen f0568e1f18
remove parallelism from the sync tool (#1436)
smithy-build actually utilizes `ForkJoinPool.common()` when executing build projections. Because each service is its own projection, the build internally is _already_ running in parallel. Because of this, running the sync in parallel produces uneccessary memory pressure.

This change:
- removes parallelism
- runs gradle `--no-daemon --info` for better log output
2022-06-02 17:30:10 +00:00
Zelda Hessler b72c807f84
add: echo-server tool w/ README (#1432) 2022-06-02 11:25:11 -05:00
John DiSanti 3df09cc1d2
Fix release issues by introducing backwards compat into `sdk-versioner` (#1434)
The `sdk-sync` tool is running into issues during release due to the
`sdk-versioner` refactor commit since it is using a Docker build image
with the tools precompiled into it. Either the `sdk-versioner` binary is
too new and can't code generate the old commits, or it's too old and
can't generate the new commits.

This reintroduces the old `sdk-versioner` behavior so that it can
succeed against both sets of commits to get a release out.
2022-06-02 09:16:36 -04:00
Zelda Hessler 4194333c88
add: rfc template (#1428)
add: info about RFC process
update: CONTRIBUTING.md to mention RFCs
2022-06-01 10:41:29 -05:00
Zelda Hessler 8ef9a8580b
add: article on difficulties Zelda encountered while implementing streaming checksums (#1427)
* add: contributing docs overview page
add: article on difficulties Zelda encountered while implementing streaming checksums
update: SUMMARY.md table of contents
add: link to contributor design docs in CONTRIBUTING.md
2022-06-01 10:03:23 -05:00
John DiSanti f8867814ba
Refactor `sdk-versioner` to operate off the versions manifest (#1420) 2022-05-31 17:07:49 -07:00
John DiSanti d99d3e0c17
Prepare for release (#1426)
* Version bump
* Update SDK models
* Revert S3 model
2022-05-31 13:00:16 -07:00
Harry Barber c503debb4b
Remove usage of percent_decode_str for decoding query string key-value pairs (#1417)
* Use `form_urlencoding::parse` over `serde_urlencoded::from_str`, this removes our dependency on `serde_urlencoded`.

* Remove `percent_encoding::percent_decode_str` where possible.

* Contract `generateParsePercentEncodedStrFn` and its children into one function and make it optionally apply percent encoding.

* Add `impl From<std::convert::Infallible> for RequestRejection` to remove codegen branch.
2022-05-30 10:56:50 +01:00
david-perez fe92efbfd6
Increase max JVM heap size in `gradle.properties` (#1373)
It's currently defaulting to 512 MiB. I often see this message in my
build logs:

> Daemon will be stopped at the end of the build after running out of JVM memory

I've done some (unscientific) profiling with this setting enabled, and
max heap size can peak at ~600 MiB, so I see no reason to increase it
more than 1024 MiB.
2022-05-27 15:18:17 +00:00