Merge branch 'main' into feat/482-pve-vm-role
This commit is contained in:
commit
773de8eba4
32 files changed
+1433
-101
No files matched your search
@@ -6,11 +6,12 @@
|
||||
|
||||
When <head-ref> starts with `renovate/`, the diff of <base-ref>...HEAD may only touch:
|
||||
|
||||
* requirements-dev.txt: pinned `name==version` lines, the same packages before and after;
|
||||
* requirements-dev.lock (pip-compile --generate-hashes output): `name==version` entries,
|
||||
`--hash=sha256:<64 hex>` lines and plain `# via` or prose comments, nothing else; packages may
|
||||
be added or removed (a transitive dependency), but the `# pip-compile ...` command in the
|
||||
header, which Renovate runs again, must stay as it is;
|
||||
* requirements-dev.txt and requirements-molecule.txt: pinned `name==version` lines, the same
|
||||
packages before and after;
|
||||
* requirements-dev.lock and requirements-molecule.lock (pip-compile --generate-hashes output):
|
||||
`name==version` entries, `--hash=sha256:<64 hex>` lines and plain `# via` or prose comments,
|
||||
nothing else; packages may be added or removed (a transitive dependency), but the
|
||||
`# pip-compile ...` command in the header, which Renovate runs again, must stay as it is;
|
||||
* requirements.yml and extensions/molecule/requirements.yml: `version:` lines (the collection
|
||||
names, and every other line, stay);
|
||||
* .pre-commit-config.yaml: `rev:` lines (a tag, or a commit SHA with its `# frozen: <tag>` comment);
|
||||
@@ -69,6 +70,9 @@ UBUNTU_LINE = re.compile(
|
||||
)
|
||||
DOCKERFILE = re.compile(r"images/[^/]+/Dockerfile")
|
||||
COLLECTION_PINS = {"requirements.yml", "extensions/molecule/requirements.yml"}
|
||||
# Lint's and the molecule-controller image's requirements, each with its pip-compile lock.
|
||||
REQUIREMENTS = {"requirements-dev.txt", "requirements-molecule.txt"}
|
||||
LOCKS = {"requirements-dev.lock", "requirements-molecule.lock"}
|
||||
CONSUMERS = {
|
||||
".gitea/workflows/lint.yml",
|
||||
".gitea/workflows/build.yml",
|
||||
@@ -108,7 +112,7 @@ def reduce_version(line):
|
||||
return "version" if VERSION_LINE.match(line) else None
|
||||
|
||||
|
||||
# requirements-dev.lock: an entry (with an optional environment marker), a hash, or a comment.
|
||||
# A lock: an entry (with an optional environment marker), a hash, or a comment.
|
||||
# The marker and the prose comment use a small character set: no backslash, quote of a shell, `$` or `--`.
|
||||
LOCK_ENTRY = re.compile(
|
||||
r"^[A-Za-z0-9][A-Za-z0-9._-]*==[0-9][0-9A-Za-z.+!_-]*"
|
||||
@@ -122,7 +126,7 @@ LOCK_COMMENT = re.compile(
|
||||
|
||||
|
||||
def lock_problem(removed, added):
|
||||
"""None when every changed line of requirements-dev.lock is an entry, a hash or a plain comment and
|
||||
"""None when every changed line of a lock is an entry, a hash or a plain comment and
|
||||
the `# pip-compile ...` command line is the same on both sides."""
|
||||
for line in removed + added:
|
||||
if LOCK_COMMAND.match(line):
|
||||
@@ -165,14 +169,14 @@ def reduce_pin(line):
|
||||
|
||||
def file_problem(path, removed, added):
|
||||
"""One-line reason why the change to `path` is not allowed for a bot, or None."""
|
||||
if path == "requirements-dev.txt":
|
||||
if path in REQUIREMENTS:
|
||||
return same_shape(
|
||||
removed,
|
||||
added,
|
||||
reduce_requirement,
|
||||
"a pinned `name==version` line of the same package",
|
||||
)
|
||||
if path == "requirements-dev.lock":
|
||||
if path in LOCKS:
|
||||
return lock_problem(removed, added)
|
||||
if path in COLLECTION_PINS:
|
||||
return same_shape(removed, added, reduce_version, "a `version:` line")
|
||||
|
||||
@@ -386,6 +386,10 @@ def check_pins(matrix, consumer_texts):
|
||||
|
||||
PYTHON_PIN_FILE = ".python-version"
|
||||
LOCK_FILE = "requirements-dev.lock"
|
||||
# The molecule-controller image's lock (ADR 0003).
|
||||
MOLECULE_LOCK_FILE = "requirements-molecule.lock"
|
||||
LOCK_FILES = (LOCK_FILE, MOLECULE_LOCK_FILE)
|
||||
ANSIBLE_CORE_RE = re.compile(r"^ansible-core==([^\s;\\]+)", re.MULTILINE)
|
||||
PYTHON_PIN_RE = re.compile(r"[0-9]+\.[0-9]+")
|
||||
LOCK_PYTHON_RE = re.compile(
|
||||
r"^# This file is autogenerated by pip-compile with Python ([0-9]+\.[0-9]+)\s*$",
|
||||
@@ -397,25 +401,27 @@ ARG_PYTHON_RE = re.compile(
|
||||
)
|
||||
|
||||
|
||||
def check_python_pin(pin_text, lock_text, dockerfiles):
|
||||
"""Errors where the Python of .python-version, the header of requirements-dev.lock and the
|
||||
def check_python_pin(pin_text, locks, dockerfiles):
|
||||
"""Errors where the Python of .python-version, the header of each lock (path -> text) and the
|
||||
`ARG PYTHON_VERSION=` of an image Dockerfile (path -> text) are not one MAJOR.MINOR version. A
|
||||
clone's virtualenv (scripts/dev-setup.sh) and the ci image's /opt/venv use the first, the lock
|
||||
records the third as the interpreter it was resolved on; at least one Dockerfile must carry the ARG."""
|
||||
clone's virtualenv (scripts/dev-setup.sh) and the images' /opt/venv use the first, a lock
|
||||
records it as the interpreter it was resolved on; at least one Dockerfile must carry the ARG."""
|
||||
pin = pin_text.strip()
|
||||
if not PYTHON_PIN_RE.fullmatch(pin):
|
||||
return [f"{PYTHON_PIN_FILE} must hold one MAJOR.MINOR version, found {pin!r}"]
|
||||
errors = []
|
||||
header = LOCK_PYTHON_RE.search(lock_text)
|
||||
if not header:
|
||||
errors.append(
|
||||
f"{LOCK_FILE}: no 'autogenerated by pip-compile with Python X.Y' header"
|
||||
)
|
||||
elif header.group(1) != pin:
|
||||
errors.append(
|
||||
f"{LOCK_FILE}: header says Python {header.group(1)} but {PYTHON_PIN_FILE} is {pin}; "
|
||||
"regenerate it with scripts/lock-requirements.sh"
|
||||
)
|
||||
for path, lock_text in locks.items():
|
||||
header = LOCK_PYTHON_RE.search(lock_text)
|
||||
if not header:
|
||||
errors.append(
|
||||
f"{path}: no 'autogenerated by pip-compile with Python X.Y' header"
|
||||
)
|
||||
elif header.group(1) != pin:
|
||||
requirements = path.removesuffix(".lock") + ".txt"
|
||||
errors.append(
|
||||
f"{path}: header says Python {header.group(1)} but {PYTHON_PIN_FILE} is {pin}; "
|
||||
f"regenerate it with scripts/lock-requirements.sh {requirements}"
|
||||
)
|
||||
carriers = 0
|
||||
for path, text in dockerfiles.items():
|
||||
for arg in ARG_PYTHON_RE.findall(text):
|
||||
@@ -431,6 +437,25 @@ def check_python_pin(pin_text, lock_text, dockerfiles):
|
||||
return errors
|
||||
|
||||
|
||||
def check_ansible_core_pins(locks):
|
||||
"""Errors where the locks (path -> text) do not pin one ansible-core version: Lint runs the one of
|
||||
requirements-dev.lock and Molecule the one of requirements-molecule.lock, and both judge the same code."""
|
||||
errors, versions = [], {}
|
||||
for path, text in locks.items():
|
||||
m = ANSIBLE_CORE_RE.search(text)
|
||||
if m:
|
||||
versions[path] = m[1]
|
||||
else:
|
||||
errors.append(f"{path}: no ansible-core== entry")
|
||||
if len(set(versions.values())) > 1:
|
||||
pins = ", ".join(f"{path} {version}" for path, version in versions.items())
|
||||
errors.append(
|
||||
f"the locks pin different ansible-core versions ({pins}); Lint and Molecule must run one "
|
||||
"ansible-core, so move both pins in the same pull request"
|
||||
)
|
||||
return errors
|
||||
|
||||
|
||||
JOB_IMAGE_RE = re.compile(r"ubuntu:(?P<release>[0-9]+\.[0-9]+)@sha256:[0-9a-f]{64}")
|
||||
CONTAINER_LINE_RE = re.compile(
|
||||
r"^\s*container:[ \t]*\n\s*image:\s*\$\{\{\s*matrix\.job_image\s*\}\}[ \t]*$",
|
||||
@@ -671,11 +696,11 @@ def run(argv):
|
||||
if pathlib.Path(path).exists():
|
||||
dockerfiles[path] = pathlib.Path(path).read_text()
|
||||
try:
|
||||
locks = {lock: pathlib.Path(lock).read_text() for lock in LOCK_FILES}
|
||||
errors += check_python_pin(
|
||||
pathlib.Path(PYTHON_PIN_FILE).read_text(),
|
||||
pathlib.Path(LOCK_FILE).read_text(),
|
||||
dockerfiles,
|
||||
pathlib.Path(PYTHON_PIN_FILE).read_text(), locks, dockerfiles
|
||||
)
|
||||
errors += check_ansible_core_pins(locks)
|
||||
except OSError as exc:
|
||||
errors.append(f"cannot read the Python pin files: {exc}")
|
||||
workflows = (
|
||||
|
||||
@@ -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."
|
||||
@@ -135,7 +135,13 @@ class Registry:
|
||||
def tags(self):
|
||||
tags, path = [], "tags/list"
|
||||
while path:
|
||||
body, headers = self._get(path)
|
||||
try:
|
||||
body, headers = self._get(path)
|
||||
except RegistryError as exc:
|
||||
# A repository not pushed yet is 404 NAME_UNKNOWN (OCI distribution spec): no tags.
|
||||
if exc.status == 404 and not tags:
|
||||
return []
|
||||
raise
|
||||
tags += body.get("tags") or []
|
||||
link = re.search(r"<[^>]*/tags/list(\?[^>]*)>", headers.get("Link", ""))
|
||||
path = f"tags/list{link[1]}" if link else None
|
||||
|
||||
Reference in new issue
Block a user