File size: 1,492 Bytes
bc32e7b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #!/usr/bin/env bash
set -euo pipefail
# Local maintenance checks for Tomato Novel Downloader.
# Do not use `cargo --all-features`: `official-api` and `no-official-api`
# are mutually exclusive by design.
skip_fmt=0
skip_no_official=0
skip_tree=0
for arg in "$@"; do
case "$arg" in
--skip-fmt) skip_fmt=1 ;;
--skip-no-official) skip_no_official=1 ;;
--skip-tree) skip_tree=1 ;;
-h|--help)
cat <<'EOF'
Usage: ./scripts/maintain.sh [--skip-fmt] [--skip-no-official] [--skip-tree]
Runs format, test, clippy, and duplicate dependency checks using valid feature combinations.
EOF
exit 0
;;
*)
echo "unknown option: $arg" >&2
exit 2
;;
esac
done
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
step() {
printf '\n==> %s\n' "$1"
}
step "Rust toolchain"
rustc --version
cargo --version
if [[ "$skip_fmt" -eq 0 ]]; then
step "Format check"
cargo fmt --all -- --check
fi
step "Default feature tests"
cargo test
step "Default feature clippy"
cargo clippy --all-targets -- -D warnings
if [[ "$skip_no_official" -eq 0 ]]; then
step "no-official-api tests"
cargo test --no-default-features --features no-official-api
step "no-official-api clippy"
cargo clippy --no-default-features --features no-official-api --all-targets -- -D warnings
fi
if [[ "$skip_tree" -eq 0 ]]; then
step "Duplicate dependency overview"
cargo tree -d
fi
printf '\nAll requested maintenance checks completed.\n'
|