|
40 | 40 | - docs Build docs with stable toolchain. |
41 | 41 | - docsrs Build docs with nightly toolchain. |
42 | 42 | - bench Run the bench tests. |
| 43 | + - lock Update Cargo-minimal.lock and Cargo-recent.lock files. |
43 | 44 |
|
44 | 45 | CRATE (optional) |
45 | 46 | - If provided, run the task only on the specified crate. |
@@ -137,6 +138,11 @@ main() { |
137 | 138 | do_bench |
138 | 139 | ;; |
139 | 140 |
|
| 141 | + lock) |
| 142 | + need_toolchain "nightly" |
| 143 | + do_update_lock_files |
| 144 | + ;; |
| 145 | + |
140 | 146 | *) |
141 | 147 | err "Error: unknown task $task" |
142 | 148 | ;; |
@@ -348,6 +354,44 @@ do_bench() { |
348 | 354 | done |
349 | 355 | } |
350 | 356 |
|
| 357 | +# Update Cargo-minimal.lock and Cargo-recent.lock files. |
| 358 | +do_update_lock_files() { |
| 359 | + pushd "$REPO_DIR" > /dev/null |
| 360 | + verbose_say "Updating lock files in repository root: $REPO_DIR" |
| 361 | + |
| 362 | + # The `direct-minimal-versions` and `minimal-versions` dependency |
| 363 | + # resolution strategy flags each have a little quirk. `direct-minimal-versions` |
| 364 | + # allows transitive versions to upgrade, so we are not testing against |
| 365 | + # the actual minimum tree. `minimal-versions` allows the direct dependency |
| 366 | + # versions to resolve upward due to transitive requirements, so we are |
| 367 | + # not testing the manifest's versions. Combo'd together though, we |
| 368 | + # can get the best of both worlds to ensure the actual minimum dependencies |
| 369 | + # listed in the crate manifests build. |
| 370 | + |
| 371 | + # Check that all explicit direct dependency versions are not lying, |
| 372 | + # as in, they are not being bumped up by transitive dependency constraints. |
| 373 | + verbose_say "Checking direct minimal versions..." |
| 374 | + rm -f "Cargo.lock" |
| 375 | + cargo check --all-features -Z direct-minimal-versions |
| 376 | + |
| 377 | + # Now that our own direct dependency versions can be trusted, check |
| 378 | + # against the lowest versions of the dependency tree which still |
| 379 | + # satisfy constraints. Use this as the minimal version lock file. |
| 380 | + verbose_say "Generating Cargo-minimal.lock..." |
| 381 | + rm -f "Cargo.lock" |
| 382 | + cargo check --all-features -Z minimal-versions |
| 383 | + cp -f "Cargo.lock" "Cargo-minimal.lock" |
| 384 | + |
| 385 | + # Conservatively bump of recent dependencies. |
| 386 | + verbose_say "Updating Cargo-recent.lock..." |
| 387 | + cp -f "Cargo-recent.lock" "Cargo.lock" |
| 388 | + cargo check --all-features |
| 389 | + cp -f "Cargo.lock" "Cargo-recent.lock" |
| 390 | + |
| 391 | + verbose_say "Lock files updated successfully" |
| 392 | + popd > /dev/null |
| 393 | +} |
| 394 | + |
351 | 395 | # Check all the commands we use are present in the current environment. |
352 | 396 | check_required_commands() { |
353 | 397 | need_cmd cargo |
|
0 commit comments