Commit ab211297 authored by John DiSanti's avatar John DiSanti
Browse files

Attempt to fix example workspace issue

parent 4a126b79
Loading
Loading
Loading
Loading
+7 −17
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
 * SPDX-License-Identifier: Apache-2.0
 */

import aws.sdk.AwsExamplesLayout
import aws.sdk.AwsServices
import aws.sdk.Membership
import aws.sdk.discoverServices
@@ -246,22 +245,13 @@ tasks.register<ExecRustBuildTool>("fixExampleManifests") {

    toolPath = sdkVersionerToolPath
    binaryName = "sdk-versioner"
    arguments = when (AwsExamplesLayout.detect(project)) {
        AwsExamplesLayout.Flat -> listOf(
            "use-path-and-version-dependencies",
            "--isolate-crates",
            "--sdk-path", "../../sdk",
            "--versions-toml", outputDir.resolve("versions.toml").absolutePath,
            outputDir.resolve("examples").absolutePath,
        )
        AwsExamplesLayout.Workspaces -> listOf(
    arguments = listOf(
        "use-path-and-version-dependencies",
        "--isolate-crates",
        "--sdk-path", sdkOutputDir.absolutePath,
        "--versions-toml", outputDir.resolve("versions.toml").absolutePath,
        outputDir.resolve("examples").absolutePath,
    )
    }

    outputs.dir(outputDir)
    dependsOn("relocateExamples", "generateVersionManifest")
+3 −41
Original line number Diff line number Diff line
@@ -19,38 +19,6 @@ data class RootTest(
    val manifestName: String,
)

// TODO(https://github.com/awslabs/smithy-rs/issues/2810): We can remove the `Flat` layout after the switch
// to `Workspaces` has been released. This can be checked by looking at the `examples/` directory in aws-sdk-rust's
// main branch.
//
// The `Flat` layout is retained for backwards compatibility so that the next release process can succeed.
enum class AwsExamplesLayout {
    /**
     * Directory layout for examples used prior to June 26, 2023,
     * where each example was in the `rust_dev_preview/` root directory and
     * was considered to be its own workspace.
     *
     * This layout had issues with CI in terms of time to compile and disk space required
     * since the dependencies would get recompiled for every example.
     */
    Flat,

    /**
     * Current directory layout where there are a small number of workspaces
     * rooted in `rust_dev_preview/`.
     */
    Workspaces,
    ;

    companion object {
        fun detect(project: Project): AwsExamplesLayout = if (project.projectDir.resolve("examples/Cargo.toml").exists()) {
            AwsExamplesLayout.Flat
        } else {
            AwsExamplesLayout.Workspaces
        }
    }
}

class AwsServices(
    private val project: Project,
    services: List<AwsService>,
@@ -77,16 +45,10 @@ class AwsServices(

    val examples: List<String> by lazy {
        val examplesRoot = project.projectDir.resolve("examples")
        if (AwsExamplesLayout.detect(project) == AwsExamplesLayout.Flat) {
            examplesRoot.listFiles { file -> !file.name.startsWith(".") }.orEmpty().toList()
                .filter { file -> manifestCompatibleWithGeneratedServices(file) }
                .map { "examples/${it.name}" }
        } else {
        examplesRoot.listFiles { file ->
            !file.name.startsWith(".") && file.isDirectory() && file.resolve("Cargo.toml").exists()
        }.orEmpty().toList().map { "examples/${it.name}" }
    }
    }

    /**
     * Tests in `aws/sdk/integration-tests` that are not named after a service module, and therefore,