Commit Graph

1143 Commits

Author SHA1 Message Date
Zelda Hessler 02296d85a5
update: canary-runner deps (#1639)
* update: canary-runner deps
* rename: use Args instead of Opt to match other CLI tools
2022-08-18 18:39:33 +00:00
82marbag b98b160799
Allow `*` in ACCEPT header (#1646)
Allow `*` in ACCEPT header

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-08-18 17:20:59 +00:00
Burak 86539f2b08
Add TLS support to Pokemon server (#1634)
* Add TLS support to Pokemon server

* Add missing copyright header to TLS module

* Handle connection errors

* Move TLS example to own binary

* Update comments according to reviews

* Move rewrite base url middleware to its own function
2022-08-18 12:32:07 +01:00
Weihang Lo e185990a0e
Support granular control of specifying runtime crate versions (#1635)
* Support granular control of specifying runtime crate versions

**BREAKING**: after this PR, `in smity-build.json` the path
`rust-codegen.runtimeConfig.version` no longer exists. Instead, a new
field `versions` comes in. It's an object mapping a runtime crate name
to a version string. There is also a special key `DEFAULT`, which is
presetted as detected runtime version but open to override. Crates
without version specified would be set as the same version as which
associated to key `DEFAULT`.

Signed-off-by: Weihang Lo <weihanglo@users.noreply.github.com>
2022-08-17 22:20:44 +00:00
Taiki Endo a2f17cff31
Support raw pointer in cargo-check-external-types (#1643) 2022-08-17 20:40:54 +00:00
John DiSanti e179bea625
Don't compile crates a second time during `cargo publish` (#1644) 2022-08-17 19:28:55 +00:00
John DiSanti 275a6f8ad0
Fix git root check for submodules (#1640) 2022-08-17 10:31:34 -07:00
Burak 7731b3f1e0
Override codegen version commit hash in PR diffs (#1636)
* Override codegen version commit hash in PR diffs

* Move version commit hash override to shell script
2022-08-17 11:24:19 +01:00
Zelda Hessler e4e9a1d34f
fix: move smithy config customization into the smithy code generator (#1599)
* fix: move smithy config customization into the smithy code generator

* add: CHANGELOG entry

* update: tests

* fix: config codegen tests

* update: hide config fields and provide accessors instead

* fix: usage of private fields
add: accessor docs

* format: run ktlint

* fix: update more old code

* update: clone sleep_impl since that's why people access it

* update: CHANGELOG.next.toml

* Update CHANGELOG.next.toml

Co-authored-by: John DiSanti <jdisanti@amazon.com>

Co-authored-by: John DiSanti <jdisanti@amazon.com>
2022-08-16 15:47:07 -05:00
John DiSanti 0f47f69ddf
Fix changelog template (#1638) 2022-08-16 18:59:10 +00:00
david-perez fd98756160
Add `awslabs/smithy-rs-server` as a crate owner in the `publisher` tool (#1619)
This commit adds the SDK and server groups to smithy-rs runtime crates,
but only the SDK group on `AwsRuntime` and `AwsSdk` crates.

With this change, the `publisher` tool won't fail when publishing the
`aws-smithy-http-server` crate.
2022-08-15 16:56:57 -07:00
John DiSanti 7b2aef71da
Make the PR Bot manually invokable (#1632) 2022-08-15 15:41:11 -07:00
david-perez 374a1c5df7
Bubble up unknown enum variant error when parsing XML in the server (#1485)
XML deserialization of enums is currently broken.

This commit should have been done as part of #1398, but we only tested
that patch using the restJson1 protocol.

The converter from the unknown enum variant error into
`aws_smithy_json::deserialize::Error` has been removed from
`ServerEnumGenerator`, since it's protocol-specific logic. We instead
use `map_err` in the protocol-specific parsers before bubbling up using
`?`.

Fixes #1477.
2022-08-12 13:11:12 +00:00
Burak 610d963df6
Add codegen version to generated package (#1621)
* Add codegen version to generated package metadata

* Update `CHANGELOG.next.toml`

* Remove unnecessary try-catch block from `smithyCodegenVersion`

* Add git commit hash to version

* Fix version filename

* Add tests for `Version`

* Store version in "$smithyRsVersion\n$gitCommitHash" format

* Make version parsing more strict
2022-08-12 11:35:55 +01:00
Harry Barber 48a85316a4
Make OperationExtension hold a &'static str for the absolute shape ID (#1631) 2022-08-11 22:56:27 +00:00
david-perez f421c63508
Make server pass naming obstacle course protocol tests (#1333)
This commit fixes two bugs that were present in the server
implementation:

* We were incorrectly referring to the operation input shape name
  instead of using the symbol provider in
  `ServerOperationHandlerGenerator.kt` and
  `ServerOperationRegistryGenerator.kt`.
* We were not escaping Rust reserved keywords in operation names in
  `ServerOperationRegistryGenerator.kt`.

The second bug would have been caught had we been generating server
crates for the two naming obstacle course test suites
(`naming-obstacle-course-ops.smithy` and
`naming-obstacle-course-structs.smithy`) that the client is already
passing. This commit adds these suites to the `codegen-server-test`
subproject, and expands `naming-obstacle-course-ops.smithy` to exercise
the logic that was causing the first bug.
2022-08-11 21:26:23 +00:00
John DiSanti 86debc676d
Improve `cargo-check-external-types` README (#1630) 2022-08-11 20:11:04 +00:00
John DiSanti a6d0364fa2
Default to not generating a README in the SDK codegen (#1628) 2022-08-11 17:05:46 +00:00
John DiSanti 18c5062cc6
Break `cargo-check-external-types` dependency on `smithy-rs-tool-common` (#1629) 2022-08-11 09:12:19 -07:00
John DiSanti cbbbec4a48
Check external types for runtime and SDK crates in CI (#1625)
* Rename `cargo-api-linter` to `cargo-check-external-types`
* Run `cargo-check-external-types` on Smithy client/shared runtime crates
* Run `cargo-check-external-types` on SDK runtime crates
* Fix bug in determining crate name
* Run `cargo-check-external-types` on generated SDK crates
2022-08-10 18:33:43 -07:00
John DiSanti 6e1d1f6c18
Fix adhoc SDK codegen and refactor SDK CI (#1624)
* Fix `aws:sdk-codegen-test` build
* Add config for SDK endpoint/readme generation
* Rename `sdk-codegen-test` to `sdk-adhoc-test` and update README
* Add `sdk-adhoc-tests` to CI
* Refactor CI scripts

The `check-rust-runtime-and-tools` script was getting beyond 20
minutes to run, so this commit splits it into `check-aws-config`,
`check-rust-runtimes`, and `check-tools`.

This also enables most of the checks to run before the smoke test SDK is
generated, which should deliver more immediate feedback on PRs.

* Give the canary its own CI step
2022-08-10 09:08:08 -07:00
Zelda Hessler 70a621930f
update: add 10ms margin of error to timeout duration assertion (#1594)
* update: add 10ms margin of error to timeout duration assertion

* update: assert_elapsed macro with customizable margin of error.
2022-08-09 14:32:55 -07:00
John DiSanti 462aef6394
Fix SDK integration tests in local dev and add CI step to verify (#1600) 2022-08-08 16:29:22 -07:00
John DiSanti d9d49a1b2a
Add `changelogger` tool to CI checks (#1615) 2022-08-08 20:30:34 +00:00
Harry Barber 903d3f2aea
Fix double semicolons in logging generated code (#1622) 2022-08-08 16:16:01 +01:00
AWS SDK Rust Bot db48039065 Update changelog 2022-08-04 01:37:32 +00:00
John DiSanti 65e53ab87a
Version bump smithy-rs (#1617)
Co-authored-by: david-perez <d@vidp.dev>
2022-08-04 01:25:54 +02:00
david-perez 7ab56e96d5
Allow both teams to release new smithy-rs versions independently (#1618)
This commit modifies the `CODEOWNERS` to allow both
`@awslabs/rust-sdk-owners` and `@awslabs/smithy-rs-server` teams to
release new versions of smithy-rs independently, without requiring peer
approval from the other team.

Syntax and semantics of `CODEOWNERS`: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
2022-08-03 22:20:13 +00:00
John DiSanti 5d69e73092
Upgrade `cargo-api-linter` to the latest nightly Rust (#1579)
* Upgrade `cargo-api-linter` to the latest Rust nightly
* Upgrade Rust nightly used by CI
* Handle failure to provide error context better
* Fix `aws-config` external type approval list
* Fix error context pathing issue
2022-08-03 20:12:31 +00:00
82marbag 458eeb63b9
Health check in Pokemon service (#1608)
Health check operation in Pokemon service

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-08-03 18:22:00 +01:00
John DiSanti a2ccdf70fb
Add `#[doc(hidden)]` to struct fields to encourage accessor use (#1573) 2022-08-03 01:26:04 +00:00
Harry Barber ed2a866c8e
Add server side HTTP logging layer (#1550)
* Add `MakeFmt` trait which modifies `Display`/`Debug` implementations.

* Add `http` wrappers which modify the `Debug` and `Display` implementations based on closures marking sensitivity. Each wrapper has an associated `MakeFmt` impl.

* Add `InstrumentOperation` [tower::Service](https://docs.rs/tower/latest/tower/trait.Service.html) which logs requests and responses. Accepts a `MakeFmt` for each potentially sensitive component of the request/response.

* Add [ServerHttpSensitivityGenerator.kt](https://github.com/awslabs/smithy-rs/compare/harryb/add-logging?expand=1#diff-a7ad7f28d152bba6f2a63f3bde498582d91c8f7ab9c2de0c7f4494d6fd1c02ff) which generates marker closures from models.

* Apply `InstrumentationOperation` to the `OperationHandler` using `MakeFmt`s using the marker closures.

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-08-02 21:32:03 +00:00
david-perez dde9646b61
Correctly load client or server specific decorators from classpath (#1592)
The current approach that attempts to downcast never worked; all Rust
decorators were being loaded, and the cast was doing nothing, because
the generic type parameter is erased at runtime.

Attempting to downcast a generic class `C<T>` to `C<U>` where `U: T` is
not possible to do in Kotlin (and presumably all JVM-based languages)
_at runtime_. Not even when using reified type parameters of inline
functions. See https://kotlinlang.org/docs/generics.html#type-erasure
for details.

This commit thus goes for another approach, suggested in the linked
Stack Overflow question [0]: add a method to the loaded classes that
signals at runtime the generic type parameter (`ClientCodegenContext` or
`ServerCodegenContext`) they can work with, in order to filter them.

This commit also simplifies the way the Python server project loads the Python
server-specific decorators, by deleting the combined decorator
`PythonServerCodegenDecorator`, which was being loaded from the classpath, and
instead directly using `CombinedCodegenDecorator` and passing it the Python
server-specific decorators in the `extras` parameter.

[0]: https://stackoverflow.com/questions/5451734/loading-generic-service-implementations-via-java-util-serviceloader
2022-08-02 17:54:02 +00:00
david-perez 3a2de293f4
Don't depend on the `modifyMtime` task if it has not been registered (#1607)
When registering the Cargo commands tasks. The `aws:sdk` is the only
Gradle subproject that depends on the Cargo commands tasks, but that
does not register the `modifyMtime` task.

Partially addresses #1596.
2022-08-02 10:55:35 +00:00
Matteo Bigoi 000e8b0db7
Allow to build and test on MacOX M1/x86 chips (#1609)
* Allow to build and test on MacOX M1 chips

* Add MacOS linker config

* Fall back to standard event loop if uvloop is not available
2022-08-01 23:27:51 +00:00
david-perez 430f4bf8b4
Make `Content-Type` check in `ServerHttpBoundProtocolGenerator` protocol-agnostic (#1605)
The `Content-Type` check of the incoming request in
`ServerHttpBoundProtocolGenerator` is performed by comparing against the
configured protocol directly within the class.

Delegating to the protocol enables the implementation of protocols in
decorators loaded from the classpath in other projects outside
smithy-rs.

This commit makes the `ServerHttpBoundProtocolGenerator`
protocol-agnostic by looking up the expected incoming request
`Content-Type` header from the protocol implementation directly. To this
end, the macro-generated `check_<protocol>_content_type` functions from
the `aws-smithy-http-server` runtime have been replaced with a single
general `check_content_type` function that takes in the expected mime
type.
2022-08-01 10:27:51 +02:00
Harry Barber 738d84cc2a
RFC(edit): Logging in the Presence of Sensitive Data (#1591)
* Fix grammar

* Merge public and internal guideline
2022-07-29 19:11:36 +00:00
John DiSanti 5fb56c8446
Set minimum `hyper` version to `0.14.12` (#1602) 2022-07-29 09:01:06 -05:00
John DiSanti 6e031dcd4f
Fix the SDK canary (#1588)
* Update `generate-matrix` to return SDK release tags instead of versions
* Upgrade the SDK used in the canary runner
* Move `build-bundle` into `canary-runner` to use `versions.toml`
* Make release tag matrix output singular
* Delete old `build-bundle` and update README
* Add canary projects to standard tool CI checks
* Generate `Cargo.toml` before testing `canary-lambda`
2022-07-28 21:52:07 +00:00
Harry Barber 0fb5ccb814
Remove excess cargo test passes from additional-ci (#1595)
* Use --exclude-all-features in additional-ci

* Remove excess cargo test --all-features

* Improve powerset echo
2022-07-28 20:40:49 +00:00
Weihang Lo e38db43ceb
Basic support of @deprecated trait in Smithy model (#1570)
* Add helper for creating deprecated attribute

* `Attribute.Custom.deprecated` is the main logic for building up
  `#[deprecated]` attribute
* `RustWriter.deprecatedShape` is the counterpart of `documentShape`,
  but we do not going to generalize it as what `documentShape` does.
  Deprecated is only for Rust code and probably won't be used in other
  output language.

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Test `@deprecated` trait for RustWriter

* Support `@deprecated` trait for StructureGenerator

* Support `@deprecated` trait for UnionGenerator

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Support `@deprecated` trait for EnumGenerator

* Support `@deprecated` trait for TopLevelErrorGenerator

* Support `@deprecated` trait for CombinedErrorGenerator

* Support `@deprecated` trait for ServerCombinedErrorGenerator

* Support `@deprecated` trait for FluentClient

* Support `@deprecated` trait for BuilderGenerator

* Cleanup leftover in test

* Use `dq()` helper method instead of escaping by hands

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Leverage Kotlin null safety well

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Allow `deprecated` rustc lint rule

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Allow deprecated in unit tests

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* Leverage kotlin null safety check again

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

* changelog: Support @deprecated trait

Signed-off-by: Weihang Lo <whlo@amazon.co.uk>

Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
2022-07-28 19:02:55 +00:00
82marbag 74a106f195
Update Status of RFCs (#1593)
* Update Status of RFCs

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-07-28 14:48:38 +00:00
Zelda Hessler 3d53e7405d
update: `From<hyper::Body>` for `ByteStream` now delegates to `SdkBody::from` (#1585)
* update: From<hyper::Body> for ByteStream now delegates to SdkBody::from
* add: comments to SdkBody inner enum variants
2022-07-27 20:14:36 +00:00
John DiSanti 852c2ec260
Upgrade Ktlint and fix lint configuration (#1572)
* Exclude sigv4 test suite from pre-commit file endings hook
* Upgrade Ktlint
* Make Gradle ktlint target consistent with pre-commit

They were previously running two separate rulesets since pre-commit
pulls in the standard ruleset, and that wasn't pulled into the Gradle
dependencies.

* Fix Gradle Ktlint paths
* Establish editorconfig for Ktlint
* Fix Ktlint lints
* Enable `trailing-commas` rule
* Fix block quote indentation
2022-07-27 18:04:07 +00:00
82marbag 68feb37e0a
Add RFC 19 to the summary (#1584)
Add RFC 19 to the summary (#1584)

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-07-27 16:31:58 +00:00
Zelda Hessler c7949be857
Add/alternative runtime tests (#1575)
* add: alternative runtime tests
2022-07-27 10:34:01 -05:00
david-perez d952ccd8f3
Fix `codegen-server` and `codegen-server:python` projects when crate name contains hyphens (#1581)
Rust crate names are allowed to contain hyphens, while Rust identifiers
are not [0]. However, the Rust and Python server projects are currently
broken because we use the user-provided crate name verbatim
(`moduleName` in `settings`) in places where Rust expects valid
identifiers:

* The Rust server's generated operation registry Rust docs use the crate
  name verbatim in import statements.
* The Python server uses the crate name verbatim to generate a shared
  library, but library target names in `Cargo.toml` cannot contain
  hyphens.

We never caught this bug because we don't generate any crates with
hyphens in their names.

This commit:

* fixes the above usages of verbatim crate names where identifiers are
  expected by calling `toSnakeCase()`,
* modifies the unit test for the server's operation registry generator
  to generate a crate with hyphens in its name,
* changes the Pokémon service server SDK crate names from
  `pokemon_service_sdk` to `pokemon-service-server-sdk`, so that we
  exercise generation of a crate with hyphens in its name, and to better
  convey that the generated SDK is server-specific; and
* changes the Pokémon service client SDK crate name from
  `pokemon_service_client` to `pokemon-service-client`, and changes the
  Pokémon service crate name itself from `pokemon_service` to
  `pokemon-service`, for symmetry.

[0]: https://doc.rust-lang.org/reference/identifiers.html
2022-07-27 15:27:15 +02:00
Oleksandr Kolomiiets 0f2fae1183
Change detailed logs in CredentialsProviderChain from info to debug (#1578) 2022-07-26 18:38:28 -07:00
John DiSanti 2670831154
Fix the check manifests tool (#1576) 2022-07-26 19:06:08 +00:00
82marbag 720a106bbb
Update RFC links (#1574)
* Update RFC links

Some links in https://awslabs.github.io/smithy-rs/design/rfcs/overview.html
are broken.

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
2022-07-26 17:58:51 +00:00