Skip to content

Commit f648759

Browse files
authored
Fix library dependency issues (#3901)
## Motivation and Context Smithy-rs CI and our release pipeline have exposed another place, [sdk-adhoc-test](https://github.com/smithy-lang/smithy-rs/tree/main/aws/sdk-adhoc-test), where we should place a Cargo lockfile but we currently don't. Specifically, running `./gradlew aws:sdk-adhoc-test:check`on the current main is encountering the following error: ``` error[E0658]: use of unstable library feature 'error_in_core' --> /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/idna-1.0.3/src/lib.rs:78:6 | 78 | impl core::error::Error for Errors {} | ^^^^^^^^^^^^^^^^^^ | = note: see issue #103765 <rust-lang/rust#103765> for more information ``` We're supposed to pin `idna` to 0.5.0 ([example](https://github.com/smithy-lang/smithy-rs/blob/62caa4639497bc9b18f57e51a30265899d9b511e/aws/sdk/Cargo.lock#L2812-L2819)), but `sdk-adhoc-test` uses 1.0.3. This PR will fix the problem by copying the checked-in SDK lockfile to `sdk-adhoc-test`. ## Testing - [x] `./gradlew aws:sdk-adhoc-test:check` from the repo root has passed - [ ] Tests in CI ---- _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 62caa46 commit f648759

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

aws/sdk-adhoc-test/build.gradle.kts

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ configure<software.amazon.smithy.gradle.SmithyExtension> {
2929
outputDirectory = layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile
3030
}
3131

32+
val checkedInSdkLockfile = rootProject.projectDir.resolve("aws/sdk/Cargo.lock")
33+
3234
dependencies {
3335
implementation(project(":aws:sdk-codegen"))
3436
implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion")
@@ -83,9 +85,10 @@ val allCodegenTests = listOf(
8385
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
8486
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
8587
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
88+
project.registerCopyCheckedInCargoLockfileTask(checkedInSdkLockfile, layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
8689

8790
tasks["smithyBuild"].dependsOn("generateSmithyBuild")
88-
tasks["assemble"].finalizedBy("generateCargoWorkspace")
91+
tasks["assemble"].dependsOn("generateCargoWorkspace").finalizedBy("copyCheckedInCargoLockfile")
8992

9093
project.registerModifyMtimeTask()
9194
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

buildSrc/src/main/kotlin/CodegenTestCommon.kt

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import org.gradle.api.Project
7+
import org.gradle.api.tasks.Copy
78
import org.gradle.api.tasks.Exec
89
import org.gradle.kotlin.dsl.extra
910
import org.gradle.kotlin.dsl.register
@@ -295,6 +296,17 @@ fun Project.registerGenerateCargoConfigTomlTask(outputDir: File) {
295296
}
296297
}
297298

299+
fun Project.registerCopyCheckedInCargoLockfileTask(
300+
lockfile: File,
301+
destinationDir: File,
302+
) {
303+
this.tasks.register<Copy>("copyCheckedInCargoLockfile") {
304+
description = "copy checked-in `Cargo.lock` to the destination directory"
305+
from(lockfile)
306+
into(destinationDir)
307+
}
308+
}
309+
298310
const val PREVIOUS_BUILD_HASHES_KEY = "previousBuildHashes"
299311

300312
fun Project.registerModifyMtimeTask() {

codegen-client-test/build.gradle.kts

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ fun getSmithyRuntimeMode(): String = properties.get("smithy.runtime.mode") ?: "o
2121
val pluginName = "rust-client-codegen"
2222
val workingDirUnderBuildDir = "smithyprojections/codegen-client-test/"
2323

24+
val checkedInSmithyRuntimeLockfile = rootProject.projectDir.resolve("rust-runtime/Cargo.lock")
25+
2426
dependencies {
2527
implementation(project(":codegen-client"))
2628
implementation("software.amazon.smithy:smithy-aws-protocol-tests:$smithyVersion")
@@ -124,11 +126,12 @@ val allCodegenTests = listOf(
124126
project.registerGenerateSmithyBuildTask(rootProject, pluginName, allCodegenTests)
125127
project.registerGenerateCargoWorkspaceTask(rootProject, pluginName, allCodegenTests, workingDirUnderBuildDir)
126128
project.registerGenerateCargoConfigTomlTask(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
129+
project.registerCopyCheckedInCargoLockfileTask(checkedInSmithyRuntimeLockfile, layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)
127130

128131
tasks["generateSmithyBuild"].inputs.property("smithy.runtime.mode", getSmithyRuntimeMode())
129132

130133
tasks["smithyBuild"].dependsOn("generateSmithyBuild")
131-
tasks["assemble"].finalizedBy("generateCargoWorkspace")
134+
tasks["assemble"].finalizedBy("generateCargoWorkspace", "copyCheckedInCargoLockfile")
132135

133136
project.registerModifyMtimeTask()
134137
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tools/ci-cdk/canary-runner/src/build_bundle.rs

+15
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ wit-bindgen = { version = "0.16.0", features = ["macros", "realloc"] }
143143
wasmtime = { version = "17.0.1", features = ["component-model"] }
144144
wasmtime-wasi = "17.0.1"
145145
wasmtime-wasi-http = "17.0.1"
146+
147+
# TODO(MSRV): Version 1.4.0 uses `error_in_core` and is considered unstable library feature in our MSRV of 1.78.0.
148+
# Remove this version constraint once we upgrade to a future MSRV that stabilizes `error_in_core`.
149+
arbitrary = "=1.3.2"
150+
146151
"#;
147152

148153
lazy_static! {
@@ -599,6 +604,11 @@ wit-bindgen = { version = "0.16.0", features = ["macros", "realloc"] }
599604
wasmtime = { version = "17.0.1", features = ["component-model"] }
600605
wasmtime-wasi = "17.0.1"
601606
wasmtime-wasi-http = "17.0.1"
607+
608+
# TODO(MSRV): Version 1.4.0 uses `error_in_core` and is considered unstable library feature in our MSRV of 1.78.0.
609+
# Remove this version constraint once we upgrade to a future MSRV that stabilizes `error_in_core`.
610+
arbitrary = "=1.3.2"
611+
602612
aws-config = { path = "some/sdk/path/aws-config", features = ["behavior-version-latest"] }
603613
aws-sdk-s3 = { path = "some/sdk/path/s3" }
604614
aws-sdk-ec2 = { path = "some/sdk/path/ec2" }
@@ -657,6 +667,11 @@ wit-bindgen = { version = "0.16.0", features = ["macros", "realloc"] }
657667
wasmtime = { version = "17.0.1", features = ["component-model"] }
658668
wasmtime-wasi = "17.0.1"
659669
wasmtime-wasi-http = "17.0.1"
670+
671+
# TODO(MSRV): Version 1.4.0 uses `error_in_core` and is considered unstable library feature in our MSRV of 1.78.0.
672+
# Remove this version constraint once we upgrade to a future MSRV that stabilizes `error_in_core`.
673+
arbitrary = "=1.3.2"
674+
660675
aws-config = { version = "0.46.0", features = ["behavior-version-latest"] }
661676
aws-sdk-s3 = { version = "0.20.0" }
662677
aws-sdk-ec2 = { version = "0.19.0" }

tools/ci-scripts/check-semver-hazards

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ runtime-versioner patch-runtime \
2424
--sdk-path "$(pwd)/aws-sdk-rust" \
2525
--smithy-rs-path "$(pwd)/smithy-rs"
2626

27+
echo -e "${C_YELLOW}# Copying the SDK lockfile to aws-sdk-rust...${C_RESET}"
28+
cp "$(pwd)/smithy-rs/aws/sdk/Cargo.lock" "$(pwd)/aws-sdk-rust/"
29+
2730
echo -e "${C_YELLOW}# Testing SDK...${C_RESET}"
2831
for sdk in aws-sdk-rust/sdk/*; do
2932
if ls "$sdk/tests" | grep -v '^endpoint_tests\.rs$'; then

tools/ci-scripts/codegen-diff/semver-checks.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def main(skip_generation=False):
4444
elif get_cmd_status(f'git cat-file -e base:{sdk_directory}/{path}/Cargo.toml') != 0:
4545
eprint(f'skipping {path} because it does not exist in base')
4646
else:
47-
get_cmd_output('cargo generate-lockfile', quiet=True)
4847
(_, out, _) = get_cmd_output('cargo pkgid', cwd=path, quiet=True)
4948
pkgid = parse_package_id(out)
5049
(status, out, err) = get_cmd_output(f'cargo semver-checks check-release '

0 commit comments

Comments
 (0)