Skip to content

Commit 845863a

Browse files
What if we used uv to run lots of our ci-checks.sh (#7787)
Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
1 parent fa20ef7 commit 845863a

6 files changed

Lines changed: 34 additions & 49 deletions

File tree

scripts/check-cmake-format.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,22 @@ else
2828
echo "Checking file format in" "$@"
2929
fi
3030

31-
if [ ! -f "scripts/env/bin/activate" ]
32-
then
33-
python3 -m venv scripts/env
31+
if [ ! -x "$(command -v uv)" ]; then
32+
echo "uv is required but not installed. See https://docs.astral.sh/uv/getting-started/installation/" >&2
33+
exit 1
3434
fi
3535

36-
source scripts/env/bin/activate
37-
pip install -U pip
38-
pip install 'gersemi==0.17.0' 1>/dev/null
36+
GERSEMI="uvx gersemi@0.17.0"
3937

4038
FILES=$(git ls-files "$@" | grep -e '\.cmake$' -e 'CMakeLists\.txt$')
4139

4240
if $fix ; then
4341
# shellcheck disable=SC2086
44-
gersemi -i $FILES
42+
$GERSEMI -i $FILES
4543
echo "All files formatted!"
4644
else
4745
# shellcheck disable=SC2086
48-
if gersemi --check $FILES; then
46+
if $GERSEMI --check $FILES; then
4947
echo "All files formatted correctly!"
5048
else
5149
echo "Fix formatting by running: scripts/cmake-format-checks.sh -f"

scripts/check-format.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,16 @@ mapfile -t files < <(git ls-files "$@" | grep -e '\.h$' -e '\.hpp$' -e '\.cpp$'
4343
# --- Format check (parallel) ---
4444
if [ "${#files[@]}" -eq 0 ]; then
4545
unformatted_files=""
46-
elif $fix ; then
47-
# In fix mode, format first then check what changed
48-
printf '%s\n' "${files[@]}" | xargs -P "$NPROC" -n 50 "$CLANG_FORMAT" -style=file -i
49-
50-
# Re-check to report which files were fixed
51-
unformatted_files=$(git diff --name-only -- "${files[@]}") || true
5246
else
53-
# Check mode: collect filenames from clang-format warnings (parallel)
47+
# Check which files need formatting (parallel)
5448
unformatted_files=$(printf '%s\n' "${files[@]}" | \
5549
xargs -P "$NPROC" -n 50 "$CLANG_FORMAT" -n -Werror -style=file 2>&1 | \
5650
sed -n 's/^\(.*\):[0-9]*:[0-9]*:.*/\1/p' | sort -u) || true
51+
52+
if $fix && [ "$unformatted_files" != "" ]; then
53+
# Fix only the files that failed the check
54+
echo "$unformatted_files" | xargs -P "$NPROC" -n 50 "$CLANG_FORMAT" -style=file -i
55+
fi
5756
fi
5857

5958
# --- File name check ---

scripts/openapi-checks.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1111
ROOT_DIR=$( dirname "$SCRIPT_DIR" )
1212
cd "$ROOT_DIR" || exit 1
1313

14-
NPM_DIR=$(mktemp -d) || exit 1
15-
trap 'rm -rf "$NPM_DIR"' EXIT
16-
npm install --loglevel=error --no-save --prefix "$NPM_DIR" @apidevtools/swagger-cli 1>/dev/null || exit 1
14+
if [ ! -x "$(command -v uv)" ]; then
15+
echo "uv is required but not installed. See https://docs.astral.sh/uv/getting-started/installation/" >&2
16+
exit 1
17+
fi
1718

18-
find doc/schemas/*.json -exec npx --prefix "$NPM_DIR" swagger-cli validate {} \; || exit 1
19-
find doc/schemas/gov/*/*.json -exec npx --prefix "$NPM_DIR" swagger-cli validate {} \;
19+
VALIDATOR="uvx --from openapi-spec-validator openapi-spec-validator"
20+
21+
$VALIDATOR doc/schemas/*.json || exit 1
22+
$VALIDATOR doc/schemas/gov/*/*.json

scripts/python-format-checks.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
ROOT_DIR=$( dirname "$SCRIPT_DIR" )
1818
cd "$ROOT_DIR" || exit 1
1919

20-
# Ensure venv exists and activate (uses a dedicated venv to allow concurrent runs)
21-
if [ ! -f "scripts/env-format/bin/activate" ]; then
22-
python3 -m venv scripts/env-format
20+
if [ ! -x "$(command -v uv)" ]; then
21+
echo "uv is required but not installed. See https://docs.astral.sh/uv/getting-started/installation/" >&2
22+
exit 1
2323
fi
24-
source scripts/env-format/bin/activate
25-
26-
pip install -U pip > /dev/null || exit 1
27-
pip install -U wheel black 1>/dev/null || exit 1
2824

2925
if [ $FIX -ne 0 ]; then
30-
git ls-files tests/ python/ scripts/ tla/ | grep -e '\.py$' | xargs black
26+
git ls-files tests/ python/ scripts/ tla/ | grep -e '\.py$' | xargs uvx black
3127
else
32-
git ls-files tests/ python/ scripts/ tla/ | grep -e '\.py$' | xargs black --check
28+
git ls-files tests/ python/ scripts/ tla/ | grep -e '\.py$' | xargs uvx black --check
3329
fi

scripts/python-lint-checks.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,13 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
ROOT_DIR=$( dirname "$SCRIPT_DIR" )
1818
cd "$ROOT_DIR" || exit 1
1919

20-
# Ensure venv exists and activate (uses a dedicated venv to allow concurrent runs)
21-
if [ ! -f "scripts/env-lint/bin/activate" ]; then
22-
python3 -m venv scripts/env-lint || exit 1
20+
if [ ! -x "$(command -v uv)" ]; then
21+
echo "uv is required but not installed. See https://docs.astral.sh/uv/getting-started/installation/" >&2
22+
exit 1
2323
fi
24-
source scripts/env-lint/bin/activate || exit 1
25-
26-
pip install -U pip > /dev/null || exit 1
27-
pip install -U wheel ruff 1>/dev/null || exit 1
28-
pip install -U -r tests/requirements.txt 1>/dev/null || exit 1
29-
pip install -U ./python 1>/dev/null || exit 1
3024

3125
if [ $FIX -ne 0 ]; then
32-
ruff check --fix python/ tests/
26+
uvx ruff check --fix python/ tests/
3327
else
34-
ruff check python/ tests/
28+
uvx ruff check python/ tests/
3529
fi

scripts/python-types-checks.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1111
ROOT_DIR=$( dirname "$SCRIPT_DIR" )
1212
cd "$ROOT_DIR" || exit 1
1313

14-
# Ensure venv exists and activate (uses a dedicated venv to allow concurrent runs)
15-
if [ ! -f "scripts/env-types/bin/activate" ]; then
16-
python3 -m venv scripts/env-types || exit 1
14+
if [ ! -x "$(command -v uv)" ]; then
15+
echo "uv is required but not installed. See https://docs.astral.sh/uv/getting-started/installation/" >&2
16+
exit 1
1717
fi
18-
source scripts/env-types/bin/activate || exit 1
1918

20-
pip install -U pip > /dev/null || exit 1
21-
pip install -U wheel pytest-mypy mypy 1>/dev/null || exit 1
22-
pip install ./python 1>/dev/null || exit 1
23-
24-
git ls-files python/ | grep -e '\.py$' | xargs mypy
19+
git ls-files python/ | grep -e '\.py$' | xargs uvx --with ./python --with pytest mypy

0 commit comments

Comments
 (0)