mirror of https://github.com/smithy-lang/smithy-rs
Merge branch 'feat/default-wasi-http' of https://github.com/eduardomourar/smithy-rs into eduardomourar-feat/default-wasi-http
This commit is contained in:
commit
beaaa7a45c
|
@ -3,3 +3,9 @@ target = "wasm32-wasi"
|
|||
|
||||
[target.wasm32-wasi]
|
||||
rustflags = ["-C", "opt-level=1"]
|
||||
runner = [
|
||||
"wasmtime",
|
||||
"--disable-cache",
|
||||
"--preview2",
|
||||
"--wasi-modules=experimental-wasi-http",
|
||||
]
|
||||
|
|
|
@ -12,20 +12,19 @@ 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"] }
|
||||
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||
aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = [
|
||||
"rt-tokio",
|
||||
] }
|
||||
aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3", default-features = false }
|
||||
aws-smithy-http = { path = "../../build/aws-sdk/sdk/aws-smithy-http" }
|
||||
aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["client"] }
|
||||
aws-smithy-runtime-api = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["client"] }
|
||||
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"
|
||||
aws-smithy-wasm = { path = "../../build/aws-sdk/sdk/aws-smithy-wasm" }
|
||||
tokio = { version = "1.32.0", features = ["macros", "rt"] }
|
||||
|
||||
[target.'cfg(all(target_family = "wasm", target_os = "wasi"))'.dependencies]
|
||||
wit-bindgen = { version = "0.11.0", features = ["macros", "realloc"] }
|
||||
|
|
|
@ -12,21 +12,18 @@ use std::future::Future;
|
|||
|
||||
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()),
|
||||
))
|
||||
.region("us-east-2")
|
||||
.timeout_config(TimeoutConfig::disabled())
|
||||
.retry_config(RetryConfig::disabled())
|
||||
.http_client(WasmHttpConnector::new())
|
||||
.no_credentials()
|
||||
.load()
|
||||
.await
|
||||
}
|
||||
|
||||
#[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.config().region().unwrap().to_string(), "us-west-2")
|
||||
assert_eq!(client.config().region().unwrap().to_string(), "us-east-2")
|
||||
}
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
mod default_config;
|
||||
mod http;
|
||||
mod list_buckets;
|
||||
#![allow(dead_code)]
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
pub async fn main() {
|
||||
crate::list_buckets::s3_list_buckets().await
|
||||
}
|
||||
#[cfg(target_family = "wasm")]
|
||||
mod default_config;
|
||||
#[cfg(target_family = "wasm")]
|
||||
mod http;
|
||||
#[cfg(target_family = "wasm")]
|
||||
mod list_objects;
|
||||
#[cfg(all(target_family = "wasm", target_os = "wasi"))]
|
||||
mod wasi;
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* 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().len(), 2)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
pub async fn test_s3_list_buckets() {
|
||||
s3_list_buckets().await
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
use aws_sdk_s3::operation::list_objects_v2::ListObjectsV2Output;
|
||||
|
||||
async fn s3_list_objects() -> ListObjectsV2Output {
|
||||
use crate::default_config::get_default_config;
|
||||
use aws_sdk_s3::Client;
|
||||
|
||||
let shared_config = get_default_config().await;
|
||||
let client = Client::new(&shared_config);
|
||||
let operation = client
|
||||
.list_objects_v2()
|
||||
.bucket("nara-national-archives-catalog")
|
||||
.delimiter("/")
|
||||
.prefix("authority-records/organization/")
|
||||
.max_keys(5)
|
||||
.customize()
|
||||
.await
|
||||
.unwrap();
|
||||
operation.send().await.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
pub async fn test_s3_list_objects() {
|
||||
let result = s3_list_objects().await;
|
||||
let objects = result.contents();
|
||||
assert!(objects.len() > 1);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
// Needed for WASI-compliant environment as it expects specific functions
|
||||
// to be exported such as `cabi_realloc`, `_start`, etc.
|
||||
|
||||
wit_bindgen::generate!({
|
||||
inline: "
|
||||
package aws:component
|
||||
|
||||
interface run {
|
||||
run: func() -> result
|
||||
}
|
||||
|
||||
world main {
|
||||
export run
|
||||
}
|
||||
",
|
||||
exports: {
|
||||
"aws:component/run": Component
|
||||
}
|
||||
});
|
||||
|
||||
struct Component;
|
||||
|
||||
impl exports::aws::component::run::Guest for Component {
|
||||
fn run() -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ object CrateSet {
|
|||
"aws-smithy-runtime-api",
|
||||
"aws-smithy-types",
|
||||
"aws-smithy-types-convert",
|
||||
"aws-smithy-wasm",
|
||||
"aws-smithy-xml",
|
||||
)
|
||||
|
||||
|
|
|
@ -19,5 +19,6 @@ members = [
|
|||
"aws-smithy-runtime-api",
|
||||
"aws-smithy-types",
|
||||
"aws-smithy-types-convert",
|
||||
"aws-smithy-wasm",
|
||||
"aws-smithy-xml",
|
||||
]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
[package]
|
||||
name = "aws-smithy-wasm"
|
||||
version = "0.0.0-smithy-rs-head"
|
||||
authors = [
|
||||
"AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
|
||||
"Eduardo Rodrigues <16357187+eduardomourar@users.noreply.github.com>",
|
||||
]
|
||||
description = "Smithy WebAssembly configuration for smithy-rs."
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
repository = "https://github.com/awslabs/smithy-rs"
|
||||
|
||||
[target.'cfg(all(target_family = "wasm", target_os = "wasi"))'.dependencies]
|
||||
aws-smithy-client = { path = "../aws-smithy-client" }
|
||||
aws-smithy-http = { path = "../aws-smithy-http" }
|
||||
bytes = "1"
|
||||
http = "0.2.4"
|
||||
tower = { version = "0.4.8" }
|
||||
tracing = "0.1"
|
||||
wasi-preview2-prototype = { version = "0.0.3", features = ["http-client"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
# End of docs.rs metadata
|
|
@ -0,0 +1,175 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
|
@ -0,0 +1,7 @@
|
|||
# aws-smithy-wasm
|
||||
|
||||
WebAssembly related configuration for service clients generated by [smithy-rs](https://github.com/awslabs/smithy-rs).
|
||||
|
||||
<!-- anchor_start:footer -->
|
||||
This crate is part of the [AWS SDK for Rust](https://awslabs.github.io/aws-sdk-rust/) and the [smithy-rs](https://github.com/awslabs/smithy-rs) code generator. In most cases, it should not be used directly.
|
||||
<!-- anchor_end:footer -->
|
|
@ -0,0 +1,2 @@
|
|||
allowed_external_types = [
|
||||
]
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#![allow(clippy::derive_partial_eq_without_eq)]
|
||||
#![warn(
|
||||
missing_docs,
|
||||
rustdoc::missing_crate_level_docs,
|
||||
unreachable_pub,
|
||||
rust_2018_idioms
|
||||
)]
|
||||
|
||||
//! Smithy WebAssembly
|
||||
|
||||
#[cfg(all(target_family = "wasm", target_os = "wasi"))]
|
||||
pub mod wasi_adapter;
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
//! HTTP WASI Adapter
|
||||
|
||||
use aws_smithy_client::{erase::DynConnector, http_connector::HttpConnector};
|
||||
use aws_smithy_http::{body::SdkBody, result::ConnectorError};
|
||||
use bytes::Bytes;
|
||||
use http::{Request, Response};
|
||||
use std::{
|
||||
sync::Arc,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
use tower::Service;
|
||||
use wasi_preview2_prototype::http_client::DefaultClient;
|
||||
|
||||
/// Creates a connector function that can be used during instantiation of the client SDK
|
||||
/// in order to route the HTTP requests through the WebAssembly host. The host must
|
||||
/// support the WASI HTTP proposal as defined in the Preview 2 specification.
|
||||
pub fn wasi_connector() -> HttpConnector {
|
||||
HttpConnector::ConnectorFn(Arc::new(|_, _| Some(DynConnector::new(Adapter::default()))))
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
/// HTTP Service Adapter used in WASI environment
|
||||
pub struct Adapter {}
|
||||
|
||||
impl Service<Request<SdkBody>> for Adapter {
|
||||
type Response = 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 {
|
||||
tracing::trace!("adapter: sending request");
|
||||
let client = DefaultClient::new(None);
|
||||
// Right now only synchronous calls can be made through WASI
|
||||
let fut = client.handle(req.map(|body| match body.bytes() {
|
||||
Some(value) => Bytes::copy_from_slice(value),
|
||||
None => Bytes::new(),
|
||||
}));
|
||||
Box::pin(async move {
|
||||
let res = fut
|
||||
.map_err(|err| ConnectorError::other(err.into(), None))
|
||||
.expect("response from adapter");
|
||||
tracing::trace!("adapter: response received");
|
||||
let (parts, body) = res.into_parts();
|
||||
let loaded_body = if body.is_empty() {
|
||||
SdkBody::empty()
|
||||
} else {
|
||||
SdkBody::from(body)
|
||||
};
|
||||
Ok(http::Response::from_parts(parts, loaded_body))
|
||||
})
|
||||
}
|
||||
}
|
|
@ -15,9 +15,9 @@ RUN yum -y updateinfo
|
|||
FROM bare_base_image as musl_toolchain
|
||||
RUN yum -y install --allowerasing tar gzip gcc make
|
||||
RUN curl https://musl.libc.org/releases/musl-1.2.3.tar.gz -o musl-1.2.3.tar.gz \
|
||||
&& ls \
|
||||
&& tar xvzf musl-1.2.3.tar.gz \
|
||||
&& (cd musl-1.2.3 && ./configure && make install)
|
||||
&& ls \
|
||||
&& tar xvzf musl-1.2.3.tar.gz \
|
||||
&& (cd musl-1.2.3 && ./configure && make install)
|
||||
|
||||
#
|
||||
# Rust & Tools Installation Stage
|
||||
|
@ -48,11 +48,11 @@ RUN yum -y install --allowerasing \
|
|||
yum clean all
|
||||
RUN set -eux; \
|
||||
if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then \
|
||||
curl https://static.rust-lang.org/rustup/archive/1.24.3/aarch64-unknown-linux-gnu/rustup-init --output rustup-init; \
|
||||
echo "32a1532f7cef072a667bac53f1a5542c99666c4071af0c9549795bbdb2069ec1 rustup-init" | sha256sum --check; \
|
||||
curl https://static.rust-lang.org/rustup/archive/1.24.3/aarch64-unknown-linux-gnu/rustup-init --output rustup-init; \
|
||||
echo "32a1532f7cef072a667bac53f1a5542c99666c4071af0c9549795bbdb2069ec1 rustup-init" | sha256sum --check; \
|
||||
else \
|
||||
curl https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown-linux-gnu/rustup-init --output rustup-init; \
|
||||
echo "3dc5ef50861ee18657f9db2eeb7392f9c2a6c95c90ab41e45ab4ca71476b4338 rustup-init" | sha256sum --check; \
|
||||
curl https://static.rust-lang.org/rustup/archive/1.24.3/x86_64-unknown-linux-gnu/rustup-init --output rustup-init; \
|
||||
echo "3dc5ef50861ee18657f9db2eeb7392f9c2a6c95c90ab41e45ab4ca71476b4338 rustup-init" | sha256sum --check; \
|
||||
fi; \
|
||||
chmod +x rustup-init; \
|
||||
./rustup-init -y --no-modify-path --profile minimal --default-toolchain ${rust_stable_version}; \
|
||||
|
@ -77,9 +77,9 @@ ARG smithy_rs_commit_hash=main
|
|||
ARG checkout_smithy_rs_tools=false
|
||||
RUN set -eux; \
|
||||
if [[ "${checkout_smithy_rs_tools}" == "true" ]]; then \
|
||||
git clone https://github.com/awslabs/smithy-rs.git; \
|
||||
cd smithy-rs; \
|
||||
git checkout ${smithy_rs_commit_hash}; \
|
||||
git clone https://github.com/awslabs/smithy-rs.git; \
|
||||
cd smithy-rs; \
|
||||
git checkout ${smithy_rs_commit_hash}; \
|
||||
fi; \
|
||||
cargo install --locked --path tools/ci-build/publisher; \
|
||||
cargo install --locked --path tools/ci-build/changelogger; \
|
||||
|
@ -119,32 +119,24 @@ ARG wasm_pack_version=0.11.0
|
|||
RUN cargo 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
|
||||
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
|
||||
RUN cargo install cargo-wasi --locked --version ${cargo_wasi_version}
|
||||
ARG cargo_wasmtime_version=13.0.0
|
||||
ARG rust_nightly_version
|
||||
RUN cargo +${rust_nightly_version} install wasmtime-cli --features="component-model" --locked --version ${cargo_wasmtime_version}
|
||||
|
||||
FROM install_rust AS cargo_semver_checks
|
||||
ARG cargo_semver_checks_version=0.20.0
|
||||
ARG rust_nightly_version
|
||||
RUN cargo +${rust_nightly_version} -Z sparse-registry install cargo-semver-checks --locked --version ${cargo_semver_checks_version}
|
||||
RUN cargo +${rust_nightly_version} install cargo-semver-checks --locked --version ${cargo_semver_checks_version}
|
||||
|
||||
FROM install_rust AS cargo_mdbook
|
||||
ARG cargo_mdbook_version=0.4.30
|
||||
ARG rust_nightly_version
|
||||
RUN cargo +${rust_nightly_version} -Z sparse-registry install mdbook --locked --version ${cargo_mdbook_version}
|
||||
RUN cargo +${rust_nightly_version} install mdbook --locked --version ${cargo_mdbook_version}
|
||||
|
||||
FROM install_rust AS cargo_mdbook_mermaid
|
||||
ARG cargo_mdbook_mermaid_version=0.12.6
|
||||
ARG rust_nightly_version
|
||||
RUN cargo +${rust_nightly_version} -Z sparse-registry install mdbook-mermaid --locked --version ${cargo_mdbook_mermaid_version}
|
||||
RUN cargo +${rust_nightly_version} install mdbook-mermaid --locked --version ${cargo_mdbook_mermaid_version}
|
||||
|
||||
#
|
||||
# Final image
|
||||
|
@ -182,15 +174,13 @@ COPY --chown=build:build --from=cargo_minimal_versions /opt/cargo/bin/cargo-mini
|
|||
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=wasmtime /opt/cargo/bin/wasmtime /opt/cargo/bin/wasmtime
|
||||
COPY --chown=build:build --from=install_rust /opt/rustup /opt/rustup
|
||||
COPY --chown=build:build --from=cargo_semver_checks /opt/cargo/bin/cargo-semver-checks /opt/cargo/bin/cargo-semver-checks
|
||||
COPY --chown=build:build --from=cargo_mdbook /opt/cargo/bin/mdbook /opt/cargo/bin/mdbook
|
||||
COPY --chown=build:build --from=cargo_mdbook_mermaid /opt/cargo/bin/mdbook-mermaid /opt/cargo/bin/mdbook-mermaid
|
||||
COPY --chown=build:build --from=musl_toolchain /usr/local/musl/ /usr/local/musl/
|
||||
ENV PATH=$PATH:/usr/local/musl/bin/
|
||||
# TODO(Rust 1.70): The sparse registry config (`CARGO_REGISTRIES_CRATES_IO_PROTOCOL`) can be removed when upgrading to Rust 1.70
|
||||
ENV PATH=/opt/cargo/bin:$PATH \
|
||||
CARGO_HOME=/opt/cargo \
|
||||
RUSTUP_HOME=/opt/rustup \
|
||||
|
@ -198,7 +188,6 @@ ENV PATH=/opt/cargo/bin:$PATH \
|
|||
GRADLE_USER_HOME=/home/build/.gradle \
|
||||
RUST_STABLE_VERSION=${rust_stable_version} \
|
||||
RUST_NIGHTLY_VERSION=${rust_nightly_version} \
|
||||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \
|
||||
CARGO_INCREMENTAL=0 \
|
||||
RUSTDOCFLAGS="-D warnings" \
|
||||
RUSTFLAGS="-D warnings" \
|
||||
|
|
|
@ -45,6 +45,6 @@ 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
|
||||
# cargo test --target wasm32-wasi --no-default-features
|
||||
|
||||
popd &>/dev/null
|
||||
|
|
|
@ -39,4 +39,9 @@ find "${tmp_dir}"
|
|||
|
||||
pushd "${tmp_dir}/aws/sdk/integration-tests"
|
||||
cargo check --tests
|
||||
|
||||
# Running WebAssembly (WASI) specific integration tests
|
||||
pushd "${tmp_dir}/aws/sdk/integration-tests/webassembly" &>/dev/null
|
||||
cargo check --tests
|
||||
RUST_TEST_NOCAPTURE=1 cargo test
|
||||
popd
|
||||
|
|
Loading…
Reference in New Issue