Skip to content

Commit 69a8a51

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 7e4eb32 commit 69a8a51

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
CRATE (optional)
4546
- If provided, run the task only on the specified crate.
@@ -137,6 +138,11 @@ main() {
137138
do_bench
138139
;;
139140

141+
lock)
142+
need_toolchain "nightly"
143+
do_update_lock_files
144+
;;
145+
140146
*)
141147
err "Error: unknown task $task"
142148
;;
@@ -348,6 +354,44 @@ do_bench() {
348354
done
349355
}
350356

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

0 commit comments

Comments
 (0)