-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support compiling to webassembly #2254
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
ffa9923
feat(aws-config): define default feature for sso
eduardomourar 91a8dcc
chore(aws): disable unused features
eduardomourar 1fbd97b
chore(rust-runtime): disable unused features
eduardomourar 06a62b7
chore: add missing tokio fs feature
eduardomourar a725e0c
chore: disable spawn blocking on wasm
eduardomourar cae60ef
chore: fix sso feature
eduardomourar ef00e01
chore: allow unused variables when not sso
eduardomourar 497c4b9
chore: remove unnecessary dependency filter for wasm
eduardomourar 59791df
chore: add integration test for wasm
eduardomourar 7478507
chore: ensure test-util feature is applied to dev dependencies
eduardomourar 56b7b33
chore: disable retry config
eduardomourar d8fcf49
chore: simplify features as suggested
eduardomourar 86a5689
chore: no default features for aws types
eduardomourar c0d61ed
chore: rename credentials-sso feature
eduardomourar a5b6316
Revert "chore: simplify features as suggested"
eduardomourar f2d47b5
chore: set right name in default features
eduardomourar df4ab9e
chore: create smithy client test util in runtime types
eduardomourar 154342f
Update aws/rust-runtime/aws-types/Cargo.toml
eduardomourar 937022c
Update aws/rust-runtime/aws-inlineable/Cargo.toml
eduardomourar 08df0df
Update aws/rust-runtime/aws-config/src/profile/credentials/exec.rs
eduardomourar 98d336e
Update aws/rust-runtime/aws-config/src/profile/credentials/exec.rs
eduardomourar 45cae40
Update aws/rust-runtime/aws-config/src/profile/credentials/exec.rs
eduardomourar 1687bbc
Update aws/rust-runtime/aws-config/src/lib.rs
eduardomourar 14e23fb
chore: use hardcoded credentials feature
eduardomourar be22904
chore: make wasm example for s3 instead
eduardomourar 6a578ec
chore: fix formatting
eduardomourar 1406d42
Merge remote-tracking branch 'origin/main' into feat/support-wasm
eduardomourar 25c8fd3
chore: fix kotlin formatting
eduardomourar 4791b46
chore: fix kotlin unit tests
eduardomourar 40136bd
chore: use timeout config from smithy types
eduardomourar 00234f2
Merge branch 'main' into feat/support-wasm
eduardomourar 40da289
Merge branch 'main' into feat/support-wasm
eduardomourar 2755357
chore: move tests into main file
eduardomourar 5fc3dfd
chore: add vscode setttings to target wasi by default
eduardomourar 0506f75
chore: fix test-util feature for smithy client
eduardomourar bc4f686
chore: separate adapter into own module
eduardomourar d353ac3
Merge branch 'main' into feat/support-wasm
eduardomourar 0beea87
chore: fix test with no default features
eduardomourar 0d52a87
Merge branch 'main' into feat/support-wasm
eduardomourar ffe83ea
Fix typo
jdisanti 0ec8283
Update changelog
jdisanti 01f106c
Check compilation of `aws-config` against `wasm32` in CI
jdisanti bc2fe6c
Merge remote-tracking branch 'origin/main' into support-wasm
jdisanti ba00b09
Fix Dockerfile issue and use correct cargo-wasi command
jdisanti 04c7094
Small Dockerfile fix
jdisanti 7e90fb3
Add missing `tar` binary to Docker image
jdisanti 4bfd4e4
Merge branch 'main' into feat/support-wasm
jdisanti 5e63eec
Merge branch 'main' into feat/support-wasm
rcoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -17,4 +17,5 @@ members = [ | |
"sts", | ||
"transcribestreaming", | ||
"using-native-tls-instead-of-rustls", | ||
"webassembly", | ||
] |
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,5 @@ | ||
[build] | ||
target = "wasm32-wasi" | ||
|
||
[target.wasm32-wasi] | ||
rustflags = ["-C", "opt-level=1"] |
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,3 @@ | ||
{ | ||
"rust-analyzer.cargo.target": "wasm32-wasi" | ||
} |
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,30 @@ | ||
# This Cargo.toml is unused in generated code. It exists solely to enable these tests to compile in-situ | ||
[package] | ||
name = "webassembly" | ||
version = "0.1.0" | ||
authors = ["Eduardo Rodrigues <[email protected]>"] | ||
description = """ | ||
These tests ensure that things will fail (or not fail) as expected | ||
when target is set to wasm32-wasi for all SDK and runtime crates. | ||
""" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
repository = "https://github.com/awslabs/smithy-rs" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = ["rt-tokio"]} | ||
aws-credential-types = { path = "../../build/aws-sdk/sdk/aws-credential-types", features = ["hardcoded-credentials"] } | ||
aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3", default-features = false } | ||
aws-smithy-client = { path = "../../build/aws-sdk/sdk/aws-smithy-client", default-features = false } | ||
aws-smithy-http = { path = "../../build/aws-sdk/sdk/aws-smithy-http" } | ||
aws-smithy-types = { path = "../../build/aws-sdk/sdk/aws-smithy-types" } | ||
aws-types = { path = "../../build/aws-sdk/sdk/aws-types" } | ||
http = "0.2.8" | ||
tokio = { version = "1.24.2", features = ["macros", "rt"] } | ||
tower = "0.4.13" |
29 changes: 29 additions & 0 deletions
29
aws/sdk/integration-tests/webassembly/src/adapter/http_client.rs
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,29 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_smithy_http::body::SdkBody; | ||
|
||
pub(crate) fn make_request(_req: http::Request<SdkBody>) -> Result<http::Response<SdkBody>, ()> { | ||
// Consumers here would pass the HTTP request to | ||
// the Wasm host in order to get the response back | ||
let body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> | ||
<ListAllMyBucketsResult> | ||
<Buckets> | ||
<Bucket> | ||
<CreationDate>2023-01-23T11:59:03.575496Z</CreationDate> | ||
<Name>doc-example-bucket</Name> | ||
</Bucket> | ||
<Bucket> | ||
<CreationDate>2023-01-23T23:32:13.125238Z</CreationDate> | ||
<Name>doc-example-bucket2</Name> | ||
</Bucket> | ||
</Buckets> | ||
<Owner> | ||
<DisplayName>account-name</DisplayName> | ||
<ID>a3a42310-42d0-46d1-9745-0cee9f4fb851</ID> | ||
</Owner> | ||
</ListAllMyBucketsResult>"; | ||
Ok(http::Response::new(SdkBody::from(body))) | ||
} |
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,44 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
mod http_client; | ||
|
||
use aws_smithy_client::erase::DynConnector; | ||
use aws_smithy_client::http_connector::HttpConnector; | ||
use aws_smithy_http::body::SdkBody; | ||
use aws_smithy_http::result::ConnectorError; | ||
use std::task::{Context, Poll}; | ||
use tower::Service; | ||
|
||
#[derive(Default, Debug, Clone)] | ||
pub(crate) struct Adapter {} | ||
|
||
impl Adapter { | ||
pub fn to_http_connector() -> impl Into<HttpConnector> { | ||
DynConnector::new(Adapter::default()) | ||
} | ||
} | ||
|
||
impl Service<http::Request<SdkBody>> for Adapter { | ||
type Response = http::Response<SdkBody>; | ||
|
||
type Error = ConnectorError; | ||
|
||
#[allow(clippy::type_complexity)] | ||
type Future = std::pin::Pin< | ||
Box<dyn std::future::Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>, | ||
>; | ||
|
||
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { | ||
Poll::Ready(Ok(())) | ||
} | ||
|
||
fn call(&mut self, req: http::Request<SdkBody>) -> Self::Future { | ||
println!("Adapter: sending request..."); | ||
let res = http_client::make_request(req).unwrap(); | ||
println!("{:?}", res); | ||
Box::pin(async move { Ok(res) }) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
aws/sdk/integration-tests/webassembly/src/default_config.rs
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,33 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_config::retry::RetryConfig; | ||
use aws_credential_types::Credentials; | ||
use aws_smithy_types::timeout::TimeoutConfig; | ||
use aws_types::region::Region; | ||
use std::future::Future; | ||
|
||
use crate::adapter::Adapter; | ||
|
||
pub(crate) fn get_default_config() -> impl Future<Output = aws_config::SdkConfig> { | ||
aws_config::from_env() | ||
.region(Region::from_static("us-west-2")) | ||
.credentials_provider(Credentials::from_keys( | ||
"access_key", | ||
"secret_key", | ||
Some("session_token".to_string()), | ||
)) | ||
.timeout_config(TimeoutConfig::disabled()) | ||
.retry_config(RetryConfig::disabled()) | ||
.http_connector(Adapter::to_http_connector()) | ||
.load() | ||
} | ||
|
||
#[tokio::test] | ||
pub async fn test_default_config() { | ||
let shared_config = get_default_config().await; | ||
let client = aws_sdk_s3::Client::new(&shared_config); | ||
assert_eq!(client.conf().region().unwrap().to_string(), "us-west-2") | ||
} |
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,13 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
mod adapter; | ||
mod default_config; | ||
mod list_buckets; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
pub async fn main() { | ||
crate::list_buckets::s3_list_buckets().await | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some prerequisite work to do before this will run in CI. I'll see if I can get around to that today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our best option is to install cargo-wasi then run
cargo wasi test -- --nocapture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That aspect of it didn't even cross my mind yet 😅
I did the prerequisite work to actually include the tests in the first place in #2255.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the tokio crate, they have a nice a setup for testing against the different webassembly targets: https://github.com/tokio-rs/tokio/blob/06f1a601bb05b1aba9f95020a7fa7572899c588f/.github/workflows/ci.yml#L529-L590