Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 68 additions & 3 deletions .github/workflows/ci-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
14 changes: 13 additions & 1 deletion CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,16 @@ author = "rcoh"
message = "Improve docs on `Endpoint::{mutable, immutable}`"
references = ["smithy-rs#1087"]
meta = { "breaking" = false, "tada" = false, "bug" = false }
author = "rcoh"
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"
31 changes: 29 additions & 2 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down Expand Up @@ -179,10 +181,32 @@ task("relocateExamples") {
}
}
}
inputs.dir(projectDir.resolve("examples"))
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")
}

/**
* The aws/rust-runtime crates depend on local versions of the Smithy core runtime enabling local compilation. However,
* those paths need to be replaced in the final build. We should probably fix this with some symlinking.
Expand Down Expand Up @@ -252,7 +276,9 @@ task("generateCargoWorkspace") {
outputDir.resolve("Cargo.toml").writeText(generateCargoWorkspace(awsServices))
}
inputs.property("servicelist", awsServices.moduleNames.toString())
inputs.dir(projectDir.resolve("examples"))
if (awsServices.examples.isNotEmpty()) {
inputs.dir(projectDir.resolve("examples"))
}
outputs.file(outputDir.resolve("Cargo.toml"))
outputs.upToDateWhen { false }
}
Expand All @@ -271,6 +297,7 @@ tasks.register<Exec>("fixManifests") {
dependsOn("relocateRuntime")
dependsOn("relocateAwsRuntime")
dependsOn("relocateExamples")
dependsOn("fixExampleManifests")
}

tasks.register<Exec>("hydrateReadme") {
Expand Down
2 changes: 0 additions & 2 deletions aws/sdk/examples/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions aws/sdk/examples/apigateway/Cargo.toml

This file was deleted.

38 changes: 0 additions & 38 deletions aws/sdk/examples/apigateway/README.md

This file was deleted.

73 changes: 0 additions & 73 deletions aws/sdk/examples/apigateway/src/bin/get_rest_apis.rs

This file was deleted.

14 changes: 0 additions & 14 deletions aws/sdk/examples/apigatewaymanagement/Cargo.toml

This file was deleted.

22 changes: 0 additions & 22 deletions aws/sdk/examples/apigatewaymanagement/README.md

This file was deleted.

Loading