From e1e65f969805ef08727a9dccb37ecd2e79bf6dcd Mon Sep 17 00:00:00 2001 From: Syngnat Date: Thu, 23 Jul 2026 13:47:38 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(release):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=95=9C=E5=83=8F=E5=AE=B9=E9=87=8F=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 POSIX df 输出读取 Gatewaysentry 可用空间 - 校验远端容量结果后再换算为字节 - 增加发布 action 容量命令回归测试 --- .github/actions/publish-vps-mirror/action.yml | 7 ++++++- tools/prepare-vps-release-payload.test.py | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/actions/publish-vps-mirror/action.yml b/.github/actions/publish-vps-mirror/action.yml index 87ca8e6f..424a3fdb 100644 --- a/.github/actions/publish-vps-mirror/action.yml +++ b/.github/actions/publish-vps-mirror/action.yml @@ -115,7 +115,12 @@ runs: ) remote="${MIRROR_SSH_USER}@${MIRROR_SSH_HOST}" payload_bytes="$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["payloadBytes"])' "${stage_dir}/deployment.json")" - available_bytes="$(ssh "${ssh_options[@]}" "${remote}" "df -PB1 --output=avail '${mirror_root}' | tail -n 1 | tr -d ' '")" + available_kib="$(ssh "${ssh_options[@]}" "${remote}" "LC_ALL=C df -Pk '${mirror_root}' | awk 'NR == 2 { print \$4 }'")" + [[ "${available_kib}" =~ ^[0-9]+$ ]] || { + echo "Mirror origin returned an invalid free space value: ${available_kib:-}" >&2 + exit 1 + } + available_bytes="$((available_kib * 1024))" required_bytes="$((payload_bytes + 2000000000))" if (( available_bytes < required_bytes )); then echo "Mirror origin has insufficient free space: available=${available_bytes} required=${required_bytes}" >&2 diff --git a/tools/prepare-vps-release-payload.test.py b/tools/prepare-vps-release-payload.test.py index 69c9419d..aac3f7c5 100644 --- a/tools/prepare-vps-release-payload.test.py +++ b/tools/prepare-vps-release-payload.test.py @@ -12,6 +12,7 @@ from pathlib import Path SCRIPT = Path(__file__).with_name("prepare-vps-release-payload.py") +PUBLISH_ACTION = SCRIPT.parents[1] / ".github/actions/publish-vps-mirror/action.yml" def sha256(value: bytes) -> str: @@ -153,6 +154,14 @@ class PrepareVPSReleasePayloadTest(unittest.TestCase): self.assertNotEqual(result.returncode, 0) self.assertIn("invalid app asset name", result.stderr) + def test_publish_action_reads_remote_capacity_with_posix_df(self) -> None: + source = PUBLISH_ACTION.read_text(encoding="utf-8") + + self.assertIn("df -Pk '${mirror_root}'", source) + self.assertNotIn("--output=avail", source) + self.assertIn("available_kib", source) + self.assertIn("available_kib * 1024", source) + if __name__ == "__main__": unittest.main()