|
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 | Environment Variables: |
45 | 46 | MAINTAINER_TOOLS_LOG_LEVEL Control script and cargo output verbosity. |
@@ -117,6 +118,11 @@ main() { |
117 | 118 | do_bench |
118 | 119 | ;; |
119 | 120 |
|
| 121 | + lock) |
| 122 | + need_toolchain "nightly" |
| 123 | + do_update_lock_files |
| 124 | + ;; |
| 125 | + |
120 | 126 | *) |
121 | 127 | err "Error: unknown task $task" |
122 | 128 | ;; |
@@ -331,6 +337,44 @@ do_bench() { |
331 | 337 | done |
332 | 338 | } |
333 | 339 |
|
| 340 | +# Update Cargo-minimal.lock and Cargo-recent.lock files. |
| 341 | +do_update_lock_files() { |
| 342 | + pushd "$REPO_DIR" > /dev/null |
| 343 | + verbose_say "Updating lock files in repository root: $REPO_DIR" |
| 344 | + |
| 345 | + # The `direct-minimal-versions` and `minimal-versions` dependency |
| 346 | + # resolution strategy flags each have a little quirk. `direct-minimal-versions` |
| 347 | + # allows transitive versions to upgrade, so we are not testing against |
| 348 | + # the actual minimum tree. `minimal-versions` allows the direct dependency |
| 349 | + # versions to resolve upward due to transitive requirements, so we are |
| 350 | + # not testing the manifest's versions. Combo'd together though, we |
| 351 | + # can get the best of both worlds to ensure the actual minimum dependencies |
| 352 | + # listed in the crate manifests build. |
| 353 | + |
| 354 | + # Check that all explicit direct dependency versions are not lying, |
| 355 | + # as in, they are not being bumped up by transitive dependency constraints. |
| 356 | + verbose_say "Checking direct minimal versions..." |
| 357 | + rm -f "Cargo.lock" |
| 358 | + cargo check --all-features -Z direct-minimal-versions |
| 359 | + |
| 360 | + # Now that our own direct dependency versions can be trusted, check |
| 361 | + # against the lowest versions of the dependency tree which still |
| 362 | + # satisfy constraints. Use this as the minimal version lock file. |
| 363 | + verbose_say "Generating Cargo-minimal.lock..." |
| 364 | + rm -f "Cargo.lock" |
| 365 | + cargo check --all-features -Z minimal-versions |
| 366 | + cp -f "Cargo.lock" "Cargo-minimal.lock" |
| 367 | + |
| 368 | + # Conservatively bump of recent dependencies. |
| 369 | + verbose_say "Updating Cargo-recent.lock..." |
| 370 | + cp -f "Cargo-recent.lock" "Cargo.lock" |
| 371 | + cargo check --all-features |
| 372 | + cp -f "Cargo.lock" "Cargo-recent.lock" |
| 373 | + |
| 374 | + verbose_say "Lock files updated successfully" |
| 375 | + popd > /dev/null |
| 376 | +} |
| 377 | + |
334 | 378 | # Check all the commands we use are present in the current environment. |
335 | 379 | check_required_commands() { |
336 | 380 | need_cmd cargo |
|
0 commit comments