Skip to content

Commit 874373b

Browse files
committed
Add lock task to update lock files
This is probably stretching the limits of the CI run task script, but it leverages a lot of the internal tooling.
1 parent e7ad5b2 commit 874373b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

ci/run_task.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ TASK
4040
- docs Build docs with stable toolchain.
4141
- docsrs Build docs with nightly toolchain.
4242
- bench Run the bench tests.
43+
- lock Update Cargo-minimal.lock and Cargo-recent.lock files.
4344
4445
Environment Variables:
4546
MAINTAINER_TOOLS_LOG_LEVEL Control script and cargo output verbosity.
@@ -117,6 +118,11 @@ main() {
117118
do_bench
118119
;;
119120

121+
lock)
122+
need_toolchain "nightly"
123+
do_update_lock_files
124+
;;
125+
120126
*)
121127
err "Error: unknown task $task"
122128
;;
@@ -331,6 +337,44 @@ do_bench() {
331337
done
332338
}
333339

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+
334378
# Check all the commands we use are present in the current environment.
335379
check_required_commands() {
336380
need_cmd cargo

0 commit comments

Comments
 (0)