ci(scripts): lock either root requirements file
The molecule-controller image gets a requirements file and lock of its own (ADR 0003), so the lock script takes the file to lock: requirements-dev.txt by default, as before, or requirements-molecule.txt. Any other argument is a usage error, so a typo cannot write a lock somewhere else. The new test runs the script against a stub interpreter, so it needs no network. Refs #477 Assisted-by: Claude Code
This commit is contained in:
1 parent
0173f6f226
commit
26c6026d1a
2 files changed
+105
-10
No files matched your search
@@ -2,16 +2,17 @@
|
||||
# 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).
|
||||
# Regenerate the hashed lock of a root requirements file: requirements-dev.txt (Lint and Build, the
|
||||
# default) or requirements-molecule.txt (the molecule-controller image) into the .lock of the same name.
|
||||
#
|
||||
# scripts/lock-requirements.sh re-resolve, keeping every locked version that still fits
|
||||
# scripts/lock-requirements.sh --upgrade move every package, transitive ones included, to its newest release
|
||||
# scripts/lock-requirements.sh [FILE] re-resolve, keeping every locked version that still fits
|
||||
# scripts/lock-requirements.sh --upgrade [FILE] move every package, transitive ones included, to its newest release
|
||||
#
|
||||
# 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
|
||||
# the lock with requirements-dev.txt; pip refuses an install of the two when they disagree
|
||||
# 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
|
||||
# created the throwaway venv.
|
||||
@@ -25,12 +26,19 @@ set -euo pipefail
|
||||
|
||||
pip_version="25.2"
|
||||
pip_tools_version="7.6.2"
|
||||
usage="usage: lock-requirements.sh [--upgrade] [requirements-dev.txt|requirements-molecule.txt]"
|
||||
upgrade=()
|
||||
case "${1:-}" in
|
||||
"") ;;
|
||||
--upgrade) upgrade=(--upgrade) ;;
|
||||
*) echo "usage: lock-requirements.sh [--upgrade]" >&2; exit 2 ;;
|
||||
if [ "${1:-}" = "--upgrade" ]; then
|
||||
upgrade=(--upgrade)
|
||||
shift
|
||||
fi
|
||||
requirements="${1:-requirements-dev.txt}"
|
||||
case "$requirements" in
|
||||
requirements-dev.txt|requirements-molecule.txt) ;;
|
||||
*) echo "$usage" >&2; exit 2 ;;
|
||||
esac
|
||||
[ "$#" -le 1 ] || { echo "$usage" >&2; exit 2; }
|
||||
lock="${requirements%.txt}.lock"
|
||||
|
||||
root="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/.." && pwd)"
|
||||
[ -f "$root/.python-version" ] || { echo "error: .python-version is missing (the Python of the lock, a clone and the ci image)" >&2; exit 1; }
|
||||
@@ -54,5 +62,5 @@ 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 \
|
||||
"${upgrade[@]}" --output-file requirements-dev.lock requirements-dev.txt
|
||||
echo "requirements-dev.lock regenerated; commit it with requirements-dev.txt."
|
||||
"${upgrade[@]}" --output-file "$lock" "$requirements"
|
||||
echo "$lock regenerated; commit it with $requirements."
|
||||
Reference in new issue
Block a user