2025-06-03 00:27:54 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2025-06-23 09:59:49 +02:00
|
|
|
{
|
2025-06-03 00:27:54 +02:00
|
|
|
set -ex
|
|
|
|
|
|
2025-06-19 12:00:43 +02:00
|
|
|
lint=true
|
|
|
|
|
if [ "$FISH_CHECK_LINT" = false ]; then
|
|
|
|
|
lint=false
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-17 13:11:39 +02:00
|
|
|
check_dependency_versions=false
|
|
|
|
|
if [ "${FISH_CHECK_DEPENDENCY_VERSIONS:-false}" != false ]; then
|
|
|
|
|
check_dependency_versions=true
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if $check_dependency_versions; then
|
|
|
|
|
command -v curl
|
|
|
|
|
command -v jq
|
|
|
|
|
command -v rustup
|
2025-10-26 09:32:44 +01:00
|
|
|
command -v uv
|
2025-10-17 13:11:39 +02:00
|
|
|
sort --version-sort </dev/null
|
2025-10-31 03:46:48 +01:00
|
|
|
# To match existing behavior, only check Rust/dockerfiles for now.
|
|
|
|
|
# TODO: remove this from this script.
|
|
|
|
|
updatecli diff --config=updatecli.d/docker.yml --config=updatecli.d/rust.yml
|
2025-10-17 13:11:39 +02:00
|
|
|
fi
|
|
|
|
|
|
2025-06-19 12:00:43 +02:00
|
|
|
cargo_args=$FISH_CHECK_CARGO_ARGS
|
|
|
|
|
target_triple=$FISH_CHECK_TARGET_TRIPLE
|
|
|
|
|
if [ -n "$target_triple" ]; then
|
|
|
|
|
cargo_args="$cargo_args --target=$FISH_CHECK_TARGET_TRIPLE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cargo() {
|
|
|
|
|
subcmd=$1
|
|
|
|
|
shift
|
2026-01-05 16:33:15 +01:00
|
|
|
if [ -n "$FISH_CHECK_RUST_TOOLCHAIN" ]; then
|
|
|
|
|
# shellcheck disable=2086
|
|
|
|
|
command cargo "+$FISH_CHECK_RUST_TOOLCHAIN" "$subcmd" $cargo_args "$@"
|
|
|
|
|
else
|
|
|
|
|
# shellcheck disable=2086
|
|
|
|
|
command cargo "$subcmd" $cargo_args "$@"
|
|
|
|
|
fi
|
2025-06-19 12:00:43 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-11 18:03:13 +02:00
|
|
|
cleanup () {
|
2025-10-16 00:40:08 +02:00
|
|
|
if [ -n "$gettext_template_dir" ] && [ -e "$gettext_template_dir" ]; then
|
|
|
|
|
rm -r "$gettext_template_dir"
|
2025-06-19 12:00:43 +02:00
|
|
|
fi
|
2025-06-11 18:03:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trap cleanup EXIT INT TERM HUP
|
|
|
|
|
|
2025-06-19 12:00:43 +02:00
|
|
|
if $lint; then
|
2025-06-23 09:59:49 +02:00
|
|
|
export RUSTFLAGS="--deny=warnings ${RUSTFLAGS}"
|
|
|
|
|
export RUSTDOCFLAGS="--deny=warnings ${RUSTDOCFLAGS}"
|
2025-06-19 12:00:43 +02:00
|
|
|
fi
|
2025-06-03 00:27:54 +02:00
|
|
|
|
2025-09-13 10:18:32 +02:00
|
|
|
workspace_root="$(dirname "$0")/.."
|
2025-08-17 00:17:19 +02:00
|
|
|
target_dir=${CARGO_TARGET_DIR:-$workspace_root/target}
|
|
|
|
|
if [ -n "$target_triple" ]; then
|
|
|
|
|
target_dir="$target_dir/$target_triple"
|
|
|
|
|
fi
|
|
|
|
|
# The directory containing the binaries produced by cargo/rustc.
|
|
|
|
|
# Currently, all builds are debug builds.
|
|
|
|
|
build_dir="$target_dir/debug"
|
2025-08-10 15:48:33 +02:00
|
|
|
|
2025-10-05 23:00:10 +08:00
|
|
|
if [ -n "$FISH_TEST_MAX_CONCURRENCY" ]; then
|
|
|
|
|
export RUST_TEST_THREADS="$FISH_TEST_MAX_CONCURRENCY"
|
|
|
|
|
export CARGO_BUILD_JOBS="$FISH_TEST_MAX_CONCURRENCY"
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-16 00:40:08 +02:00
|
|
|
gettext_template_dir=$(mktemp -d)
|
2025-10-07 02:40:21 +02:00
|
|
|
(
|
2025-10-16 00:40:08 +02:00
|
|
|
export FISH_GETTEXT_EXTRACTION_DIR="$gettext_template_dir"
|
2025-10-07 02:40:21 +02:00
|
|
|
cargo build --workspace --all-targets --features=gettext-extract
|
|
|
|
|
)
|
2025-06-19 12:00:43 +02:00
|
|
|
if $lint; then
|
2025-11-04 11:08:04 +01:00
|
|
|
if command -v cargo-deny >/dev/null; then
|
|
|
|
|
cargo deny --all-features --locked --exclude-dev check licenses
|
|
|
|
|
fi
|
2026-02-20 15:29:07 +01:00
|
|
|
PATH="$build_dir:$PATH" cargo xtask format --all --check
|
2025-09-06 18:51:07 +02:00
|
|
|
for features in "" --no-default-features; do
|
|
|
|
|
cargo clippy --workspace --all-targets $features
|
|
|
|
|
done
|
2025-06-19 12:00:43 +02:00
|
|
|
fi
|
2025-06-03 00:27:54 +02:00
|
|
|
cargo test --no-default-features --workspace --all-targets
|
|
|
|
|
cargo test --doc --workspace
|
2025-06-19 12:00:43 +02:00
|
|
|
if $lint; then
|
2025-12-23 18:41:08 +01:00
|
|
|
cargo doc --workspace --no-deps
|
2025-06-19 12:00:43 +02:00
|
|
|
fi
|
2025-10-16 00:40:08 +02:00
|
|
|
FISH_GETTEXT_EXTRACTION_DIR=$gettext_template_dir "$workspace_root/tests/test_driver.py" "$build_dir"
|
2025-06-23 09:59:49 +02:00
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
}
|