Skip to content

Commit 7bba9b5

Browse files
authored
Re-enable check-fuzzgen CI step (#4206)
## Motivation and Context #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](#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._
1 parent a0801ec commit 7bba9b5

File tree

3 files changed

+2854
-3
lines changed

3 files changed

+2854
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ jobs:
105105
fetch-depth: 0
106106
- action: check-sdk-codegen-unit-tests
107107
runner: ubuntu-latest
108-
# - action: check-fuzzgen
109-
# runner: ubuntu-latest
108+
- action: check-fuzzgen
109+
runner: ubuntu-latest
110110
- action: check-server-codegen-integration-tests
111111
runner: smithy_ubuntu-latest_8-core
112112
- action: check-server-codegen-integration-tests-python

fuzzgen/src/main/kotlin/software/amazon/smithy/rust/codegen/fuzz/FuzzHarnessBuildPlugin.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import software.amazon.smithy.model.traits.HttpTrait
2626
import software.amazon.smithy.model.traits.JsonNameTrait
2727
import software.amazon.smithy.model.traits.XmlNameTrait
2828
import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait
29+
import software.amazon.smithy.rust.codegen.core.generated.BuildEnvironment
2930
import software.amazon.smithy.rust.codegen.core.rustlang.RustModule
3031
import software.amazon.smithy.rust.codegen.core.rustlang.Writable
3132
import software.amazon.smithy.rust.codegen.core.smithy.ModuleDocProvider
@@ -34,6 +35,7 @@ import software.amazon.smithy.rust.codegen.core.smithy.transformers.OperationNor
3435
import software.amazon.smithy.rust.codegen.core.util.getTrait
3536
import software.amazon.smithy.rust.codegen.core.util.orNull
3637
import software.amazon.smithy.rust.codegen.server.smithy.transformers.AttachValidationExceptionToConstrainedOperationInputsInAllowList
38+
import java.io.File
3739
import java.nio.file.Path
3840
import java.util.Base64
3941
import kotlin.streams.toList
@@ -91,6 +93,13 @@ data class FuzzSettings(
9193
* This is used by `aws-smithy-fuzz` which contains most of the usage docs
9294
*/
9395
class FuzzHarnessBuildPlugin : SmithyBuildPlugin {
96+
// `aws-smithy-fuzz` is not part of the `rust-runtime` workspace,
97+
// and its dependencies may not be included in the SDK lockfile.
98+
// This plugin needs to use the lockfile from `aws-smithy-fuzz`.
99+
private val cargoLock: File by lazy {
100+
File(BuildEnvironment.PROJECT_DIR).resolve("rust-runtime/aws-smithy-fuzz/Cargo.lock")
101+
}
102+
94103
override fun getName(): String = "fuzz-harness"
95104

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

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

0 commit comments

Comments
 (0)