chore(dev): move the dev tools from .venv to .venv-dev
Build / build (pull_request) Successful in 34s
Molecule / select (pull_request) Successful in 3s
Molecule / scenarios (pull_request) Skipped
Molecule / Result (pull_request) Successful in 1s
Lint / lint (pull_request) Successful in 1m49s

uv uses .venv as its project environment, and `uv sync --frozen` removes
every package that is not in uv.lock. The tools the git hooks need would
go with it, so they get a directory of their own.

Re-running scripts/dev-setup.sh switches the hooks of an older clone and
leaves its .venv alone. Ignore rules and prunes cover both directories.

Refs: #516
Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-12-04 20:45:49 +00:00
1 parent b7b763e1fa
commit f62097a748
12 files changed
+51 -23

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ cd "$root"
for tool in ansible ansible-test; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv/bin)" >&2
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv-dev/bin)" >&2
exit 1
fi
done
+1 -1
View File
@@ -27,7 +27,7 @@ allow list. It fails the build for:
ansible-galaxy dereferences FILE symlinks while building, so a symlink to a file reaches
the archive as a regular file with the target's content and this check cannot see it. The
`Refuse symlinks in the source tree` step of .gitea/workflows/build.yml is the only guard
against that. Its `find` prunes ./.venv and ./.git only because both are in galaxy.yml
against that. Its `find` prunes ./.git, ./.venv and ./.venv-dev only because they are in galaxy.yml
`build_ignore` (or excluded by ansible-galaxy itself, as .git is): the two lists must stay
in step, and tests/scripts/test_check_tarball.py fails when a pruned directory is not
ignored by the build.
+9 -9
View File
@@ -26,7 +26,7 @@ set -euo pipefail
# The repository is derived from this script's own location (symlinks resolved), never
# from the caller's working directory: running it from another repository must not
# create or remove that repository's .venv.
# create or remove that repository's .venv-dev.
script="$(readlink -f "${BASH_SOURCE[0]}")"
root="$(git -C "$(dirname "$script")/.." rev-parse --show-toplevel)"
cd "$root"
@@ -122,19 +122,19 @@ if still="$(git -C "$root" config --get core.hooksPath)" && [ -n "$still" ]; the
fi
# A virtualenv made by an older Python is rebuilt rather than reused.
if [ -x .venv/bin/python ] && ! .venv/bin/python -c "$py_ok" 2>/dev/null; then
rm -rf "$root/.venv"
if [ -x .venv-dev/bin/python ] && ! .venv-dev/bin/python -c "$py_ok" 2>/dev/null; then
rm -rf "$root/.venv-dev"
fi
[ -x .venv/bin/python ] || "$python" -m venv .venv
.venv/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
.venv/bin/pre-commit install --install-hooks
[ -x .venv-dev/bin/python ] || "$python" -m venv .venv-dev
.venv-dev/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
.venv-dev/bin/pre-commit install --install-hooks
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
# git and by the Collection build). ANSIBLE_COLLECTIONS_PATH is set to the target for the install:
# a copy found elsewhere (~/.ansible/collections) would be skipped as already installed.
collections="$root/.ansible/collections"
mkdir -p "$collections"
ANSIBLE_COLLECTIONS_PATH="$collections" .venv/bin/ansible-galaxy collection install \
ANSIBLE_COLLECTIONS_PATH="$collections" .venv-dev/bin/ansible-galaxy collection install \
-r requirements.yml -p "$collections"
marker="# kamino-dev-setup: virtualenv first on PATH"
@@ -150,7 +150,7 @@ for hook in pre-commit commit-msg pre-push; do
{
head -n 1 "$file"
# %q shell-quotes the path: a repository path with spaces, quotes or $(...) is data.
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv/bin"):\"\$PATH\""
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv-dev/bin"):\"\$PATH\""
tail -n +2 "$file"
} > "$tmp"
cat "$tmp" > "$file" # keeps the file mode of the hook
@@ -179,4 +179,4 @@ else
fi
fi
echo "Done: git commit now runs the hooks with the tools in $root/.venv/bin and the collections in $collections."
echo "Done: git commit now runs the hooks with the tools in $root/.venv-dev/bin and the collections in $collections."
+1 -1
View File
@@ -11,7 +11,7 @@
# Needs the network (PyPI) and the Python of .python-version (python<MINOR>; KAMINO_PYTHON overrides it): the
# header of the lock records it, and check_image_versions.py pins fails when it differs.
# pip and pip-tools are installed, at the pinned versions below, into a throwaway virtualenv, never
# into the project's .venv. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
# into the project's .venv-dev. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
# the lock with its requirements file; pip refuses an install of the two when they disagree
# (`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`).
# The pins are not hash-checked themselves: they come from PyPI over TLS, like the pip that