-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dev): Script to update cargo deps (#801)
Add a script that handles updating cargo dependencies, running tests, and creating a commit since this is a relatively common operation. If the script fails at any step the commit will not be created.
- Loading branch information
1 parent
792655f
commit e4f22f9
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# Updates Cargo dependencies and generates a commit if the operation is successful and tests pass. | ||
# This requires the user to have the following binaries available in their PATH: | ||
# | ||
# - cargo | ||
# - cargo-upgrade | ||
# - cargo-update | ||
# - cargo-nextest | ||
# | ||
# If these can't be found the script will exit with an error. | ||
|
||
required_binaries=("cargo" "cargo-upgrade" "cargo-update" "cargo-nextest") | ||
|
||
for cmd in "${required_binaries[@]}" | ||
do | ||
if ! command -v "$cmd" | ||
then | ||
echo "$cmd was not found" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Checks if the current branch is clean, we only want this script to run in a clean context so | ||
# we don't accidentally commit other changes. | ||
has_changes=$(git diff-files --quiet) | ||
|
||
if [ "$has_changes" -ne "0" ]; then | ||
echo "ERROR: detected local changes. You must run this script with a clean git context." | ||
exit 1 | ||
fi | ||
|
||
set -ex | ||
|
||
cargo upgrade --incompatible | ||
cargo update | ||
cargo test --doc | ||
cargo nextest run | ||
git add Cargo.lock Cargo.toml | ||
git commit -m "chore(deps): Update cargo dependencies" \ | ||
-m "Done with \`dev_scripts/update_dependencies.bash\`" |