From 548a6d92ec1986d51298c858037b00be72510e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B6gl-Brunner=20Michel?= Date: Thu, 12 Nov 2026 12:04:56 +0100 Subject: [PATCH] pr-script-test: upgrade test only in ProxmoxVE, and only for a changed update_script --- .github/workflows/pr-script-test.yml | 29 +++++++++++++------ .../workflows/scripts/ci-controller-setup.sh | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-script-test.yml b/.github/workflows/pr-script-test.yml index c7e04ec13..34d049f1e 100644 --- a/.github/workflows/pr-script-test.yml +++ b/.github/workflows/pr-script-test.yml @@ -259,19 +259,30 @@ jobs: } const include = []; - // Upgrade test: a ct/ script that already exists on the PR's base - // branch is also installed from there and then updated with the PR, - // as a user who installed before the merge would. New scripts have - // nothing to upgrade from. Proxmox only, once per script. + // Upgrade test: install the ct/ script from the PR's base branch, + // then update with the PR, as a user who installed before the merge + // would. Only in ProxmoxVE, where users have installed it, and only + // when the PR changes update_script(): with the same update code an + // existing install updates exactly as it does today. New scripts + // have nothing to upgrade from. Proxmox only, once per script. + const UPGRADE_REPO = 'community-scripts/ProxmoxVE'; let baseSha = ''; - if (!isIssue) { + if (!isIssue && `${owner}/${repo}` === UPGRADE_REPO) { const { data: b } = await github.rest.repos.getBranch({ owner, repo, branch: pr.base.ref }); baseSha = b.commit.sha; } - const onBase = async p => { + // From `function update_script() {` to the first `}` at the start of + // a line; null without one. + const updateCode = t => ((t || '').match(/^(function[ \t]+)?update_script[ \t]*\(\)[ \t]*\{[\s\S]*?^\}/m) || [null])[0]; + const updateChanged = async (p, headText) => { if (!baseSha) return false; - try { await github.rest.repos.getContent({ owner, repo, path: p, ref: baseSha }); return true; } - catch (e) { return false; } + let baseText; + try { + const res = await github.rest.repos.getContent({ owner, repo, path: p, ref: baseSha }); + baseText = Buffer.from(res.data.content || '', 'base64').toString('utf8'); + } catch (e) { return false; } + const before = updateCode(baseText), after = updateCode(headText); + return before !== null && after !== null && before !== after; }; const fetchScript = async p => { try { @@ -319,7 +330,7 @@ jobs: for (const platform of platforms) { for (const os of oses) include.push({ script, os, platform, arm64: platform === 'arm' ? arm : '', mode: '', name: `${os ? `${name}-${os}` : name}-${platform}` }); } - if (!isVm && platforms.includes('pve') && await onBase(script)) { + if (!isVm && platforms.includes('pve') && await updateChanged(script, text)) { const os = oses[0]; include.push({ script, os, platform: 'pve', arm64: '', mode: 'upgrade', name: `${os ? `${name}-${os}` : name}-pve-upgrade` }); } diff --git a/.github/workflows/scripts/ci-controller-setup.sh b/.github/workflows/scripts/ci-controller-setup.sh index d93d2a085..b2236eaaf 100644 --- a/.github/workflows/scripts/ci-controller-setup.sh +++ b/.github/workflows/scripts/ci-controller-setup.sh @@ -62,6 +62,7 @@ EOF } conf 200 10.201.146.232 pve-ci proxmox-test community-scripts/DevScripts conf 201 10.201.146.231 pve-ci-2 proxmox-test community-scripts/ProxmoxVE +conf 204 10.201.146.235 pve-ci-3 proxmox-test community-scripts/ProxmoxVE conf 202 10.201.146.233 incus-ci incus-test community-scripts/DevScripts conf 203 10.201.146.234 incus-ci-2 incus-test community-scripts/ProxmoxVE