From 6325c8a277225e786920d42df935371d27b11fc4 Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Wed, 15 Dec 2021 18:40:51 -0800 Subject: [PATCH] Move additional-ci step into SDK smoke test (#961) * Move additional-ci step into SDK smoke test * Add `cargo hack` test to `aws-config` and make it pass * Fix warning introduced by merge * Incorporate feedback * Fix native-tls example --- .github/workflows/ci-sdk.yaml | 72 +++++++++---------- .github/workflows/ci.yaml | 5 +- CHANGELOG.next.toml | 10 +++ aws/rust-runtime/aws-config/Cargo.toml | 24 +++---- aws/rust-runtime/aws-config/additional-ci | 18 +++++ aws/rust-runtime/aws-config/examples/imds.rs | 7 +- .../aws-config/src/default_provider.rs | 15 ++-- aws/rust-runtime/aws-config/src/ecs.rs | 17 +++-- .../aws-config/src/imds/client.rs | 12 +++- aws/rust-runtime/aws-config/src/lib.rs | 12 ++-- .../aws-config/src/meta/credentials/chain.rs | 3 + .../src/meta/credentials/lazy_caching.rs | 2 +- .../aws-config/src/meta/credentials/mod.rs | 2 - .../aws-config/src/meta/region.rs | 5 ++ .../aws-config/src/profile/app_name.rs | 2 +- .../aws-config/src/profile/credentials.rs | 4 +- .../src/profile/credentials/exec.rs | 2 +- .../aws-config/src/profile/region.rs | 2 +- .../aws-config/src/provider_config.rs | 3 +- aws/rust-runtime/aws-config/src/sts.rs | 15 ++-- aws/rust-runtime/aws-config/src/test_case.rs | 16 ++--- .../aws-config/src/web_identity_token.rs | 5 +- .../Cargo.toml | 2 +- rust-runtime/aws-smithy-async/additional-ci | 3 + .../aws-smithy-eventstream/additional-ci | 9 +-- 25 files changed, 155 insertions(+), 112 deletions(-) create mode 100755 aws/rust-runtime/aws-config/additional-ci diff --git a/.github/workflows/ci-sdk.yaml b/.github/workflows/ci-sdk.yaml index acf6cd166..4a806778b 100644 --- a/.github/workflows/ci-sdk.yaml +++ b/.github/workflows/ci-sdk.yaml @@ -55,19 +55,22 @@ jobs: name: Smoke Test needs: generate-smoke-test runs-on: ubuntu-latest + # To avoid repeating setup boilerplate, we have the actual test commands + # in a matrix strategy. These commands get run in the steps after all of the setup. strategy: fail-fast: false matrix: test: - name: Unit Tests run: cargo test $(cat service-with-tests) - working-directory: aws-sdk - name: Docs run: cargo doc --no-deps --document-private-items - working-directory: aws-sdk - name: Clippy run: cargo clippy - working-directory: aws-sdk + - name: Unused Dependencies + run: cargo +nightly udeps + - name: Additional per-crate checks + run: ../tools/additional-per-crate-checks.sh ./sdk/ env: # Disable incremental compilation to reduce disk space use CARGO_INCREMENTAL: 0 @@ -76,11 +79,29 @@ jobs: # so we have to manually restore the target directory override CARGO_TARGET_DIR: ../target steps: + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: ${{ env.rust_version }} components: ${{ env.rust_toolchain_components }} default: true + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + default: false + - name: Cache cargo bin + uses: actions/cache@v2 + with: + path: ~/.cargo/bin + key: ${{ github.job }}-${{ runner.os }}-${{ env.rust_version }} + - name: Install additional cargo binaries + run: | + if [[ ! -f ~/.cargo/bin/cargo-udeps ]]; then + cargo +nightly install cargo-udeps + fi + if [[ ! -f ~/.cargo/bin/cargo-hack ]]; then + cargo install cargo-hack + fi - name: Generate a name for the SDK id: gen-name run: echo "name=${GITHUB_REF##*/}" >> $GITHUB_ENV @@ -96,47 +117,20 @@ jobs: with: sharedKey: ${{ runner.os }}-${{ env.rust_version }}-${{ github.job }} target-dir: ../target + # This runs the commands from the matrix strategy - name: ${{ matrix.test.name }} run: ${{ matrix.test.run }} - working-directory: ${{ matrix.test.working-directory }} + working-directory: aws-sdk - unused-sdk-dependencies: - name: Smoke Test - Unused dependencies - needs: generate-smoke-test + # Psuedo-job that depends on the smoke-test job so that we don't have to enter + # the myriad of test matrix combinations into GitHub's protected branch rules + require-smoke-tests: + needs: smoke-test runs-on: ubuntu-latest + name: Smoke Test Matrix Success steps: - # Pinned to the commit hash of v1.3.0 - - uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641 - with: - sharedKey: ${{ runner.os }}-${{ github.job }} - target-dir: ../target - - uses: actions-rs/toolchain@v1 - with: - # Cargo udeps requires nightly - toolchain: nightly - default: true - - name: Generate a name for the SDK - id: gen-name - run: echo "name=${GITHUB_REF##*/}" >> $GITHUB_ENV - - uses: actions/download-artifact@v2 - name: Download SDK Artifact - with: - name: aws-sdk-${{ env.name }}-smoketest-${{ github.sha }} - path: artifact - - name: untar - run: mkdir aws-sdk && cd aws-sdk && tar -xvf ../artifact/sdk.tar - - name: Install `cargo udeps` - run: cargo install cargo-udeps - - name: Check for unused dependencies with default features - run: cargo udeps - working-directory: aws-sdk - - name: Check for unused dependencies with `--all-features` - run: cargo udeps --all-features - working-directory: aws-sdk - env: - # Note: the .cargo/config.toml is lost because we untar the SDK rather than checking out the repo, - # so we have to manually restore the target directory override - CARGO_TARGET_DIR: ../target + - name: Run + run: echo "We should only get this far if the smoke-test matrix succeeded." standalone-integration-tests-check: name: Standalone Integration Tests - cargo check diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9e221a5be..561d6dfea 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,6 +33,8 @@ jobs: codegen-tests: name: Codegen Tests runs-on: ubuntu-latest + # To avoid repeating setup boilerplate, we have the actual test commands + # in a matrix strategy. These commands get run in the steps after all of the setup. strategy: fail-fast: false matrix: @@ -74,6 +76,7 @@ jobs: uses: actions/setup-java@v1 with: java-version: ${{ env.java_version }} + # This runs the commands from the matrix strategy - name: ${{ matrix.test.name }} run: ${{ matrix.test.run }} @@ -113,5 +116,3 @@ jobs: working-directory: ${{ matrix.runtime }}/rust-runtime/ env: RUSTDOCFLAGS: -D warnings - - name: Additional per-crate checks - run: ./tools/additional-per-crate-checks.sh ${{ matrix.runtime }}/rust-runtime/ diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 72d79628e..fa75bca0f 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -10,3 +10,13 @@ # references = ["smithy-rs#920"] # meta = { "breaking" = false, "tada" = false, "bug" = false } # author = "rcoh" + +[[aws-sdk-rust]] +message = """ +The `meta`, `environment`, and `dns` Cargo feature flags were removed from `aws-config`. +The code behind the `dns` flag is now enabled when `rt-tokio` is enabled. The code behind +the `meta` and `environment` flags is always enabled now. +""" +references = ["smithy-rs#961"] +meta = { "breaking" = true, "tada" = false, "bug" = false } +author = "jdisanti" diff --git a/aws/rust-runtime/aws-config/Cargo.toml b/aws/rust-runtime/aws-config/Cargo.toml index 96edf3ae0..5ecd8d154 100644 --- a/aws/rust-runtime/aws-config/Cargo.toml +++ b/aws/rust-runtime/aws-config/Cargo.toml @@ -9,27 +9,19 @@ license = "Apache-2.0" repository = "https://github.com/awslabs/smithy-rs" [features] -default-provider = ["profile", "imds", "meta", "sts", "environment", "http-provider"] -profile = ["sts", "web-identity-token", "meta", "environment", "imds", "http-provider"] -meta = ["tokio/sync"] -imds = ["profile", "aws-smithy-http/rt-tokio", "aws-smithy-http-tower", "aws-smithy-json", "tower", "aws-http", "meta"] -environment = ["meta"] -sts = ["aws-sdk-sts"] +default-provider = ["profile", "imds", "sts", "http-provider"] +profile = ["sts", "web-identity-token", "imds", "http-provider"] +imds = ["profile", "aws-smithy-http/rt-tokio", "aws-smithy-http-tower", "aws-smithy-json", "tower", "aws-http"] +sts = ["aws-sdk-sts", "aws-smithy-http"] web-identity-token = ["sts", "profile"] http-provider = ["aws-smithy-json", "aws-smithy-http/rt-tokio", "tower", "tokio/sync"] tcp-connector = ["tokio/net", "tower"] -# SSO is not supported -sso = [] - rustls = ["aws-smithy-client/rustls"] native-tls = ["aws-smithy-client/native-tls"] rt-tokio = ["aws-smithy-async/rt-tokio"] -# Tokio based DNS-resolver for ECS validation -dns = ["tokio/rt"] - -default = ["default-provider", "rustls", "rt-tokio", "dns", "tcp-connector"] +default = ["default-provider", "rustls", "rt-tokio", "tcp-connector"] [dependencies] aws-sdk-sts = { path = "../../sdk/build/aws-sdk/sdk/sts", default-features = false, optional = true } @@ -37,7 +29,7 @@ aws-smithy-async = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-async" } aws-smithy-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-client" } aws-smithy-types = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-types" } aws-types = { path = "../../sdk/build/aws-sdk/sdk/aws-types" } -tokio = { version = "1", features = ["sync"], optional = true } +tokio = { version = "1", features = ["sync"] } tracing = { version = "0.1" } # imds @@ -72,3 +64,7 @@ all-features = true targets = ["x86_64-unknown-linux-gnu"] rustdoc-args = ["--cfg", "docsrs"] # End of docs.rs metadata + +[[example]] +name = "imds" +required-features = ["imds"] diff --git a/aws/rust-runtime/aws-config/additional-ci b/aws/rust-runtime/aws-config/additional-ci new file mode 100755 index 000000000..22616ac6d --- /dev/null +++ b/aws/rust-runtime/aws-config/additional-ci @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0. +# + +# This script contains additional CI checks to run for this specific package + +set -e + +echo "### Checking for duplicate dependency versions in the normal dependency graph with all features enabled" +cargo tree -d --edges normal --all-features + +echo "### Testing with all features enabled" +cargo test --all-features + +echo "### Testing each feature in isolation" +cargo hack test --each-feature --skip default diff --git a/aws/rust-runtime/aws-config/examples/imds.rs b/aws/rust-runtime/aws-config/examples/imds.rs index 855d1d724..3c6653df5 100644 --- a/aws/rust-runtime/aws-config/examples/imds.rs +++ b/aws/rust-runtime/aws-config/examples/imds.rs @@ -3,16 +3,15 @@ * SPDX-License-Identifier: Apache-2.0. */ -use aws_config::imds::Client; -use std::error::Error; - /// IMDSv2 client usage example /// /// The IMDS client is used with `aws-config` to load credentials and regions, however, you can also /// use the client directly. This example demonstrates loading the instance-id from IMDS. More /// fetures of IMDS can be found [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) #[tokio::main] -async fn main() -> Result<(), Box> { +async fn main() -> Result<(), Box> { + use aws_config::imds::Client; + let imds = Client::builder().build().await?; let instance_id = imds.get("/latest/meta-data/instance-id").await?; println!("current instance id: {}", instance_id); diff --git a/aws/rust-runtime/aws-config/src/default_provider.rs b/aws/rust-runtime/aws-config/src/default_provider.rs index 94360ca6e..1dadef8cb 100644 --- a/aws/rust-runtime/aws-config/src/default_provider.rs +++ b/aws/rust-runtime/aws-config/src/default_provider.rs @@ -597,18 +597,14 @@ pub mod credentials { use tracing_test::traced_test; use aws_smithy_types::retry::{RetryConfig, RetryMode}; - use aws_types::credentials::{CredentialsError, ProvideCredentials}; - use aws_types::os_shim_internal::{Env, Fs, TimeSource}; + use aws_types::credentials::ProvideCredentials; + use aws_types::os_shim_internal::{Env, Fs}; use crate::default_provider::credentials::DefaultCredentialsChain; use crate::default_provider::retry_config; use crate::provider_config::ProviderConfig; use crate::test_case::TestEnvironment; - use aws_smithy_async::rt::sleep::TokioSleep; - use aws_smithy_client::erase::boxclone::BoxCloneService; - use aws_smithy_client::never::NeverConnected; - /// Test generation macro /// /// # Examples @@ -701,7 +697,14 @@ pub mod credentials { #[tokio::test] #[traced_test] + #[cfg(feature = "tcp-connector")] async fn no_providers_configured_err() { + use aws_smithy_async::rt::sleep::TokioSleep; + use aws_smithy_client::erase::boxclone::BoxCloneService; + use aws_smithy_client::never::NeverConnected; + use aws_types::credentials::CredentialsError; + use aws_types::os_shim_internal::TimeSource; + tokio::time::pause(); let conf = ProviderConfig::no_configuration() .with_tcp_connector(BoxCloneService::new(NeverConnected::new())) diff --git a/aws/rust-runtime/aws-config/src/ecs.rs b/aws/rust-runtime/aws-config/src/ecs.rs index b5a428937..d6942398f 100644 --- a/aws/rust-runtime/aws-config/src/ecs.rs +++ b/aws/rust-runtime/aws-config/src/ecs.rs @@ -49,11 +49,9 @@ use std::error::Error; use std::fmt::{Display, Formatter}; use std::io; -use std::io::ErrorKind; -use std::net::{IpAddr, ToSocketAddrs}; -use std::task::{Context, Poll}; +use std::net::IpAddr; -use aws_smithy_client::erase::boxclone::{BoxCloneService, BoxFuture}; +use aws_smithy_client::erase::boxclone::BoxCloneService; use aws_smithy_http::endpoint::Endpoint; use aws_types::credentials; use aws_types::credentials::{future, CredentialsError, ProvideCredentials}; @@ -391,7 +389,7 @@ async fn validate_full_uri(uri: &str, dns: &mut DnsService) -> Result Option { None } @@ -399,8 +397,13 @@ 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 = "dns")] +#[cfg(feature = "rt-tokio")] fn tokio_dns() -> Option { + use aws_smithy_client::erase::boxclone::BoxFuture; + use std::io::ErrorKind; + use std::net::ToSocketAddrs; + use std::task::{Context, Poll}; + #[derive(Clone)] struct TokioDns; impl Service for TokioDns { @@ -428,7 +431,7 @@ fn tokio_dns() -> Option { Some(BoxCloneService::new(TokioDns)) } -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod test { use aws_smithy_client::erase::boxclone::BoxCloneService; use aws_smithy_client::never::NeverService; diff --git a/aws/rust-runtime/aws-config/src/imds/client.rs b/aws/rust-runtime/aws-config/src/imds/client.rs index a8d91333e..2926402ff 100644 --- a/aws/rust-runtime/aws-config/src/imds/client.rs +++ b/aws/rust-runtime/aws-config/src/imds/client.rs @@ -457,9 +457,11 @@ impl Builder { /// /// # Examples /// ```no_run - /// use aws_config::imds::Client; + /// # #[cfg(feature = "default-provider")] /// # async fn test() { + /// use aws_config::imds::Client; /// use aws_config::provider_config::ProviderConfig; + /// /// let provider = Client::builder() /// .configure(&ProviderConfig::with_default_region().await) /// .build(); @@ -721,7 +723,7 @@ impl ClassifyResponse, SdkError> for ImdsErrorPolicy { pub(crate) mod test { use std::collections::HashMap; use std::error::Error; - use std::time::{Duration, SystemTime, UNIX_EPOCH}; + use std::time::{Duration, UNIX_EPOCH}; use aws_smithy_async::rt::sleep::TokioSleep; use aws_smithy_client::erase::DynConnector; @@ -732,7 +734,7 @@ pub(crate) mod test { use serde::Deserialize; use tracing_test::traced_test; - use crate::imds::client::{Client, EndpointMode, ImdsError}; + use crate::imds::client::{Client, EndpointMode}; use crate::provider_config::ProviderConfig; use http::header::USER_AGENT; @@ -1011,7 +1013,11 @@ pub(crate) mod test { /// Verify that the end-to-end real client has a 1-second connect timeout #[tokio::test] + #[cfg(any(feature = "rustls", feature = "native-tls"))] async fn one_second_connect_timeout() { + use crate::imds::client::ImdsError; + use std::time::SystemTime; + let client = Client::builder() // 240.* can never be resolved .endpoint(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 7240b8166..1d0ba6b33 100644 --- a/aws/rust-runtime/aws-config/src/lib.rs +++ b/aws/rust-runtime/aws-config/src/lib.rs @@ -14,14 +14,17 @@ //! an AWS service client. //! //! # Examples +//! //! Load default SDK configuration: //! ```no_run +//! # #[cfg(feature = "default-provider")] //! # mod aws_sdk_dynamodb { //! # pub struct Client; //! # impl Client { //! # pub fn new(config: &aws_types::config::Config) -> Self { Client } //! # } //! # } +//! # #[cfg(feature = "default-provider")] //! # async fn docs() { //! let config = aws_config::load_from_env().await; //! let client = aws_sdk_dynamodb::Client::new(&config); @@ -30,14 +33,16 @@ //! //! Load SDK configuration with a region override: //! ```no_run -//! use aws_config::meta::region::RegionProviderChain; +//! # #[cfg(feature = "default-provider")] //! # mod aws_sdk_dynamodb { //! # pub struct Client; //! # impl Client { //! # pub fn new(config: &aws_types::config::Config) -> Self { Client } //! # } //! # } +//! # #[cfg(feature = "default-provider")] //! # async fn docs() { +//! # use aws_config::meta::region::RegionProviderChain; //! let region_provider = RegionProviderChain::default_provider().or_else("us-east-1"); //! let config = aws_config::from_env().region(region_provider).load().await; //! let client = aws_sdk_dynamodb::Client::new(&config); @@ -51,12 +56,10 @@ const PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); #[cfg(feature = "default-provider")] pub mod default_provider; -#[cfg(feature = "environment")] /// Providers that load configuration from environment variables pub mod environment; /// Meta-providers that augment existing providers with new behavior -#[cfg(feature = "meta")] pub mod meta; #[cfg(feature = "profile")] @@ -65,7 +68,7 @@ pub mod profile; #[cfg(feature = "sts")] pub mod sts; -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod test_case; #[cfg(feature = "web-identity-token")] @@ -76,7 +79,6 @@ pub mod ecs; pub mod provider_config; -#[cfg(any(feature = "meta", feature = "default-provider"))] mod cache; #[cfg(feature = "imds")] diff --git a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs index a9c7482cc..e6ef8f38d 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs @@ -21,12 +21,15 @@ use tracing::Instrument; /// # Examples /// /// ```no_run +/// # #[cfg(feature = "profile")] +/// # fn example() { /// use aws_config::meta::credentials::CredentialsProviderChain; /// use aws_config::environment::credentials::EnvironmentVariableCredentialsProvider; /// use aws_config::profile::ProfileFileCredentialsProvider; /// /// let provider = CredentialsProviderChain::first_try("Environment", EnvironmentVariableCredentialsProvider::new()) /// .or_else("Profile", ProfileFileCredentialsProvider::builder().build()); +/// # } /// ``` #[derive(Debug)] pub struct CredentialsProviderChain { diff --git a/aws/rust-runtime/aws-config/src/meta/credentials/lazy_caching.rs b/aws/rust-runtime/aws-config/src/meta/credentials/lazy_caching.rs index 084aed3ff..25c330d37 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/lazy_caching.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/lazy_caching.rs @@ -411,7 +411,7 @@ mod tests { TimeSource::manual(&time), Arc::new(TokioSleep::new()), Arc::new(provide_credentials_fn(|| async { - tokio::time::sleep(Duration::from_millis(10)).await; + aws_smithy_async::future::never::Never::new().await; Ok(credentials(1000)) })), Duration::from_millis(5), diff --git a/aws/rust-runtime/aws-config/src/meta/credentials/mod.rs b/aws/rust-runtime/aws-config/src/meta/credentials/mod.rs index 2969585c9..8f5e504e4 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/mod.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/mod.rs @@ -11,7 +11,5 @@ pub use chain::CredentialsProviderChain; mod credential_fn; pub use credential_fn::provide_credentials_fn; -#[cfg(any(feature = "meta", feature = "default-provider"))] pub mod lazy_caching; -#[cfg(any(feature = "meta", feature = "default-provider"))] pub use lazy_caching::LazyCachingCredentialsProvider; diff --git a/aws/rust-runtime/aws-config/src/meta/region.rs b/aws/rust-runtime/aws-config/src/meta/region.rs index f064122fc..346b4859c 100644 --- a/aws/rust-runtime/aws-config/src/meta/region.rs +++ b/aws/rust-runtime/aws-config/src/meta/region.rs @@ -13,15 +13,20 @@ use tracing::Instrument; /// Load a region by selecting the first from a series of region providers. /// /// # Examples +/// /// ```no_run +/// # #[cfg(feature = "default-provider")] +/// # fn example() { /// use aws_types::region::Region; /// use std::env; /// use aws_config::meta::region::RegionProviderChain; +/// /// // region provider that first checks the `CUSTOM_REGION` environment variable, /// // then checks the default provider chain, then falls back to us-east-2 /// let provider = RegionProviderChain::first_try(env::var("CUSTOM_REGION").ok().map(Region::new)) /// .or_default_provider() /// .or_else(Region::new("us-east-2")); +/// # } /// ``` #[derive(Debug)] pub struct RegionProviderChain { diff --git a/aws/rust-runtime/aws-config/src/profile/app_name.rs b/aws/rust-runtime/aws-config/src/profile/app_name.rs index 563fd61db..121efef1d 100644 --- a/aws/rust-runtime/aws-config/src/profile/app_name.rs +++ b/aws/rust-runtime/aws-config/src/profile/app_name.rs @@ -109,7 +109,7 @@ impl Builder { } } -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod tests { use super::ProfileFileAppNameProvider; use crate::provider_config::ProviderConfig; diff --git a/aws/rust-runtime/aws-config/src/profile/credentials.rs b/aws/rust-runtime/aws-config/src/profile/credentials.rs index 0790ed80b..c9c7cc7e2 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials.rs @@ -336,7 +336,9 @@ impl Builder { /// Override the configuration for the [`ProfileFileCredentialsProvider`] /// /// # Examples + /// /// ```no_run + /// # #[cfg(feature = "default-provider")] /// # async fn test() { /// use aws_config::profile::ProfileFileCredentialsProvider; /// use aws_config::provider_config::ProviderConfig; @@ -462,7 +464,7 @@ async fn build_provider_chain( exec::ProviderChain::from_repr(fs.clone(), connector, region.region().await, repr, factory) } -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod test { use tracing_test::traced_test; 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 b65b11c3e..c98dc101a 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials/exec.rs @@ -174,7 +174,7 @@ pub mod named { } } -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod test { use crate::profile::credentials::exec::named::NamedProviderFactory; use crate::profile::credentials::exec::ProviderChain; diff --git a/aws/rust-runtime/aws-config/src/profile/region.rs b/aws/rust-runtime/aws-config/src/profile/region.rs index 3a2f5f91c..09605dd9d 100644 --- a/aws/rust-runtime/aws-config/src/profile/region.rs +++ b/aws/rust-runtime/aws-config/src/profile/region.rs @@ -109,7 +109,7 @@ impl ProvideRegion for ProfileFileRegionProvider { } } -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod test { use crate::profile::ProfileFileRegionProvider; use crate::provider_config::ProviderConfig; diff --git a/aws/rust-runtime/aws-config/src/provider_config.rs b/aws/rust-runtime/aws-config/src/provider_config.rs index 4a8452df2..dd81e25b1 100644 --- a/aws/rust-runtime/aws-config/src/provider_config.rs +++ b/aws/rust-runtime/aws-config/src/provider_config.rs @@ -146,12 +146,13 @@ impl ProviderConfig { /// /// # Examples /// ```no_run + /// # #[cfg(all(feature = "default-provider", any(feature = "rustls", feature = "native-tls")))] + /// # fn example() { /// use aws_config::provider_config::ProviderConfig; /// use aws_sdk_sts::Region; /// use aws_config::web_identity_token::WebIdentityTokenCredentialsProvider; /// let conf = ProviderConfig::without_region().with_region(Some(Region::new("us-east-1"))); /// - /// # if cfg!(any(feature = "rustls", feature = "native-tls")) { /// let credential_provider = WebIdentityTokenCredentialsProvider::builder().configure(&conf).build(); /// # } /// ``` diff --git a/aws/rust-runtime/aws-config/src/sts.rs b/aws/rust-runtime/aws-config/src/sts.rs index e10d0c6e3..c4a4f39a3 100644 --- a/aws/rust-runtime/aws-config/src/sts.rs +++ b/aws/rust-runtime/aws-config/src/sts.rs @@ -7,14 +7,19 @@ mod assume_role; -use crate::connector::expect_connector; -use crate::provider_config::{HttpSettings, ProviderConfig}; pub use assume_role::{AssumeRoleProvider, AssumeRoleProviderBuilder}; + +#[cfg(feature = "profile")] use aws_sdk_sts::middleware::DefaultMiddleware; -use aws_smithy_client::erase::DynConnector; -impl ProviderConfig { - pub(crate) fn sdk_client(&self) -> aws_smithy_client::Client { +#[cfg(feature = "profile")] +impl crate::provider_config::ProviderConfig { + pub(crate) fn sdk_client( + &self, + ) -> aws_smithy_client::Client { + use crate::connector::expect_connector; + use crate::provider_config::HttpSettings; + aws_smithy_client::Builder::<(), DefaultMiddleware>::new() .connector(expect_connector(self.connector(&HttpSettings::default()))) .sleep_impl(self.sleep()) diff --git a/aws/rust-runtime/aws-config/src/test_case.rs b/aws/rust-runtime/aws-config/src/test_case.rs index dd262761e..f4b84caf9 100644 --- a/aws/rust-runtime/aws-config/src/test_case.rs +++ b/aws/rust-runtime/aws-config/src/test_case.rs @@ -3,23 +3,19 @@ * SPDX-License-Identifier: Apache-2.0. */ -use std::collections::HashMap; -use std::error::Error; -use std::path::{Path, PathBuf}; - -use std::time::{Duration, UNIX_EPOCH}; - use crate::provider_config::{HttpSettings, ProviderConfig}; use aws_smithy_async::rt::sleep::{AsyncSleep, Sleep, TokioSleep}; +use aws_smithy_client::dvr::{NetworkTraffic, RecordingConnection, ReplayingConnection}; +use aws_smithy_client::erase::DynConnector; use aws_types::credentials::{self, ProvideCredentials}; use aws_types::os_shim_internal::{Env, Fs}; use serde::Deserialize; - -use aws_smithy_client::dvr::{NetworkTraffic, RecordingConnection, ReplayingConnection}; -use aws_smithy_client::erase::DynConnector; - +use std::collections::HashMap; +use std::error::Error; use std::fmt::Debug; use std::future::Future; +use std::path::{Path, PathBuf}; +use std::time::{Duration, UNIX_EPOCH}; /// Test case credentials /// diff --git a/aws/rust-runtime/aws-config/src/web_identity_token.rs b/aws/rust-runtime/aws-config/src/web_identity_token.rs index 5cf0fd13a..ed6acaf3c 100644 --- a/aws/rust-runtime/aws-config/src/web_identity_token.rs +++ b/aws/rust-runtime/aws-config/src/web_identity_token.rs @@ -52,6 +52,7 @@ //! load configuration from environment variables. //! //! ```no_run +//! # #[cfg(feature = "default-provider")] //! # async fn test() { //! use aws_config::web_identity_token::WebIdentityTokenCredentialsProvider; //! use aws_config::provider_config::ProviderConfig; @@ -60,6 +61,7 @@ //! .build(); //! # } //! ``` + use aws_sdk_sts::Region; use aws_types::os_shim_internal::{Env, Fs}; @@ -180,6 +182,7 @@ impl Builder { /// /// # Examples /// ```no_run + /// # #[cfg(feature = "default-provider")] /// # async fn test() { /// use aws_config::web_identity_token::WebIdentityTokenCredentialsProvider; /// use aws_config::provider_config::ProviderConfig; @@ -256,7 +259,7 @@ async fn load_credentials( sts::util::into_credentials(resp.credentials, "WebIdentityToken") } -#[cfg(test)] +#[cfg(all(test, feature = "default-provider"))] mod test { use crate::web_identity_token::{ Builder, ENV_VAR_ROLE_ARN, ENV_VAR_SESSION_NAME, ENV_VAR_TOKEN_FILE, diff --git a/aws/sdk/examples/using_native_tls_instead_of_rustls/Cargo.toml b/aws/sdk/examples/using_native_tls_instead_of_rustls/Cargo.toml index e9a9eac52..7238a97d6 100644 --- a/aws/sdk/examples/using_native_tls_instead_of_rustls/Cargo.toml +++ b/aws/sdk/examples/using_native_tls_instead_of_rustls/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] # aws-config pulls in rustls and several other things by default. We have to disable defaults in order to use native-tls # and then manually bring the other defaults back -aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = ["default-provider", "native-tls", "rt-tokio", "dns", "tcp-connector"] } +aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = ["default-provider", "native-tls", "rt-tokio", "tcp-connector"] } # aws-sdk-s3 brings in rustls by default so we disable that in order to use native-tls only aws-sdk-s3 = { package = "aws-sdk-s3", path = "../../build/aws-sdk/sdk/s3", default-features = false, features = ["native-tls"] } # aws-sdk-sts is the same as aws-sdk-s3 diff --git a/rust-runtime/aws-smithy-async/additional-ci b/rust-runtime/aws-smithy-async/additional-ci index 3e9c539b6..29abdfad1 100755 --- a/rust-runtime/aws-smithy-async/additional-ci +++ b/rust-runtime/aws-smithy-async/additional-ci @@ -10,3 +10,6 @@ set -e echo "### Checking for duplicate dependency versions in the normal dependency graph with all features enabled" cargo tree -d --edges normal --all-features + +echo "### Checking each feature" +cargo hack test --feature-powerset diff --git a/rust-runtime/aws-smithy-eventstream/additional-ci b/rust-runtime/aws-smithy-eventstream/additional-ci index acefdfb55..29abdfad1 100755 --- a/rust-runtime/aws-smithy-eventstream/additional-ci +++ b/rust-runtime/aws-smithy-eventstream/additional-ci @@ -11,10 +11,5 @@ set -e echo "### Checking for duplicate dependency versions in the normal dependency graph with all features enabled" cargo tree -d --edges normal --all-features -FEATURES=( - "derive-arbitrary" -) -for feature in "${FEATURES[@]}"; do - echo "### Checking feature '${feature}'..." - cargo test --no-default-features --features "${feature}" -done +echo "### Checking each feature" +cargo hack test --feature-powerset -- GitLab