Unverified Commit 7bba9b5d authored by ysaito1001's avatar ysaito1001 Committed by GitHub
Browse files

Re-enable `check-fuzzgen` CI step (#4206)

## Motivation and Context
https://github.com/smithy-lang/smithy-rs/issues/4195
```
FuzzHarnessBuildPluginTest > smokeTest() FAILED
    CommandError(output=Unexpected exception thrown when executing subprocess:
    CommandError(output=Command Error
    warning: /Users/awsaito/.local/share/smithy-test-workspace/smithy-test9654713374929678826/a/Cargo.toml: unused manifest key: workspace._ignored
        Updating crates.io index
         Locking 300 packages to latest compatible versions
          Adding homedir v0.3.6 (requires Rust 1.88)
    error: rustc 1.85.0 is not supported by the following package:
      homedir@0.3.6 requires rustc 1.88
    Either upgrade rustc or select compatible dependency versions with
    `cargo update <name>@<current-ver> --precise <compatible-ver>`
    where `<compatible-ver>` is the latest version supporting rustc 1.85.0
```

## Description
The PR commits a new lockfile to the `aws-smithy-fuzz` crate, which
contains a downgraded `homedir` crate with version `0.3.5`.
`FuzzHarnessBuildPlugin` places that lockfile in a fuzz target workspace
to avoid the compilation error above.

As a follow-up, filed [an OPS
enhancement](https://github.com/smithy-lang/smithy-rs/issues/4205) to
improve the lockfile update workflow to handle the one in
`aws-smithy-fuzz` as well.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent a0801ece
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -105,8 +105,8 @@ jobs:
          fetch-depth: 0
        - action: check-sdk-codegen-unit-tests
          runner: ubuntu-latest
        # - action: check-fuzzgen
        #   runner: ubuntu-latest
        - action: check-fuzzgen
          runner: ubuntu-latest
        - action: check-server-codegen-integration-tests
          runner: smithy_ubuntu-latest_8-core
        - action: check-server-codegen-integration-tests-python
+18 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import software.amazon.smithy.model.traits.HttpTrait
import software.amazon.smithy.model.traits.JsonNameTrait
import software.amazon.smithy.model.traits.XmlNameTrait
import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait
import software.amazon.smithy.rust.codegen.core.generated.BuildEnvironment
import software.amazon.smithy.rust.codegen.core.rustlang.RustModule
import software.amazon.smithy.rust.codegen.core.rustlang.Writable
import software.amazon.smithy.rust.codegen.core.smithy.ModuleDocProvider
@@ -34,6 +35,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNor
import software.amazon.smithy.rust.codegen.core.util.getTrait
import software.amazon.smithy.rust.codegen.core.util.orNull
import software.amazon.smithy.rust.codegen.server.smithy.transformers.AttachValidationExceptionToConstrainedOperationInputsInAllowList
import java.io.File
import java.nio.file.Path
import java.util.Base64
import kotlin.streams.toList
@@ -91,6 +93,13 @@ data class FuzzSettings(
 * This is used by `aws-smithy-fuzz` which contains most of the usage docs
 */
class FuzzHarnessBuildPlugin : SmithyBuildPlugin {
    // `aws-smithy-fuzz` is not part of the `rust-runtime` workspace,
    // and its dependencies may not be included in the SDK lockfile.
    // This plugin needs to use the lockfile from `aws-smithy-fuzz`.
    private val cargoLock: File by lazy {
        File(BuildEnvironment.PROJECT_DIR).resolve("rust-runtime/aws-smithy-fuzz/Cargo.lock")
    }

    override fun getName(): String = "fuzz-harness"

    override fun execute(context: PluginContext) {
@@ -111,7 +120,15 @@ class FuzzHarnessBuildPlugin : SmithyBuildPlugin {
        createDriver(model, context.fileManifest, fuzzSettings)

        targets.forEach {
            context.fileManifest.addAllFiles(it.finalize())
            val manifest = it.finalize()
            context.fileManifest.addAllFiles(manifest)
            // A fuzz target crate exists in a nested structure like:
            // smithy-test-workspace/smithy-test4510328876569901367/a
            //
            // Each fuzz target is its own workspace with `[workspace]\n_ignored _ignored`.
            // As a result, placing the lockfile from `aws-smithy-fuzz` in `TestWorkspace`
            // has no effect; it must be copied directly into the fuzz target.
            cargoLock.copyTo(manifest.baseDir.resolve("Cargo.lock").toFile(), true)
        }
    }
}
+2834 −0

File added.

Preview size limit exceeded, changes collapsed.