From a99ec91c1dfaeba836c12f08cdd5b932986a1ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= Date: Thu, 21 Nov 2024 10:15:50 +0000 Subject: [PATCH] chore: Check `uv` version --- .github/check_uv.sh | 23 +++++++++++++++++++++++ DEVELOPMENT.md | 1 + justfile | 2 ++ 3 files changed, 26 insertions(+) create mode 100755 .github/check_uv.sh diff --git a/.github/check_uv.sh b/.github/check_uv.sh new file mode 100755 index 00000000..36eef09f --- /dev/null +++ b/.github/check_uv.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Ensure that the `uv` command is available and meets the minimum version requirement. + +# Desired minimum version +MIN_VERSION="0.4.27" + +# Get the version of `uv` +UV_VERSION=$(uv --version | awk '{print $2}') + +# Function to compare versions +version_ge() { + # Returns 0 (true) if $1 >= $2 + [ "$(printf '%s\n' "$1" "$2" | sort -V | head -n 1)" == "$2" ] +} + +# Compare versions +if version_ge "$UV_VERSION" "$MIN_VERSION"; then + echo "uv version $UV_VERSION meets the minimum requirement ($MIN_VERSION)." +else + echo "uv version $UV_VERSION does not meet the minimum requirement ($MIN_VERSION)." + echo "Please upgrade uv by running `uv self update`, or by following the instructions in your package manager." + exit 1 +fi \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 4cd583a0..140c4a81 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -30,6 +30,7 @@ To setup the environment manually you will need: - Just: [just.systems](https://just.systems/) - uv `>=0.4.27`: [docs.astral.sh](https://docs.astral.sh/uv/getting-started/installation/) + * If you have an older manually installed `uv` version, you can upgrade it with `uv self update`. The extended test suite has additional requirements. These are **optional**; tests that require them will be skipped if they are not installed. diff --git a/justfile b/justfile index d0399767..b1b77f78 100644 --- a/justfile +++ b/justfile @@ -14,6 +14,8 @@ setup-extras: # Run the pre-commit checks. check: + # Ensure that the uv version is supported + ./.github/check_uv.sh uv run pre-commit run --all-files # Compile integration test binaries.