From bfbf6cf55f478a097d80241df5b2b79db6fad491 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Fri, 6 Nov 2026 10:39:49 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8A=A0=E5=9B=BA=20Gitea=20Release?= =?UTF-8?q?=20=E4=B8=8A=E4=BC=A0=EF=BC=8C=E9=81=BF=E5=85=8D=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E6=9C=9F=E4=B8=A2=E8=B5=84=E4=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0.9.5 的 Release workflow 因 Gitea 服务端维护期不稳,5 个资产 上传 3 次重试全部失败,Gitea 侧只落地 7/12(已手动补齐)。 根因不是代码缺陷,但二进制变大后并发大文件上传放大了影响。 - job timeout-minutes: 30 → 60,给重试留足窗口。 - 单资产重试次数 3 → 5,间隔保持 3 秒。 - 上传从「2 并发 + wait」改为串行,维护期不再互相抢带宽; 幂等逻辑不变(已存在资产校验 SHA-256 后跳过,字节不同才删除重传)。 - 同步 release-validation.test.ts:断言改 attempt 2/5, 并发用例改为验证严格单 worker(peak === 1), 失败用例的 spawnSync 超时放宽到 40s。 校验:YAML parse 通过;bun test 1114 pass / 0 fail; bun run check、check:readme 37/37 全通过。 本次只改 CI,不打 tag、不发版。 --- .github/workflows/release.yml | 22 +++++++--------------- scripts/release/release-validation.test.ts | 8 ++++---- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf5a22d..0097db5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: build-and-publish: name: 🚀 Build & Publish Multi-Platform Binaries runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 60 permissions: contents: write env: @@ -183,9 +183,9 @@ jobs: local file="$1" filename expected_hash attempt info existing remote_hash asset_id response delete_failed filename=$(basename "$file") expected_hash=$(sha256sum "$file" | awk '{ print $1 }') - for attempt in 1 2 3; do + for attempt in 1 2 3 4 5; do if [ "$attempt" -gt 1 ]; then sleep "${GITEA_RETRY_DELAY:-3}"; fi - echo " [start] Uploading ${filename} to Gitea (attempt ${attempt}/3)..." + echo " [start] Uploading ${filename} to Gitea (attempt ${attempt}/5)..." if ! info=$(curl -fsS --connect-timeout 15 --max-time 60 -H "Authorization: token ${GITEA_TOKEN}" "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}"); then continue fi @@ -212,24 +212,16 @@ jobs: return 0 fi done - echo "::error::Failed to upload ${filename} after 3 attempts." + echo "::error::Failed to upload ${filename} after 5 attempts." return 1 } - # Bound outbound traffic: large raw binaries must not compete with all archives. - pids=() + # 串行上传:Gitea 维护期并发推大文件容易把重试窗口耗光,宁可慢也不要丢资产。 + # 配合 job 超时 60 分钟与单资产 5 次重试,给服务端抖动留出余量。 failed=0 for file in dist/bin/hose-use-* dist/bin/checksums.txt; do - upload_asset "$file" & - pids+=($!) - if [ "${#pids[@]}" -eq 2 ]; then - for pid in "${pids[@]}"; do wait "$pid" || failed=1; done - pids=() - fi + upload_asset "$file" || failed=1 done - if [ "${#pids[@]}" -gt 0 ]; then - for pid in "${pids[@]}"; do wait "$pid" || failed=1; done - fi if [ "$failed" -ne 0 ]; then echo "::error::One or more Gitea assets failed to upload." exit 1 diff --git a/scripts/release/release-validation.test.ts b/scripts/release/release-validation.test.ts index d55f5e0..382ef07 100644 --- a/scripts/release/release-validation.test.ts +++ b/scripts/release/release-validation.test.ts @@ -162,7 +162,7 @@ for arg in "$@"; do done exit 22 `, { mode: 0o755 }); - const result = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${join(f.root, "tools")}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0" }, encoding: "utf8", timeout: 30_000 }); + const result = spawnSync("bash", ["-eo", "pipefail", "-c", step.run], { cwd: f.root, env: { ...process.env, PATH: `${join(f.root, "tools")}:${process.env.PATH}`, GITEA_TOKEN: "fixture", GITEA_RETRY_DELAY: "0", GITEA_HOST: "https://example.test", GITEA_REPO: "test/repo", RELEASE_TAG: "v1.0.0" }, encoding: "utf8", timeout: 40_000 }); expect(result.status).toBe(1); expect(result.stdout).toContain("assets failed to upload"); expect(result.stdout).not.toContain("Successfully published"); @@ -173,7 +173,7 @@ exit 22 const result = f.run(); expect(result.status).toBe(0); for (const name of f.files) expect(readFileSync(join(f.root, `count-${name}`), "utf8")).toBe("2"); - expect(result.stdout).toContain("attempt 2/3"); + expect(result.stdout).toContain("attempt 2/5"); }, 60_000); test("correct mirror assets are verified and retained without uploading replacements", () => { @@ -189,7 +189,7 @@ exit 22 expect(readFileSync(join(f.root, "gh.log"), "utf8")).toContain("release download v1.0.0"); }, 60_000); - test("asset transfers never exceed two concurrent workers", () => { + test("asset transfers are serialized to a single worker", () => { const f = mirrorFixture("concurrency"); expect(f.run().status).toBe(0); let active = 0, peak = 0; @@ -198,6 +198,6 @@ exit 22 peak = Math.max(peak, active); } expect(active).toBe(0); - expect(peak).toBeLessThanOrEqual(2); + expect(peak).toBe(1); }, 60_000); });