Refs #113. - .pre-commit-config.yaml: every hook repo is pinned by commit SHA with the release in a `# frozen:` comment, so a moved tag cannot change the code a hook environment is built from. - requirements-dev.lock: hashed lock of requirements-dev.txt, installed with `pip install --require-hashes` by scripts/dev-setup.sh, the ci image and the fallback install of the Lint and Build workflows. - scripts/lock-requirements.sh regenerates the lock; scripts/check_requirements_lock.py (offline, a pre-commit hook) fails when it drifts from the direct pins. - check_bot_pr_diff.py accepts a `rev:` line with a `# frozen:` comment and nothing else. - ci image 0.2.16 -> 0.2.17 (image inputs changed).
37 lines
1.7 KiB
Bash
Executable File
37 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: Defame1297 and contributors
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
#
|
|
# Regenerate requirements-dev.lock, the hashed lock of requirements-dev.txt (#113).
|
|
#
|
|
# scripts/lock-requirements.sh
|
|
#
|
|
# Needs the network (PyPI) and Python 3.13+ (ansible-core 2.22; KAMINO_PYTHON overrides python3).
|
|
# pip-tools is installed, at the pinned version below, into a throwaway virtualenv, never into
|
|
# the project's .venv. Run it in the same pull request as any change to requirements-dev.txt,
|
|
# then commit both files: scripts/check_requirements_lock.py (a pre-commit hook and the Lint job)
|
|
# fails when they disagree. An image input changed, so the image version needs its bump as usual
|
|
# (python3 scripts/bump_image_versions.py).
|
|
set -euo pipefail
|
|
|
|
pip_tools_version="7.5.2"
|
|
python="${KAMINO_PYTHON:-python3}"
|
|
if ! "$python" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 13) else 1)' 2>/dev/null; then
|
|
echo "error: $python is missing or older than 3.13; set KAMINO_PYTHON=/path/to/python3.13" >&2
|
|
exit 1
|
|
fi
|
|
|
|
root="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)"
|
|
tmp="$(mktemp -d)"
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
"$python" -m venv "$tmp/venv"
|
|
"$tmp/venv/bin/pip" install --quiet --disable-pip-version-check "pip-tools==${pip_tools_version}"
|
|
cd "$root"
|
|
# --allow-unsafe: setuptools is a dependency of a tool here, and pip refuses an unpinned
|
|
# requirement in a file that carries hashes.
|
|
"$tmp/venv/bin/pip-compile" --quiet --generate-hashes --strip-extras --allow-unsafe --newline lf \
|
|
--output-file requirements-dev.lock requirements-dev.txt
|
|
python3 scripts/check_requirements_lock.py
|
|
echo "requirements-dev.lock regenerated; commit it with requirements-dev.txt."
|