Unverified Commit 39e33163 authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Take SDK examples from `awsdocs/aws-doc-sdk-examples` (#1118)

* Split SDK service checks from example checks

* Delete examples

* Take examples from `aws-doc-sdk-examples`

* Fix example checkout

* Fix example manifests after relocation

* Update changelog
parent eb0581ab
Loading
Loading
Loading
Loading
+68 −3
Original line number Diff line number Diff line
@@ -171,11 +171,15 @@ jobs:
        RUSTC_FORCE_INCREMENTAL: 1
        RUSTFLAGS: -D warnings

  all-services-check:
    name: Full SDK - Generate and cargo check
  generate-all-services:
    name: Full SDK - Generate
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/checkout@v2
      with:
        repository: awsdocs/aws-doc-sdk-examples
        path: aws-doc-sdk-examples
    - uses: actions/cache@v2
      name: Gradle Cache
      with:
@@ -194,8 +198,13 @@ jobs:
      uses: actions/setup-java@v1
      with:
        java-version: ${{ env.java_version }}
    - name: Take examples from `awsdocs/aws-doc-sdk-examples`
      run: |
        mv aws-doc-sdk-examples/rust_dev_preview aws/sdk/examples
        rm -rf aws/sdk/examples/.cargo
        rm aws/sdk/examples/Cargo.toml
    - name: Generate and check all services
      run: ./gradlew -Paws.fullsdk=true :aws:sdk:cargoCheck
      run: ./gradlew -Paws.fullsdk=true :aws:sdk:assemble
    - name: Generate a name for the SDK
      id: gen-name
      run: echo "name=${GITHUB_REF##*/}" >> $GITHUB_ENV
@@ -206,3 +215,59 @@ jobs:
      with:
        name: aws-sdk-${{ env.name }}-${{ github.sha }}
        path: sdk.tar

  check-all-examples:
    name: Full SDK - Check examples
    runs-on: ubuntu-latest
    needs: generate-all-services
    env:
      # Disable incremental compilation to reduce disk space use
      CARGO_INCREMENTAL: 0
      RUSTFLAGS: -D warnings
    steps:
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ env.rust_version }}
        components: ${{ env.rust_toolchain_components }}
        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 }}-${{ github.sha }}
        path: artifact
    - name: untar
      run: tar -xvf ./artifact/sdk.tar
    - name: Check the SDK
      run: cargo check
      working-directory: ./examples

  check-all-services:
    name: Full SDK - Check services
    runs-on: ubuntu-latest
    needs: generate-all-services
    env:
      # Disable incremental compilation to reduce disk space use
      CARGO_INCREMENTAL: 0
      RUSTFLAGS: -D warnings
    steps:
    - uses: actions-rs/toolchain@v1
      with:
        toolchain: ${{ env.rust_version }}
        components: ${{ env.rust_toolchain_components }}
        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 }}-${{ github.sha }}
        path: artifact
    - name: untar
      run: tar -xvf ./artifact/sdk.tar
    - name: Check the SDK
      run: cargo check
      working-directory: ./sdk
+13 −1
Original line number Diff line number Diff line
@@ -22,3 +22,15 @@ message = "Improve docs on `Endpoint::{mutable, immutable}`"
references = ["smithy-rs#1087"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "rcoh"

[[aws-sdk-rust]]
message = "SDK examples now come from [`awsdocs/aws-doc-sdk-examples`](https://github.com/awsdocs/aws-doc-sdk-examples) rather than from `smithy-rs`"
references = ["smithy-rs#1118"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "jdisanti"

[[smithy-rs]]
message = "SDK examples now come from [`awsdocs/aws-doc-sdk-examples`](https://github.com/awsdocs/aws-doc-sdk-examples) rather than from `smithy-rs`"
references = ["smithy-rs#1118"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "jdisanti"
+29 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)

val publisherToolPath = rootProject.projectDir.resolve("tools/publisher")
val sdkVersionerToolPath = rootProject.projectDir.resolve("tools/sdk-versioner")
val outputDir = buildDir.resolve("aws-sdk")
val sdkOutputDir = outputDir.resolve("sdk")
val examplesOutputDir = outputDir.resolve("examples")
@@ -50,6 +51,7 @@ val awsServices: AwsServices by lazy { discoverServices(loadServiceMembership())
val eventStreamAllowList: Set<String> by lazy { eventStreamAllowList() }

fun getSdkVersion(): String = properties.get("aws.sdk.version") ?: throw kotlin.Exception("SDK version missing")
fun getSmithyRsVersion(): String = properties.get("smithy.rs.runtime.crate.version") ?: throw kotlin.Exception("smithy-rs version missing")
fun getRustMSRV(): String = properties.get("rust.msrv") ?: throw kotlin.Exception("Rust MSRV missing")

fun loadServiceMembership(): Membership {
@@ -179,8 +181,30 @@ task("relocateExamples") {
            }
        }
    }
    if (awsServices.examples.isNotEmpty()) {
        inputs.dir(projectDir.resolve("examples"))
    }
    outputs.dir(outputDir)
}

task("fixExampleManifests") {
    description = "Adds dependency path and corrects version number of examples after relocation"
    doLast {
        if (awsServices.examples.isNotEmpty()) {
            exec {
                workingDir(sdkVersionerToolPath)
                commandLine(
                    "cargo", "run", "--",
                    outputDir.resolve("examples").absolutePath,
                    "--sdk-path", "../../sdk",
                    "--sdk-version", getSdkVersion(),
                    "--smithy-version", getSmithyRsVersion()
                )
            }
        }
    }
    outputs.dir(outputDir)
    dependsOn("relocateExamples")
}

/**
@@ -252,7 +276,9 @@ task("generateCargoWorkspace") {
        outputDir.resolve("Cargo.toml").writeText(generateCargoWorkspace(awsServices))
    }
    inputs.property("servicelist", awsServices.moduleNames.toString())
    if (awsServices.examples.isNotEmpty()) {
        inputs.dir(projectDir.resolve("examples"))
    }
    outputs.file(outputDir.resolve("Cargo.toml"))
    outputs.upToDateWhen { false }
}
@@ -271,6 +297,7 @@ tasks.register<Exec>("fixManifests") {
    dependsOn("relocateRuntime")
    dependsOn("relocateAwsRuntime")
    dependsOn("relocateExamples")
    dependsOn("fixExampleManifests")
}

tasks.register<Exec>("hydrateReadme") {

aws/sdk/examples/.gitignore

deleted100644 → 0
+0 −2
Original line number Diff line number Diff line
target/
Cargo.lock
+0 −14
Original line number Diff line number Diff line
[package]
name = "apigateway-code-examples"
version = "0.1.0"
edition = "2018"

# 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" }
aws-smithy-types-convert = { path = "../../build/aws-sdk/sdk/aws-smithy-types-convert", features = ["convert-chrono"] }
aws-sdk-apigateway = { path = "../../build/aws-sdk/sdk/apigateway" }
tokio = { version = "1", features = ["full"] }
structopt = { version = "0.3", default-features = false }
tracing-subscriber = { version = "0.3.5", features = ["env-filter"] }
Loading