diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index b834b8c2b8..dfa9171197 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -24,6 +24,18 @@ meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "all"} author = "jdisanti" [[aws-sdk-rust]] +message = "The AWS SDK now compiles for the `wasm32-unknown-unknown` and `wasm32-wasi` targets when no default features are enabled. WebAssembly is not officially supported yet, but this is a great first step towards it!" +references = ["smithy-rs#2254"] +meta = { "breaking" = false, "tada" = true, "bug" = false } +author = "eduardomourar" + +[[smithy-rs]] +message = "Clients now compile for the `wasm32-unknown-unknown` and `wasm32-wasi` targets when no default features are enabled. WebAssembly is not officially supported yet, but this is a great first step towards it!" +references = ["smithy-rs#2254"] +meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "client"} +author = "eduardomourar" + +[[smithy-rs]] message = "Streaming operations now emit the request ID at the `debug` log level like their non-streaming counterparts." references = ["smithy-rs#2495"] meta = { "breaking" = false, "tada" = false, "bug" = true } diff --git a/aws/rust-runtime/aws-config/Cargo.toml b/aws/rust-runtime/aws-config/Cargo.toml index 66c773ed75..92cacc1c52 100644 --- a/aws/rust-runtime/aws-config/Cargo.toml +++ b/aws/rust-runtime/aws-config/Cargo.toml @@ -13,13 +13,13 @@ client-hyper = ["aws-smithy-client/client-hyper"] rustls = ["aws-smithy-client/rustls"] native-tls = ["aws-smithy-client/native-tls"] rt-tokio = ["aws-smithy-async/rt-tokio", "tokio/rt"] +credentials-sso = ["dep:aws-sdk-sso", "dep:ring", "dep:hex", "dep:zeroize"] -default = ["client-hyper", "rustls", "rt-tokio"] +default = ["client-hyper", "rustls", "rt-tokio", "credentials-sso"] [dependencies] aws-credential-types = { path = "../../sdk/build/aws-sdk/sdk/aws-credential-types" } aws-http = { path = "../../sdk/build/aws-sdk/sdk/aws-http" } -aws-sdk-sso = { path = "../../sdk/build/aws-sdk/sdk/sso", default-features = false } aws-sdk-sts = { path = "../../sdk/build/aws-sdk/sdk/sts", default-features = false } aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async" } aws-smithy-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-client", default-features = false } @@ -33,11 +33,6 @@ time = { version = "0.3.4", features = ["parsing"] } tokio = { version = "1.13.1", features = ["sync"] } tracing = { version = "0.1" } -# implementation detail of SSO credential caching -ring = "0.16" -hex = "0.4.3" -zeroize = "1" - # implementation detail of IMDS credentials provider fastrand = "1" @@ -45,6 +40,12 @@ bytes = "1.1.0" http = "0.2.4" tower = { version = "0.4.8" } +# implementation detail of SSO credential caching +aws-sdk-sso = { path = "../../sdk/build/aws-sdk/sdk/sso", default-features = false, optional = true } +ring = { version = "0.16", optional = true } +hex = { version = "0.4.3", optional = true } +zeroize = { version = "1", optional = true } + [dev-dependencies] futures-util = { version = "0.3.16", default-features = false } tracing-test = "0.2.1" diff --git a/aws/rust-runtime/aws-config/src/default_provider/credentials.rs b/aws/rust-runtime/aws-config/src/default_provider/credentials.rs index 70b5725d0b..7f04b334b5 100644 --- a/aws/rust-runtime/aws-config/src/default_provider/credentials.rs +++ b/aws/rust-runtime/aws-config/src/default_provider/credentials.rs @@ -298,7 +298,9 @@ mod test { make_test!(ecs_credentials); make_test!(ecs_credentials_invalid_profile); + #[cfg(feature = "credentials-sso")] make_test!(sso_assume_role); + #[cfg(feature = "credentials-sso")] make_test!(sso_no_token_file); #[tokio::test] diff --git a/aws/rust-runtime/aws-config/src/default_provider/timeout_config.rs b/aws/rust-runtime/aws-config/src/default_provider/timeout_config.rs index 4ac803e597..1a173682c3 100644 --- a/aws/rust-runtime/aws-config/src/default_provider/timeout_config.rs +++ b/aws/rust-runtime/aws-config/src/default_provider/timeout_config.rs @@ -4,7 +4,7 @@ */ use crate::provider_config::ProviderConfig; -use aws_sdk_sso::config::timeout::TimeoutConfig; +use aws_smithy_types::timeout::TimeoutConfig; use std::time::Duration; const SDK_DEFAULT_CONNECT_TIMEOUT: Duration = Duration::from_millis(3100); diff --git a/aws/rust-runtime/aws-config/src/ecs.rs b/aws/rust-runtime/aws-config/src/ecs.rs index 536e74866a..17fab949f5 100644 --- a/aws/rust-runtime/aws-config/src/ecs.rs +++ b/aws/rust-runtime/aws-config/src/ecs.rs @@ -418,7 +418,7 @@ async fn validate_full_uri( } } -#[cfg(not(feature = "rt-tokio"))] +#[cfg(any(not(feature = "rt-tokio"), target_family = "wasm"))] fn tokio_dns() -> Option { None } @@ -426,7 +426,7 @@ fn tokio_dns() -> Option { /// DNS resolver that uses tokio::spawn_blocking /// /// DNS resolution is required to validate that provided URIs point to the loopback interface -#[cfg(feature = "rt-tokio")] +#[cfg(all(feature = "rt-tokio", not(target_family = "wasm")))] fn tokio_dns() -> Option { use aws_smithy_client::erase::boxclone::BoxFuture; use std::io::ErrorKind; diff --git a/aws/rust-runtime/aws-config/src/imds/client.rs b/aws/rust-runtime/aws-config/src/imds/client.rs index e791ec929a..6bc8a290bf 100644 --- a/aws/rust-runtime/aws-config/src/imds/client.rs +++ b/aws/rust-runtime/aws-config/src/imds/client.rs @@ -13,7 +13,6 @@ use crate::imds::client::token::TokenMiddleware; use crate::provider_config::ProviderConfig; use crate::PKG_VERSION; use aws_http::user_agent::{ApiMetadata, AwsUserAgent, UserAgentStage}; -use aws_sdk_sso::config::timeout::TimeoutConfig; use aws_smithy_client::http_connector::ConnectorSettings; use aws_smithy_client::{erase::DynConnector, SdkSuccess}; use aws_smithy_client::{retry, SdkError}; @@ -28,6 +27,7 @@ use aws_smithy_http_tower::map_request::{ }; use aws_smithy_types::error::display::DisplayErrorContext; use aws_smithy_types::retry::{ErrorKind, RetryKind}; +use aws_smithy_types::timeout::TimeoutConfig; use aws_types::os_shim_internal::Env; use bytes::Bytes; use http::{Response, Uri}; diff --git a/aws/rust-runtime/aws-config/src/imds/client/token.rs b/aws/rust-runtime/aws-config/src/imds/client/token.rs index f5c70b80e4..a4de2c0deb 100644 --- a/aws/rust-runtime/aws-config/src/imds/client/token.rs +++ b/aws/rust-runtime/aws-config/src/imds/client/token.rs @@ -19,7 +19,6 @@ use crate::imds::client::ImdsResponseRetryClassifier; use aws_credential_types::cache::ExpiringCache; use aws_credential_types::time_source::TimeSource; use aws_http::user_agent::UserAgentStage; -use aws_sdk_sso::config::timeout::TimeoutConfig; use aws_smithy_async::rt::sleep::AsyncSleep; use aws_smithy_client::erase::DynConnector; use aws_smithy_client::retry; @@ -31,6 +30,7 @@ use aws_smithy_http::operation::Operation; use aws_smithy_http::operation::{Metadata, Request}; use aws_smithy_http::response::ParseStrictResponse; use aws_smithy_http_tower::map_request::MapRequestLayer; +use aws_smithy_types::timeout::TimeoutConfig; use http::{HeaderValue, Uri}; use std::fmt::{Debug, Formatter}; use std::future::Future; diff --git a/aws/rust-runtime/aws-config/src/imds/credentials.rs b/aws/rust-runtime/aws-config/src/imds/credentials.rs index c260ba51f1..665d03f801 100644 --- a/aws/rust-runtime/aws-config/src/imds/credentials.rs +++ b/aws/rust-runtime/aws-config/src/imds/credentials.rs @@ -432,7 +432,7 @@ mod test { #[tokio::test] #[cfg(any(feature = "rustls", feature = "native-tls"))] async fn external_timeout_during_credentials_refresh_should_yield_last_retrieved_credentials() { - use aws_sdk_sso::config::AsyncSleep; + use aws_smithy_async::rt::sleep::AsyncSleep; let client = crate::imds::Client::builder() // 240.* can never be resolved .endpoint(http::Uri::from_static("http://240.0.0.0")) diff --git a/aws/rust-runtime/aws-config/src/lib.rs b/aws/rust-runtime/aws-config/src/lib.rs index 3c6a11fa1d..ee3a2b59d6 100644 --- a/aws/rust-runtime/aws-config/src/lib.rs +++ b/aws/rust-runtime/aws-config/src/lib.rs @@ -122,6 +122,7 @@ pub mod meta; pub mod profile; pub mod provider_config; pub mod retry; +#[cfg(feature = "credentials-sso")] pub mod sso; pub(crate) mod standard_property; pub mod sts; diff --git a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs index fda62d7708..351e7df8d8 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs @@ -7,6 +7,7 @@ use super::repr::{self, BaseProvider}; use crate::credential_process::CredentialProcessProvider; use crate::profile::credentials::ProfileFileError; use crate::provider_config::ProviderConfig; +#[cfg(feature = "credentials-sso")] use crate::sso::{SsoConfig, SsoCredentialsProvider}; use crate::sts; use crate::web_identity_token::{StaticConfiguration, WebIdentityTokenCredentialsProvider}; @@ -117,19 +118,29 @@ impl ProviderChain { .build(); Arc::new(provider) } + #[allow(unused_variables)] BaseProvider::Sso { sso_account_id, sso_region, sso_role_name, sso_start_url, } => { - let sso_config = SsoConfig { - account_id: sso_account_id.to_string(), - role_name: sso_role_name.to_string(), - start_url: sso_start_url.to_string(), - region: Region::new(sso_region.to_string()), - }; - Arc::new(SsoCredentialsProvider::new(provider_config, sso_config)) + #[cfg(feature = "credentials-sso")] + { + let sso_config = SsoConfig { + account_id: sso_account_id.to_string(), + role_name: sso_role_name.to_string(), + start_url: sso_start_url.to_string(), + region: Region::new(sso_region.to_string()), + }; + Arc::new(SsoCredentialsProvider::new(provider_config, sso_config)) + } + #[cfg(not(feature = "credentials-sso"))] + { + Err(ProfileFileError::UnknownProvider { + name: "sso".to_string(), + })? + } } }; tracing::info!(base = ?repr.base(), "first credentials will be loaded from {:?}", repr.base()); diff --git a/aws/rust-runtime/aws-types/Cargo.toml b/aws/rust-runtime/aws-types/Cargo.toml index 5c3d39b909..31d72bd1ec 100644 --- a/aws/rust-runtime/aws-types/Cargo.toml +++ b/aws/rust-runtime/aws-types/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/awslabs/smithy-rs" [features] # This feature is to be used only for doc comments -examples = ["aws-smithy-client/client-hyper", "aws-smithy-client/rustls", "hyper-rustls"] +examples = ["dep:hyper-rustls", "aws-smithy-client/client-hyper", "aws-smithy-client/rustls"] [dependencies] aws-credential-types = { path = "../aws-credential-types" } diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointsCredentialsTest.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointsCredentialsTest.kt index ea2bfe026f..89e11618a6 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointsCredentialsTest.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/EndpointsCredentialsTest.kt @@ -97,8 +97,8 @@ class EndpointsCredentialsTest { assert!(auth_header.contains("/us-west-2/foobaz/aws4_request"), "{}", auth_header); """, "capture_request" to RuntimeType.captureRequest(context.runtimeConfig), - "Credentials" to AwsCargoDependency.awsCredentialTypes(context.runtimeConfig) - .withFeature("test-util").toType().resolve("Credentials"), + "Credentials" to AwsRuntimeType.awsCredentialTypesTestUtil(context.runtimeConfig) + .resolve("Credentials"), "Region" to AwsRuntimeType.awsTypes(context.runtimeConfig).resolve("region::Region"), ) } @@ -120,8 +120,8 @@ class EndpointsCredentialsTest { assert!(auth_header.contains("/region-custom-auth/name-custom-auth/aws4_request"), "{}", auth_header); """, "capture_request" to RuntimeType.captureRequest(context.runtimeConfig), - "Credentials" to AwsCargoDependency.awsCredentialTypes(context.runtimeConfig) - .withFeature("test-util").toType().resolve("Credentials"), + "Credentials" to AwsRuntimeType.awsCredentialTypesTestUtil(context.runtimeConfig) + .resolve("Credentials"), "Region" to AwsRuntimeType.awsTypes(context.runtimeConfig).resolve("region::Region"), ) } diff --git a/aws/sdk/integration-tests/Cargo.toml b/aws/sdk/integration-tests/Cargo.toml index 286d73a6fb..398f26f490 100644 --- a/aws/sdk/integration-tests/Cargo.toml +++ b/aws/sdk/integration-tests/Cargo.toml @@ -17,4 +17,5 @@ members = [ "sts", "transcribestreaming", "using-native-tls-instead-of-rustls", + "webassembly", ] diff --git a/aws/sdk/integration-tests/webassembly/.cargo/config.toml b/aws/sdk/integration-tests/webassembly/.cargo/config.toml new file mode 100644 index 0000000000..031dad7377 --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/.cargo/config.toml @@ -0,0 +1,5 @@ +[build] +target = "wasm32-wasi" + +[target.wasm32-wasi] +rustflags = ["-C", "opt-level=1"] diff --git a/aws/sdk/integration-tests/webassembly/.vscode/settings.json b/aws/sdk/integration-tests/webassembly/.vscode/settings.json new file mode 100644 index 0000000000..22faeb86f2 --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.cargo.target": "wasm32-wasi" +} diff --git a/aws/sdk/integration-tests/webassembly/Cargo.toml b/aws/sdk/integration-tests/webassembly/Cargo.toml new file mode 100644 index 0000000000..b66406e6f5 --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/Cargo.toml @@ -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 <16357187+eduardomourar@users.noreply.github.com>"] +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" diff --git a/aws/sdk/integration-tests/webassembly/src/adapter/http_client.rs b/aws/sdk/integration-tests/webassembly/src/adapter/http_client.rs new file mode 100644 index 0000000000..5ca84838c9 --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/src/adapter/http_client.rs @@ -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) -> Result, ()> { + // Consumers here would pass the HTTP request to + // the Wasm host in order to get the response back + let body = " + + + + 2023-01-23T11:59:03.575496Z + doc-example-bucket + + + 2023-01-23T23:32:13.125238Z + doc-example-bucket2 + + + + account-name + a3a42310-42d0-46d1-9745-0cee9f4fb851 + + "; + Ok(http::Response::new(SdkBody::from(body))) +} diff --git a/aws/sdk/integration-tests/webassembly/src/adapter/mod.rs b/aws/sdk/integration-tests/webassembly/src/adapter/mod.rs new file mode 100644 index 0000000000..b563eb097a --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/src/adapter/mod.rs @@ -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 { + DynConnector::new(Adapter::default()) + } +} + +impl Service> for Adapter { + type Response = http::Response; + + type Error = ConnectorError; + + #[allow(clippy::type_complexity)] + type Future = std::pin::Pin< + Box> + Send + 'static>, + >; + + fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: http::Request) -> Self::Future { + println!("Adapter: sending request..."); + let res = http_client::make_request(req).unwrap(); + println!("{:?}", res); + Box::pin(async move { Ok(res) }) + } +} diff --git a/aws/sdk/integration-tests/webassembly/src/default_config.rs b/aws/sdk/integration-tests/webassembly/src/default_config.rs new file mode 100644 index 0000000000..fd8899cbe0 --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/src/default_config.rs @@ -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 { + 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") +} diff --git a/aws/sdk/integration-tests/webassembly/src/lib.rs b/aws/sdk/integration-tests/webassembly/src/lib.rs new file mode 100644 index 0000000000..bc9c1a112b --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/src/lib.rs @@ -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 +} diff --git a/aws/sdk/integration-tests/webassembly/src/list_buckets.rs b/aws/sdk/integration-tests/webassembly/src/list_buckets.rs new file mode 100644 index 0000000000..53504e6644 --- /dev/null +++ b/aws/sdk/integration-tests/webassembly/src/list_buckets.rs @@ -0,0 +1,20 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +pub async fn s3_list_buckets() { + use aws_sdk_s3::Client; + + use crate::default_config::get_default_config; + + let shared_config = get_default_config().await; + let client = Client::new(&shared_config); + let result = client.list_buckets().send().await.unwrap(); + assert_eq!(result.buckets().unwrap().len(), 2) +} + +#[tokio::test] +pub async fn test_s3_list_buckets() { + s3_list_buckets().await +} diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt index 66ae833bb4..428c766568 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/RuntimeType.kt @@ -248,6 +248,8 @@ data class RuntimeType(val path: String, val dependency: RustDependency? = null) fun smithyAsync(runtimeConfig: RuntimeConfig) = CargoDependency.smithyAsync(runtimeConfig).toType() fun smithyChecksums(runtimeConfig: RuntimeConfig) = CargoDependency.smithyChecksums(runtimeConfig).toType() fun smithyClient(runtimeConfig: RuntimeConfig) = CargoDependency.smithyClient(runtimeConfig).toType() + fun smithyClientTestUtil(runtimeConfig: RuntimeConfig) = CargoDependency.smithyClient(runtimeConfig) + .copy(features = setOf("test-util"), scope = DependencyScope.Dev).toType() fun smithyEventStream(runtimeConfig: RuntimeConfig) = CargoDependency.smithyEventStream(runtimeConfig).toType() fun smithyHttp(runtimeConfig: RuntimeConfig) = CargoDependency.smithyHttp(runtimeConfig).toType() fun smithyHttpAuth(runtimeConfig: RuntimeConfig) = CargoDependency.smithyHttpAuth(runtimeConfig).toType() diff --git a/rust-runtime/aws-smithy-async/Cargo.toml b/rust-runtime/aws-smithy-async/Cargo.toml index d77d6097d6..d148e229e4 100644 --- a/rust-runtime/aws-smithy-async/Cargo.toml +++ b/rust-runtime/aws-smithy-async/Cargo.toml @@ -13,7 +13,7 @@ rt-tokio = ["tokio/time"] [dependencies] pin-project-lite = "0.2" tokio = { version = "1.23.1", features = ["sync"] } -tokio-stream = "0.1.5" +tokio-stream = { version = "0.1.5", default-features = false } futures-util = { version = "0.3.16", default-features = false } [dev-dependencies] diff --git a/rust-runtime/aws-smithy-client/Cargo.toml b/rust-runtime/aws-smithy-client/Cargo.toml index 56ab945aa0..43b40da126 100644 --- a/rust-runtime/aws-smithy-client/Cargo.toml +++ b/rust-runtime/aws-smithy-client/Cargo.toml @@ -9,11 +9,11 @@ repository = "https://github.com/awslabs/smithy-rs" [features] rt-tokio = ["aws-smithy-async/rt-tokio"] -test-util = ["aws-smithy-protocol-test", "serde/derive", "rustls", "hyper/server", "hyper/h2", "tokio/full"] -native-tls = ["client-hyper", "hyper-tls", "rt-tokio"] -rustls = ["client-hyper", "hyper-rustls", "rt-tokio", "lazy_static", "dep:rustls"] -client-hyper = ["hyper"] -hyper-webpki-doctest-only = ["hyper-rustls/webpki-roots"] +test-util = ["dep:aws-smithy-protocol-test", "dep:hyper", "hyper?/server", "hyper?/h2", "dep:serde", "serde?/derive", "rustls", "tokio/full"] +native-tls = ["dep:hyper-tls", "client-hyper", "rt-tokio"] +rustls = ["dep:hyper-rustls", "dep:lazy_static", "dep:rustls", "client-hyper", "rt-tokio"] +client-hyper = ["dep:hyper"] +hyper-webpki-doctest-only = ["dep:hyper-rustls", "hyper-rustls?/webpki-roots"] [dependencies] diff --git a/rust-runtime/aws-smithy-http/Cargo.toml b/rust-runtime/aws-smithy-http/Cargo.toml index cef87ef295..e26419e4df 100644 --- a/rust-runtime/aws-smithy-http/Cargo.toml +++ b/rust-runtime/aws-smithy-http/Cargo.toml @@ -11,7 +11,7 @@ license = "Apache-2.0" repository = "https://github.com/awslabs/smithy-rs" [features] -rt-tokio = ["tokio/rt", "tokio/fs", "tokio/io-util", "tokio-util/io"] +rt-tokio = ["dep:tokio-util", "dep:tokio", "tokio?/rt", "tokio?/fs", "tokio?/io-util", "tokio-util?/io"] event-stream = ["aws-smithy-eventstream"] [dependencies] diff --git a/tools/ci-build/Dockerfile b/tools/ci-build/Dockerfile index 441a004696..b043866a31 100644 --- a/tools/ci-build/Dockerfile +++ b/tools/ci-build/Dockerfile @@ -41,7 +41,9 @@ RUN yum -y install \ git \ make \ openssl-devel \ - pkgconfig && \ + pkgconfig \ + tar \ + xz && \ yum clean all RUN set -eux; \ if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then \ @@ -60,6 +62,7 @@ RUN set -eux; \ rustup toolchain install ${rust_nightly_version} --component clippy; \ rustup target add x86_64-unknown-linux-musl; \ rustup target add wasm32-unknown-unknown; \ + rustup target add wasm32-wasi; \ cargo --version; \ cargo +${rust_nightly_version} --version; @@ -115,7 +118,25 @@ ARG maturin_version=0.14.1 ARG rust_nightly_version RUN cargo +${rust_nightly_version} -Z sparse-registry install maturin --locked --version ${maturin_version} +FROM install_rust AS wasm_pack +ARG wasm_pack_version=0.11.0 +ARG rust_nightly_version +RUN cargo +${rust_nightly_version} -Z sparse-registry install wasm-pack --locked --version ${wasm_pack_version} + +FROM install_rust AS wasmtime +ARG wasmtime_precompiled_url=https://github.com/bytecodealliance/wasmtime/releases/download/v7.0.0/wasmtime-v7.0.0-x86_64-linux.tar.xz +ARG wasmtime_precompiled_sha256=b8a1c97f9107c885ea73a5c38677d0d340a7c26879d366e8a5f3dce84cffec99 +ARG rust_nightly_version +RUN set -eux; \ + curl "${wasmtime_precompiled_url}" -L -o wasmtime.xz; \ + echo "${wasmtime_precompiled_sha256} wasmtime.xz" | sha256sum --check; \ + tar xf wasmtime.xz; \ + mv wasmtime-v*/wasmtime /opt; +FROM install_rust AS cargo_wasi +ARG cargo_wasi_version=0.1.27 +ARG rust_nightly_version +RUN cargo +${rust_nightly_version} -Z sparse-registry install cargo-wasi --locked --version ${cargo_wasi_version} # # Final image @@ -148,6 +169,9 @@ COPY --chown=build:build --from=cargo_hack /opt/cargo/bin/cargo-hack /opt/cargo/ COPY --chown=build:build --from=cargo_minimal_versions /opt/cargo/bin/cargo-minimal-versions /opt/cargo/bin/cargo-minimal-versions COPY --chown=build:build --from=cargo_check_external_types /opt/cargo/bin/cargo-check-external-types /opt/cargo/bin/cargo-check-external-types COPY --chown=build:build --from=maturin /opt/cargo/bin/maturin /opt/cargo/bin/maturin +COPY --chown=build:build --from=wasm_pack /opt/cargo/bin/wasm-pack /opt/cargo/bin/wasm-pack +COPY --chown=build:build --from=wasmtime /opt/wasmtime /opt/cargo/bin/wasmtime +COPY --chown=build:build --from=cargo_wasi /opt/cargo/bin/cargo-wasi /opt/cargo/bin/cargo-wasi COPY --chown=build:build --from=install_rust /opt/rustup /opt/rustup COPY --chown=build:build --from=musl_toolchain /usr/local/musl/ /usr/local/musl/ ENV PATH=$PATH:/usr/local/musl/bin/ diff --git a/tools/ci-scripts/check-aws-config b/tools/ci-scripts/check-aws-config index 1a1367dc71..60af5d28d2 100755 --- a/tools/ci-scripts/check-aws-config +++ b/tools/ci-scripts/check-aws-config @@ -38,4 +38,13 @@ cargo tree -d --edges normal --all-features echo "${C_YELLOW}## Testing every combination of features${C_RESET}" cargo hack test --feature-powerset --exclude-all-features +echo "${C_YELLOW}## Checking the wasm32-unknown-unknown and wasm32-wasi targets${C_RESET}" +cargo check --target wasm32-unknown-unknown --no-default-features +cargo check --target wasm32-wasi --no-default-features + +# TODO(https://github.com/awslabs/smithy-rs/issues/2499): Uncomment the following once aws-config tests compile for WASM +# echo "${C_YELLOW}## Testing the wasm32-unknown-unknown and wasm32-wasi targets${C_RESET}" +# wasm-pack test --node -- --no-default-features +# cargo wasi test --no-default-features + popd &>/dev/null