mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-11-26 21:13:40 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1407b3af36 |
No files matched your search
+127
-158
@@ -1,10 +1,10 @@
|
||||
name: Check PHP Version Drift
|
||||
name: Check Python Version Drift
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Weekly on Monday at 08:00 UTC, after the Node.js and Python checks
|
||||
- cron: "0 8 * * 1"
|
||||
# Weekly on Monday at 07:00 UTC, an hour after the Node.js check
|
||||
- cron: "0 7 * * 1"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -12,7 +12,7 @@ permissions:
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
check-php-versions:
|
||||
check-python-versions:
|
||||
if: github.repository == 'community-scripts/ProxmoxVE'
|
||||
runs-on: coolify-runner
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq jq curl > /dev/null 2>&1
|
||||
|
||||
- name: Check upstream PHP versions
|
||||
- name: Check upstream Python versions
|
||||
id: check
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -35,10 +35,10 @@ jobs:
|
||||
set -euo pipefail
|
||||
|
||||
echo "================================================"
|
||||
echo " Checking PHP version drift in install scripts"
|
||||
echo " Checking Python version drift in install scripts"
|
||||
echo "================================================"
|
||||
|
||||
# Versions are compared minor-granular as major*100+minor: 8.4 -> 804.
|
||||
# Versions are compared minor-granular as major*100+minor: 3.12 -> 312.
|
||||
vstr() { echo "$(($1 / 100)).$(($1 % 100))"; }
|
||||
|
||||
# One comparison as a range. Sets T_LO / T_HI, empty when open.
|
||||
@@ -64,16 +64,20 @@ jobs:
|
||||
"<=")
|
||||
if [[ -n "$mi" ]]; then T_HI=$((maj * 100 + mi)); else T_HI=$((maj * 100 + 99)); fi
|
||||
;;
|
||||
"~=")
|
||||
T_LO=$((maj * 100 + ${mi:-0}))
|
||||
if [[ -n "$pat" ]]; then T_HI=$T_LO; else T_HI=$((maj * 100 + 99)); fi
|
||||
;;
|
||||
"^")
|
||||
T_LO=$((maj * 100 + ${mi:-0}))
|
||||
T_HI=$((maj * 100 + 99))
|
||||
;;
|
||||
"~")
|
||||
# Composer: ~8.2 is >=8.2 <9.0, ~8.2.1 is >=8.2.1 <8.3
|
||||
# Poetry: ~3.11 is >=3.11,<3.12
|
||||
T_LO=$((maj * 100 + ${mi:-0}))
|
||||
if [[ -n "$pat" ]]; then T_HI=$T_LO; else T_HI=$((maj * 100 + 99)); fi
|
||||
if [[ -n "$mi" ]]; then T_HI=$T_LO; else T_HI=$((maj * 100 + 99)); fi
|
||||
;;
|
||||
"" | "=" | "==")
|
||||
"" | "=" | "==" | "===")
|
||||
if [[ -n "$mi" ]]; then T_LO=$((maj * 100 + mi)) T_HI=$T_LO
|
||||
else T_LO=$((maj * 100)) T_HI=$((maj * 100 + 99)); fi
|
||||
;;
|
||||
@@ -81,33 +85,27 @@ jobs:
|
||||
esac
|
||||
}
|
||||
|
||||
# A Composer constraint as a range: space or comma = AND, | or || = OR,
|
||||
# "a - b" ranges, @stability flags. Sets C_MIN / C_MAX, empty when open.
|
||||
# requires-python (PEP 440) or a Poetry python constraint as a range:
|
||||
# comma = AND, || = OR. Sets C_MIN / C_MAX, empty when open.
|
||||
parse_constraint() {
|
||||
local spec="$1" alt part a_lo a_hi lo_open=0 hi_open=0 seen=0
|
||||
local -a alts parts
|
||||
C_MIN="" C_MAX=""
|
||||
spec=$(sed -E 's/@[a-zA-Z]+//g; s/(>=|<=|==|!=|>|<|\^|~)[[:space:]]+/\1/g' <<<"$spec")
|
||||
spec="${spec//[[:space:]]/}"
|
||||
spec="${spec//||/|}"
|
||||
IFS='|' read -ra alts <<<"$spec"
|
||||
for alt in "${alts[@]}"; do
|
||||
alt=$(sed -E 's/^[[:space:],]+|[[:space:],]+$//g' <<<"$alt")
|
||||
alt="${alt#,}"
|
||||
alt="${alt%,}"
|
||||
[[ -z "$alt" || "$alt" == "*" ]] && { lo_open=1; hi_open=1; seen=1; continue; }
|
||||
a_lo="" a_hi=""
|
||||
if [[ "$alt" =~ ^v?([0-9]+)(\.([0-9]+))?[^[:space:]]*[[:space:]]+-[[:space:]]+v?([0-9]+)(\.([0-9]+))? ]]; then
|
||||
a_lo=$((BASH_REMATCH[1] * 100 + ${BASH_REMATCH[3]:-0}))
|
||||
if [[ -n "${BASH_REMATCH[6]}" ]]; then a_hi=$((BASH_REMATCH[4] * 100 + BASH_REMATCH[6]))
|
||||
else a_hi=$((BASH_REMATCH[4] * 100 + 99)); fi
|
||||
else
|
||||
IFS=', ' read -ra parts <<<"$alt"
|
||||
for part in "${parts[@]}"; do
|
||||
[[ -z "$part" ]] && continue
|
||||
[[ "$part" =~ ^(==|!=|>=|<=|>|<|\^|~|=)?v?([0-9]+)(\.([0-9]+|\*))?(\.([0-9]+|\*))?(\.[0-9]+)*$ ]] || continue
|
||||
clause_range "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[4]}" "${BASH_REMATCH[6]}" || continue
|
||||
[[ -n "$T_LO" ]] && { [[ -z "$a_lo" ]] || ((T_LO > a_lo)); } && a_lo=$T_LO
|
||||
[[ -n "$T_HI" ]] && { [[ -z "$a_hi" ]] || ((T_HI < a_hi)); } && a_hi=$T_HI
|
||||
done
|
||||
fi
|
||||
IFS=',' read -ra parts <<<"$alt"
|
||||
for part in "${parts[@]}"; do
|
||||
[[ "$part" =~ ^(~=|===|==|!=|>=|<=|>|<|\^|~|=)?v?([0-9]+)(\.([0-9]+|\*))?(\.([0-9]+|\*))?(\.[0-9]+)*$ ]] || continue
|
||||
clause_range "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[4]}" "${BASH_REMATCH[6]}" || continue
|
||||
[[ -n "$T_LO" ]] && { [[ -z "$a_lo" ]] || ((T_LO > a_lo)); } && a_lo=$T_LO
|
||||
[[ -n "$T_HI" ]] && { [[ -z "$a_hi" ]] || ((T_HI < a_hi)); } && a_hi=$T_HI
|
||||
done
|
||||
seen=1
|
||||
if [[ -z "$a_lo" ]]; then lo_open=1; elif [[ -z "$C_MIN" ]] || ((a_lo < C_MIN)); then C_MIN=$a_lo; fi
|
||||
if [[ -z "$a_hi" ]]; then hi_open=1; elif [[ -z "$C_MAX" ]] || ((a_hi > C_MAX)); then C_MAX=$a_hi; fi
|
||||
@@ -118,8 +116,8 @@ jobs:
|
||||
return 0
|
||||
}
|
||||
|
||||
# Inside the range Composer enforces for the current script ($lo/$hi)
|
||||
within() { [[ -z "$lo" || "$1" -ge "$lo" ]] && [[ -z "$hi" || "$1" -le "$hi" ]]; }
|
||||
# Inside the range parse_constraint last set
|
||||
within() { [[ -z "$C_MIN" || "$1" -ge "$C_MIN" ]] && [[ -z "$C_MAX" || "$1" -le "$C_MAX" ]]; }
|
||||
|
||||
# Same name in the core sense (_forge_is_script_app): case and punctuation
|
||||
# ignored, equal, or one containing the other with the shorter at least 4 long.
|
||||
@@ -158,13 +156,16 @@ jobs:
|
||||
)
|
||||
}
|
||||
|
||||
# PHP a script pins: X.Y, "dynamic", or "unset" (core's default).
|
||||
php_version_of() {
|
||||
local v
|
||||
v=$(grep -oP '^[^#]*PHP_VERSION="?\K\d\.\d+' "$1" | head -1 || true)
|
||||
# Python a script pins: X.Y, "dynamic", or "unset" (uv then picks one
|
||||
# that satisfies the project's requires-python). setup_uv only installs
|
||||
# PYTHON_VERSION; the venv takes its version from --python and the like.
|
||||
python_version_of() {
|
||||
local f="$1" v
|
||||
v=$(grep -oP '^[^#]*PYTHON_VERSION="?\K3\.\d+' "$f" | head -1 || true)
|
||||
[[ -z "$v" ]] && v=$(grep -oP '^[^#]*(?:--python[ =]"?|-p "?python|uv python install "?|UV_PYTHON="?)\K3\.\d+' "$f" | head -1 || true)
|
||||
if [[ -n "$v" ]]; then
|
||||
echo "$v"
|
||||
elif grep -qE '^[^#]*PHP_VERSION=\$\(' "$1"; then
|
||||
elif grep -qE '^[^#]*PYTHON_VERSION=\$\(' "$f"; then
|
||||
echo "dynamic"
|
||||
else
|
||||
echo "unset"
|
||||
@@ -186,14 +187,13 @@ jobs:
|
||||
}
|
||||
|
||||
# Shallowest file of that name. Below the repo root it only counts in a
|
||||
# directory the scripts name, or for a Dockerfile in docker/ or build/:
|
||||
# a composer.json beside a side tool says nothing about the app we install.
|
||||
# Usage: fetch_file "composer.json" => sets REPLY to its content and
|
||||
# FETCHED_PATH to its path, both empty when there is none
|
||||
# directory the scripts name (apps/parser-api), or for a Dockerfile in
|
||||
# docker/ or build/: a pyproject.toml beside a side tool says nothing
|
||||
# about the app we install.
|
||||
# Usage: fetch_file "pyproject.toml" => sets REPLY to its content or empty
|
||||
fetch_file() {
|
||||
local name="$1" path="" p dir
|
||||
REPLY=""
|
||||
FETCHED_PATH=""
|
||||
if [[ -n "$TREE_PATHS" ]]; then
|
||||
while IFS= read -r p; do
|
||||
dir="${p%/*}"
|
||||
@@ -209,9 +209,6 @@ jobs:
|
||||
[[ -z "$path" && "$TREE_TRUNCATED" == "true" ]] && path="$name"
|
||||
[[ -z "$path" ]] && return
|
||||
REPLY=$(curl -sf "https://raw.githubusercontent.com/${REPO}/${BRANCH}/${path}" 2>/dev/null || echo "")
|
||||
if [[ -n "$REPLY" ]]; then
|
||||
FETCHED_PATH="$path"
|
||||
fi
|
||||
}
|
||||
|
||||
# Collect results
|
||||
@@ -224,23 +221,23 @@ jobs:
|
||||
|
||||
for script in install/*-install.sh; do
|
||||
[[ ! -f "$script" ]] && continue
|
||||
grep -qE '^[^#]*(\bsetup_php\b|PHP_VERSION=)' "$script" || continue
|
||||
grep -qE '^[^#]*(\bsetup_uv\b|PYTHON_VERSION=)' "$script" || continue
|
||||
|
||||
total=$((total + 1))
|
||||
slug=$(basename "$script" | sed 's/-install\.sh$//')
|
||||
our_version=$(php_version_of "$script")
|
||||
our_version=$(python_version_of "$script")
|
||||
|
||||
# The update has to set up the same PHP, or a bump in install/ reaches
|
||||
# new containers only. setup_php without PHP_VERSION switches to core's
|
||||
# default, so that counts as out of step too.
|
||||
# The update has to use the same Python, or a bump in install/
|
||||
# reaches new containers only: an existing venv keeps its version
|
||||
# until the update recreates it.
|
||||
ct_file="ct/${slug}.sh"
|
||||
ct_display="—"
|
||||
if [[ -f "$ct_file" ]] &&
|
||||
grep -qE '^[^#]*(\b(check_for|fetch_and_deploy)_|(^|[[:space:];&|(])(composer|php)[[:space:]])' "$ct_file"; then
|
||||
if grep -qE '^[^#]*\bsetup_php\b' "$ct_file"; then
|
||||
ct_version=$(php_version_of "$ct_file")
|
||||
else
|
||||
ct_version="none"
|
||||
grep -qE '^[^#]*(\b(check_for|fetch_and_deploy)_|(^|[[:space:];&|(])(uv|pip|pip3)[[:space:]])' "$ct_file"; then
|
||||
ct_version=$(python_version_of "$ct_file")
|
||||
# uv sync rebuilds the venv itself once requires-python excludes its Python
|
||||
if [[ "$ct_version" == "unset" ]] && grep -qE '^[^#]*\buv sync\b' "$ct_file"; then
|
||||
ct_version="$our_version"
|
||||
fi
|
||||
ct_display="$ct_version"
|
||||
if [[ "$ct_version" != "$our_version" ]]; then
|
||||
@@ -265,7 +262,7 @@ jobs:
|
||||
checked=$((checked + 1))
|
||||
|
||||
# A script that deploys a release is judged by that release: the default
|
||||
# branch may already target a PHP no release needs yet. Both the tree
|
||||
# branch may already target a Python no release needs yet. Both the tree
|
||||
# API and raw.githubusercontent.com resolve HEAD to the default branch.
|
||||
SCRIPT_TEXT=$(cat "$script" "$ct_file" 2>/dev/null || true)
|
||||
BRANCH="HEAD"
|
||||
@@ -281,85 +278,73 @@ jobs:
|
||||
fi
|
||||
load_tree
|
||||
|
||||
# Composer enforces a locked package's upper bound only when the script
|
||||
# runs it; a release that ships vendor/ is held to the lower bounds alone,
|
||||
# which its code needs at run time.
|
||||
runs_composer=0
|
||||
grep -qE '^[^#]*\bcomposer (install|update)\b' "$script" && runs_composer=1
|
||||
|
||||
# require.php is the project's own range; composer.lock beside it holds
|
||||
# what its locked packages need, and Composer refuses either breach.
|
||||
requires="" platform="" lock_lo="" lock_hi="" lock_lo_pkg="" lock_hi_pkg=""
|
||||
fetch_file "composer.json"
|
||||
if [[ -n "$REPLY" ]]; then
|
||||
requires=$(jq -r '.require.php // empty' <<<"$REPLY" 2>/dev/null || true)
|
||||
platform=$(jq -r '.config.platform.php // empty' <<<"$REPLY" 2>/dev/null | grep -oP '^\d\.\d+' || true)
|
||||
lock_path="composer.lock"
|
||||
[[ "$FETCHED_PATH" == */* ]] && lock_path="${FETCHED_PATH%/*}/composer.lock"
|
||||
lock=""
|
||||
if [[ "$TREE_TRUNCATED" == "true" ]] || grep -qxF "$lock_path" <<<"$TREE_PATHS"; then
|
||||
lock=$(curl -sf "https://raw.githubusercontent.com/${REPO}/${BRANCH}/${lock_path}" 2>/dev/null || echo "")
|
||||
fi
|
||||
if [[ -n "$lock" ]]; then
|
||||
while IFS=$'\t' read -r pkg spec; do
|
||||
[[ -z "$spec" ]] && continue
|
||||
parse_constraint "$spec"
|
||||
if [[ -n "$C_MIN" ]] && { [[ -z "$lock_lo" ]] || ((C_MIN > lock_lo)); }; then
|
||||
lock_lo=$C_MIN lock_lo_pkg="$pkg"
|
||||
fi
|
||||
if ((runs_composer)) && [[ -n "$C_MAX" ]] && { [[ -z "$lock_hi" ]] || ((C_MAX < lock_hi)); }; then
|
||||
lock_hi=$C_MAX lock_hi_pkg="$pkg"
|
||||
fi
|
||||
done < <(jq -r '.packages[]? | select(.require.php != null) | "\(.name)\t\(.require.php)"' <<<"$lock" 2>/dev/null || true)
|
||||
fi
|
||||
# uv sync takes the interpreter from requires-python itself, so a pin
|
||||
# outside that range is unused rather than broken.
|
||||
uv_sync=0
|
||||
if grep -qE '^[^#]*\buv sync\b' "$script" && ! grep -qE '^[^#]*\buv sync\b.*(--python|-p )' "$script"; then
|
||||
uv_sync=1
|
||||
fi
|
||||
|
||||
# What upstream runs: the last php image in the Dockerfile, else
|
||||
# config.platform.php, the version it resolves its lock against
|
||||
docker_php=""
|
||||
# requires-python (PEP 621), Poetry's python dependency, or setup.py/cfg
|
||||
requires=""
|
||||
fetch_file "pyproject.toml"
|
||||
if [[ -n "$REPLY" ]]; then
|
||||
requires=$(grep -oP '^\s*requires-python\s*=\s*["\x27]\K[^"\x27]+' <<<"$REPLY" | head -1 || true)
|
||||
[[ -z "$requires" ]] && requires=$(awk '
|
||||
/^\[/ { in_deps = ($0 ~ /^\[tool\.poetry\.dependencies\]/) }
|
||||
in_deps && /^[[:space:]]*python[[:space:]]*=/ { print; exit }' <<<"$REPLY" |
|
||||
grep -oP '=\s*["\x27]\K[^"\x27]+' || true)
|
||||
fi
|
||||
if [[ -z "$requires" ]]; then
|
||||
for f in setup.cfg setup.py; do
|
||||
fetch_file "$f"
|
||||
requires=$(grep -oP 'python_requires\s*=\s*["\x27]?\K[^"\x27\n]+' <<<"$REPLY" | head -1 | sed 's/[[:space:],]*$//' || true)
|
||||
[[ -n "$requires" ]] && break
|
||||
done
|
||||
fi
|
||||
|
||||
# What upstream runs: .python-version, else the last python image in the Dockerfile
|
||||
pyver_file=""
|
||||
fetch_file ".python-version"
|
||||
[[ -n "$REPLY" ]] && pyver_file=$(grep -oP '^\s*(?:cpython-)?\K3\.\d+' <<<"$REPLY" | head -1 || true)
|
||||
docker_py=""
|
||||
fetch_file "Dockerfile"
|
||||
if [[ -n "$REPLY" ]]; then
|
||||
docker_php=$(grep -oiP '^\s*FROM\s+(?:--platform=\S+\s+)?\S*?php[:-]?\K\d\.\d+(?![.\d]*-?(?:rc|alpha|beta))' <<<"$REPLY" | tail -1 || true)
|
||||
[[ -z "$docker_php" ]] && docker_php=$(grep -oP '\bphp\K\d\.\d+(?=-(?:fpm|cli|common))' <<<"$REPLY" | head -1 || true)
|
||||
fi
|
||||
[[ -n "$REPLY" ]] && docker_py=$(grep -oiP '^\s*FROM\s+(?:--platform=\S+\s+)?\S*?python:?\K3\.\d+(?![.\d]*-?(?:rc|alpha|beta|a\d|b\d))' <<<"$REPLY" | tail -1 || true)
|
||||
|
||||
rec="" rec_hint=""
|
||||
if [[ -n "$docker_php" ]]; then
|
||||
rec=$((${docker_php%%.*} * 100 + ${docker_php#*.})) rec_hint="Dockerfile"
|
||||
elif [[ -n "$platform" ]]; then
|
||||
rec=$((${platform%%.*} * 100 + ${platform#*.})) rec_hint="config.platform.php"
|
||||
if [[ -n "$pyver_file" ]]; then
|
||||
rec=$((${pyver_file%%.*} * 100 + ${pyver_file#*.})) rec_hint=".python-version"
|
||||
elif [[ -n "$docker_py" ]]; then
|
||||
rec=$((${docker_py%%.*} * 100 + ${docker_py#*.})) rec_hint="Dockerfile"
|
||||
fi
|
||||
|
||||
# The range Composer enforces: the project's, narrowed by its packages
|
||||
parse_constraint "$requires"
|
||||
lo="$C_MIN" hi="$C_MAX"
|
||||
lo_hint="require.php: $requires" hi_hint="require.php: $requires"
|
||||
if [[ -n "$lock_lo" ]] && { [[ -z "$lo" ]] || ((lock_lo > lo)); }; then
|
||||
lo=$lock_lo lo_hint="composer.lock: ${lock_lo_pkg} needs ≥$(vstr "$lock_lo")"
|
||||
fi
|
||||
if [[ -n "$lock_hi" ]] && { [[ -z "$hi" ]] || ((lock_hi < hi)); }; then
|
||||
hi=$lock_hi hi_hint="composer.lock: ${lock_hi_pkg} allows ≤$(vstr "$lock_hi")"
|
||||
fi
|
||||
|
||||
status="✅"
|
||||
target=""
|
||||
hint=""
|
||||
if [[ "$our_version" == "dynamic" ]]; then
|
||||
status="🔄 Dynamic"
|
||||
elif [[ "$our_version" == "unset" ]]; then
|
||||
status="🔄 core default (no version pinned)"
|
||||
status="🔄 uv picks (no version pinned)"
|
||||
else
|
||||
ours=$((${our_version%%.*} * 100 + ${our_version#*.}))
|
||||
if [[ -n "$lo" ]] && ((ours < lo)); then
|
||||
target=$lo
|
||||
if [[ -n "$C_MIN" ]] && ((ours < C_MIN)); then
|
||||
target=$C_MIN
|
||||
[[ -n "$rec" ]] && within "$rec" && ((rec > ours)) && target=$rec
|
||||
hint="$lo_hint"
|
||||
hint="requires-python: $requires"
|
||||
status="🔴 Too old → $(vstr "$target") ($hint)"
|
||||
elif [[ -n "$hi" ]] && ((ours > hi)); then
|
||||
target=$hi
|
||||
elif [[ -n "$C_MAX" ]] && ((ours > C_MAX)); then
|
||||
target=$C_MAX
|
||||
[[ -n "$rec" ]] && within "$rec" && target=$rec
|
||||
hint="$hi_hint"
|
||||
hint="requires-python: $requires"
|
||||
status="🔴 Too new → $(vstr "$target") ($hint)"
|
||||
elif [[ -n "$lo" || -n "$hi" ]]; then
|
||||
fi
|
||||
if [[ -n "$target" ]] && ((uv_sync)); then
|
||||
hint="uv sync follows requires-python: $requires"
|
||||
status="🔸 Pin unused → $(vstr "$target") ($hint)"
|
||||
elif [[ -n "$target" ]]; then
|
||||
:
|
||||
elif [[ -n "$requires" ]]; then
|
||||
[[ -n "$rec" && "$rec" -ne "$ours" ]] && status="✅ (upstream runs $(vstr "$rec") via $rec_hint)"
|
||||
elif [[ -n "$rec" ]] && ((ours < rec)); then
|
||||
target=$rec
|
||||
@@ -374,13 +359,9 @@ jobs:
|
||||
drift_count=$((drift_count + 1))
|
||||
fi
|
||||
|
||||
lock_display="—"
|
||||
if [[ -n "$lock_lo" || -n "$lock_hi" ]]; then
|
||||
lock_display="${lock_lo:+≥$(vstr "$lock_lo")}${lock_lo:+${lock_hi:+ }}${lock_hi:+≤$(vstr "$lock_hi")}"
|
||||
fi
|
||||
# A | inside a cell ends it
|
||||
requires_md="${requires:-—}"
|
||||
report_lines+=("| \`$slug\` | $our_version | $ct_display | ${requires_md//|/\\|} | $lock_display | ${docker_php:-—} | [$REPO](https://github.com/$REPO)$repo_note$ref_note | ${status//|/\\|} |")
|
||||
report_lines+=("| \`$slug\` | $our_version | $ct_display | ${requires_md//|/\\|} | ${pyver_file:-—} | ${docker_py:-—} | [$REPO](https://github.com/$REPO)$repo_note$ref_note | ${status//|/\\|} |")
|
||||
|
||||
# Rate-limit to avoid GitHub secondary rate limits
|
||||
sleep 0.3
|
||||
@@ -390,7 +371,7 @@ jobs:
|
||||
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo " Total scripts using PHP: $total"
|
||||
echo " Total scripts using Python: $total"
|
||||
echo " Checked (with GitHub source): $checked"
|
||||
echo " Version drift detected: $drift_count"
|
||||
echo " ct/ update out of step: $sync_count"
|
||||
@@ -407,13 +388,13 @@ jobs:
|
||||
printf '%s\n' "${sync_scripts[@]}" > /tmp/sync_scripts.txt 2>/dev/null || touch /tmp/sync_scripts.txt
|
||||
|
||||
{
|
||||
echo "## PHP Version Drift Report"
|
||||
echo "## Python Version Drift Report"
|
||||
echo ""
|
||||
echo "**Generated:** $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "**Scripts checked:** $total | **With GitHub source:** $checked | **Drift detected:** $drift_count | **ct/ out of step:** $sync_count"
|
||||
echo ""
|
||||
echo "| Script | Our Version | ct/ update | require.php | composer.lock | Dockerfile | Upstream Repo | Status |"
|
||||
echo "|--------|-------------|------------|-------------|---------------|------------|---------------|--------|"
|
||||
echo "| Script | Our Version | ct/ update | requires-python | .python-version | Dockerfile | Upstream Repo | Status |"
|
||||
echo "|--------|-------------|------------|-----------------|-----------------|------------|---------------|--------|"
|
||||
printf '%s\n' "${report_lines[@]}" | sort
|
||||
} > /tmp/drift_report.md
|
||||
|
||||
@@ -443,7 +424,7 @@ jobs:
|
||||
|
||||
# The branch name carries the exact bump: open means waiting for a
|
||||
# review, closed means someone said no to this bump.
|
||||
branch="php-drift/${slug}-${our}-to-${upstream}"
|
||||
branch="python-drift/${slug}-${our}-to-${upstream}"
|
||||
|
||||
existing=$(gh pr list --head "$branch" --state all \
|
||||
--json number,state,url,labels --jq '.[0] // empty' 2>/dev/null || echo "")
|
||||
@@ -475,19 +456,17 @@ jobs:
|
||||
|
||||
git checkout -q -B "$branch"
|
||||
|
||||
# PHP_VERSION plus the package, service, socket and /etc/php names.
|
||||
# PYTHON_VERSION plus the places a venv or uv names the version.
|
||||
old_re="${our//./\\.}"
|
||||
uv_re='(--python[ =]"?|-p "?python|uv python install "?|UV_PYTHON="?)'
|
||||
changed=()
|
||||
leftovers=""
|
||||
uses_fpm=0
|
||||
for f in "install/${slug}-install.sh" "ct/${slug}.sh"; do
|
||||
[[ -f "$f" ]] || continue
|
||||
grep -qE 'PHP_FPM="?YES|php[0-9.]*-fpm|php-fpm' "$f" && uses_fpm=1
|
||||
if grep -qE "PHP_VERSION=\"?${old_re}([^0-9]|$)|php${old_re}([^0-9]|$)|/php/${old_re}/" "$f"; then
|
||||
if grep -qE "(PYTHON_VERSION=\"?|${uv_re})${old_re}([^0-9]|$)" "$f"; then
|
||||
sed -i -E \
|
||||
-e "s/(PHP_VERSION=)\"?${old_re}\"?([^0-9]|$)/\1\"${upstream}\"\2/g" \
|
||||
-e "s/php${old_re}([^0-9]|$)/php${upstream}\1/g" \
|
||||
-e "s#/php/${old_re}/#/php/${upstream}/#g" "$f"
|
||||
-e "s/(PYTHON_VERSION=)\"?${old_re}(\.[0-9]+)?\"?/\1\"${upstream}\"/g" \
|
||||
-e "s/${uv_re}${old_re}([^0-9]|$)/\1${upstream}\2/g" "$f"
|
||||
changed+=("$f")
|
||||
fi
|
||||
rest=$(grep -nE "(^|[^0-9.])${old_re}([^0-9]|$)" "$f" | grep -vE '^[0-9]+:[[:space:]]*#' | head -10 || true)
|
||||
@@ -501,7 +480,7 @@ jobs:
|
||||
fi
|
||||
|
||||
git add "${changed[@]}"
|
||||
git commit -q -m "${slug}: bump PHP from ${our} to ${upstream}"
|
||||
git commit -q -m "${slug}: bump Python from ${our} to ${upstream}"
|
||||
|
||||
if ! git push -q -u origin "$branch" 2>/dev/null; then
|
||||
printf '%s|failed||\n' "$slug" >>/tmp/drift_prs.txt
|
||||
@@ -509,20 +488,10 @@ jobs:
|
||||
continue
|
||||
fi
|
||||
|
||||
# Only an update that runs setup_php with the new version moves an
|
||||
# existing container; renamed php${our} paths alone point it at nothing.
|
||||
ct_sets_php=0
|
||||
grep -qE "^[^#]*PHP_VERSION=\"?${upstream//./\\.}\"?[^0-9]" "ct/${slug}.sh" 2>/dev/null && ct_sets_php=1
|
||||
notes=""
|
||||
if [[ -f "ct/${slug}.sh" ]] && ((!ct_sets_php)); then
|
||||
if [[ -f "ct/${slug}.sh" && " ${changed[*]} " != *" ct/${slug}.sh "* ]]; then
|
||||
notes+="> [!WARNING]
|
||||
> \`ct/${slug}.sh\` runs no \`setup_php\` for ${upstream} in its update, so existing containers stay on PHP ${our}. Add \`PHP_VERSION=\"${upstream}\" setup_php\` to the update before merging.
|
||||
|
||||
"
|
||||
fi
|
||||
if ((uses_fpm && ct_sets_php)); then
|
||||
notes+="> [!IMPORTANT]
|
||||
> On the next update setup_php removes PHP ${our} and installs ${upstream}. The web server config an existing container got at install time still names \`php${our}-fpm\` (socket or service): the update has to switch it, or the site goes down.
|
||||
> \`ct/${slug}.sh\` names no Python ${our} in its update, so existing containers keep their venv on it. Make the update recreate the venv with ${upstream} before merging.
|
||||
|
||||
"
|
||||
fi
|
||||
@@ -538,9 +507,9 @@ jobs:
|
||||
# The test command is written here: a PR opened with GITHUB_TOKEN does
|
||||
# not start pr-test-command.yml.
|
||||
body=$(cat <<PR_EOF
|
||||
\`${slug}\` pins PHP **${our}**, upstream indicates **${upstream}** (${hint}) — [upstream repo](https://github.com/${repo}).
|
||||
\`${slug}\` pins Python **${our}**, upstream indicates **${upstream}** (${hint}) — [upstream repo](https://github.com/${repo}).
|
||||
|
||||
${notes}Opened automatically by the weekly PHP version drift check. **Nothing here has been tested.** Run it against a host before merging:
|
||||
${notes}Opened automatically by the weekly Python version drift check. **Nothing here has been tested.** Run it against a host before merging:
|
||||
|
||||
\`\`\`bash
|
||||
export COMMUNITY_SCRIPTS_URL=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${branch}
|
||||
@@ -557,7 +526,7 @@ jobs:
|
||||
# which runs on "opened". "keep-open" rather than "automated pr", which
|
||||
# changelog-pr.yml drops.
|
||||
if url=$(gh pr create \
|
||||
--title "${slug}: bump PHP from ${our} to ${upstream}" \
|
||||
--title "${slug}: bump Python from ${our} to ${upstream}" \
|
||||
--body "$body" \
|
||||
--base main \
|
||||
--head "$branch" \
|
||||
@@ -582,7 +551,7 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
TITLE="[Automated] PHP Version Drift Report"
|
||||
TITLE="[Automated] Python Version Drift Report"
|
||||
DATE=$(date -u +%Y-%m-%d)
|
||||
DRIFT_COUNT="${{ steps.check.outputs.drift_count }}"
|
||||
SYNC_COUNT="${{ steps.check.outputs.sync_count }}"
|
||||
@@ -605,7 +574,7 @@ jobs:
|
||||
open) mark="- [ ]"; note="— ${pr_url}" ;;
|
||||
declined) mark="- [x]"; note="— declined in ${pr_url}, not proposed again" ;;
|
||||
merged) mark="- [x]"; note="— merged in ${pr_url}" ;;
|
||||
manual) mark="- [ ]"; note="— needs a manual change (no fixed PHP version to rewrite)" ;;
|
||||
manual) mark="- [ ]"; note="— needs a manual change (no fixed Python version to rewrite)" ;;
|
||||
failed) mark="- [ ]"; note="— could not open a PR automatically" ;;
|
||||
*) mark="- [ ]"; note="" ;;
|
||||
esac
|
||||
@@ -616,7 +585,7 @@ jobs:
|
||||
SYNC_SECTION=""
|
||||
if [[ "$SYNC_COUNT" != "0" ]]; then
|
||||
SYNC_SECTION="### ct/ update out of step with install/"$'\n\n'
|
||||
SYNC_SECTION+="The update does not set up the install's PHP, so a bump reaches new containers only. \`none\` means the update has no setup_php; \`unset\` means it switches to core's default."$'\n\n'
|
||||
SYNC_SECTION+="The update does not use the install's Python, so a bump reaches new containers only: an existing venv keeps its version until the update recreates it."$'\n\n'
|
||||
while IFS='|' read -r slug our_version ct_version; do
|
||||
[[ -z "$slug" ]] && continue
|
||||
SYNC_SECTION+="- [ ] **\`${slug}\`** — install/: \`${our_version}\`, ct/ update: \`${ct_version}\`"$'\n'
|
||||
@@ -626,11 +595,11 @@ jobs:
|
||||
REPORT=$(cat /tmp/drift_report.md)
|
||||
|
||||
BODY=$(cat <<ISSUE_EOF
|
||||
## PHP Version Drift Report — ${DATE}
|
||||
## Python Version Drift Report — ${DATE}
|
||||
|
||||
**${DRIFT_COUNT}** script(s) with version drift detected (out of ${CHECKED} checked / ${TOTAL} total), **${SYNC_COUNT}** ct/ update(s) out of step.
|
||||
|
||||
🔴 means our PHP is outside what Composer accepts (\`require.php\` or a locked package), so the install breaks. 🔸 means upstream runs a newer PHP and declares no range.
|
||||
🔴 means our Python is outside upstream's \`requires-python\`, so the install breaks. 🔸 *Pin unused* means the install runs \`uv sync\`, which takes its Python from \`requires-python\`, so the pin only installs an interpreter nobody uses. 🔸 *Drift* means upstream runs a newer Python and declares no range.
|
||||
|
||||
### Scripts requiring investigation
|
||||
|
||||
@@ -642,8 +611,8 @@ jobs:
|
||||
|
||||
Each item above has its own pull request with the bump applied and a ready-to-run test command in the description.
|
||||
|
||||
1. Check upstream's composer.json / Dockerfile to confirm the PHP version
|
||||
2. Run the test command from the PR against a host: a fresh install and an update of an existing container
|
||||
1. Check upstream's pyproject.toml / Dockerfile to confirm the Python version
|
||||
2. Run the test command from the PR against a host
|
||||
3. Merge the PR if it works — the item disappears from this list on the next run
|
||||
4. Close the PR if the bump is wrong: this exact bump is never proposed again
|
||||
|
||||
@@ -655,12 +624,12 @@ jobs:
|
||||
</details>
|
||||
|
||||
---
|
||||
*This issue is automatically created/updated weekly by the PHP version drift check workflow.*
|
||||
*This issue is automatically created/updated weekly by the Python version drift check workflow.*
|
||||
*Last updated: ${DATE}*
|
||||
ISSUE_EOF
|
||||
)
|
||||
|
||||
EXISTING=$(gh issue list --state open --label "automated,dependencies" --search "\"[Automated] PHP Version Drift Report\"" --json number --jq '.[0].number // empty' 2>/dev/null || echo "")
|
||||
EXISTING=$(gh issue list --state open --label "automated,dependencies" --search "\"[Automated] Python Version Drift Report\"" --json number --jq '.[0].number // empty' 2>/dev/null || echo "")
|
||||
|
||||
if [[ -n "$EXISTING" ]]; then
|
||||
gh issue edit "$EXISTING" --body "$BODY"
|
||||
@@ -678,8 +647,8 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
EXISTING=$(gh issue list --state open --label "automated,dependencies" --search "\"[Automated] PHP Version Drift Report\"" --json number --jq '.[0].number // empty' 2>/dev/null || echo "")
|
||||
EXISTING=$(gh issue list --state open --label "automated,dependencies" --search "\"[Automated] Python Version Drift Report\"" --json number --jq '.[0].number // empty' 2>/dev/null || echo "")
|
||||
if [[ -n "$EXISTING" ]]; then
|
||||
gh issue close "$EXISTING" --comment "All PHP versions are in sync with upstream. Closing automatically."
|
||||
gh issue close "$EXISTING" --comment "All Python versions are in sync with upstream. Closing automatically."
|
||||
echo "Closed issue #$EXISTING"
|
||||
fi
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
name: Record closed PHP drift PR
|
||||
name: Record closed Python drift PR
|
||||
|
||||
# The drift check opens one PR per script and treats a closed one as a verdict:
|
||||
# that bump is not proposed again. Record it on the report so the decision is
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
if: >
|
||||
github.repository == 'community-scripts/ProxmoxVE' &&
|
||||
github.event.pull_request.merged == false &&
|
||||
startsWith(github.event.pull_request.head.ref, 'php-drift/')
|
||||
startsWith(github.event.pull_request.head.ref, 'python-drift/')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
@@ -25,8 +25,8 @@ jobs:
|
||||
const owner = context.repo.owner;
|
||||
const repo = context.repo.repo;
|
||||
|
||||
// php-drift/<slug>-<from>-to-<to>
|
||||
const m = pr.head.ref.match(/^php-drift\/(.+)-(\d+\.\d+)-to-(\d+\.\d+)$/);
|
||||
// python-drift/<slug>-<from>-to-<to>
|
||||
const m = pr.head.ref.match(/^python-drift\/(.+)-(\d+\.\d+)-to-(\d+\.\d+)$/);
|
||||
if (!m) return;
|
||||
const [, slug, from, to] = m;
|
||||
|
||||
@@ -38,15 +38,15 @@ jobs:
|
||||
owner, repo, state: 'open', labels: 'automated,dependencies', per_page: 100,
|
||||
});
|
||||
const issue = issues.data.find(
|
||||
(i) => !i.pull_request && i.title === '[Automated] PHP Version Drift Report',
|
||||
(i) => !i.pull_request && i.title === '[Automated] Python Version Drift Report',
|
||||
);
|
||||
if (!issue) return;
|
||||
|
||||
const body = stale
|
||||
? `\`${slug}\` — PR #${pr.number} (PHP ${from} → ${to}) was closed as stale. `
|
||||
? `\`${slug}\` — PR #${pr.number} (Python ${from} → ${to}) was closed as stale. `
|
||||
+ `No decision was recorded, so the next drift check opens it again.`
|
||||
: `\`${slug}\` — PR #${pr.number} (PHP ${from} → ${to}) was closed without merging. `
|
||||
+ `The script keeps PHP ${from} and this bump will not be proposed again. `
|
||||
: `\`${slug}\` — PR #${pr.number} (Python ${from} → ${to}) was closed without merging. `
|
||||
+ `The script keeps Python ${from} and this bump will not be proposed again. `
|
||||
+ `If it was closed by mistake, reopen the PR.`;
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
Reference in new issue
Block a user