fix(ci): resilient large git push to updates feed (1.0.8)
Release / release (push) Failing after 6m13s
Release / release (push) Failing after 6m13s
http.postBuffer 2GiB, disable low-speed abort, retry push; docs for nginx/Gitea limits. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
* ARTIFACT_MAC — каталог с файлами macOS
|
||||
* ARTIFACT_LINUX — каталог с файлами Linux (AppImage и т.д.)
|
||||
* GIT_COMMIT_TAG — опционально, для сообщения коммита
|
||||
* DND_GIT_PUSH_RETRIES — опционально, число попыток git push (1–5, по умолчанию 3)
|
||||
*/
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
@@ -56,6 +57,43 @@ function runGit(args, cwd) {
|
||||
execFileSync('git', args, { cwd, stdio: 'inherit' });
|
||||
}
|
||||
|
||||
/** Большие AppImage + exe в одном push: без этого Git по умолчанию может оборвать HTTPS (postBuffer / stall). */
|
||||
function configureGitHttpForLargePush(cwd) {
|
||||
// 2 GiB — достаточно для пачки артефактов; на старых Git при необходимости поднять на сервере лимиты nginx/Gitea.
|
||||
runGit(['config', 'http.postBuffer', '2147483648'], cwd);
|
||||
runGit(['config', 'http.lowSpeedLimit', '0'], cwd);
|
||||
runGit(['config', 'http.lowSpeedTime', '0'], cwd);
|
||||
}
|
||||
|
||||
function sleepSyncSeconds(seconds) {
|
||||
try {
|
||||
execFileSync('sleep', [String(seconds)], { stdio: 'ignore' });
|
||||
} catch {
|
||||
const end = Date.now() + seconds * 1000;
|
||||
while (Date.now() < end) {
|
||||
/* fallback без утилиты sleep */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pushUpdatesBranch(work) {
|
||||
const retries = Math.max(1, Math.min(5, Number.parseInt(process.env.DND_GIT_PUSH_RETRIES || '3', 10) || 3));
|
||||
let lastError;
|
||||
for (let attempt = 1; attempt <= retries; attempt += 1) {
|
||||
try {
|
||||
runGit(['push', '-u', 'origin', 'updates'], work);
|
||||
return;
|
||||
} catch (err) {
|
||||
lastError = err;
|
||||
console.warn(`[sync-update-feed] git push failed (attempt ${attempt}/${retries})`);
|
||||
if (attempt < retries) {
|
||||
sleepSyncSeconds(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const server = mustEnv('DND_UPDATES_SERVER').replace(/\/+$/u, '');
|
||||
const updatesRepo = mustEnv('UPDATES_REPO');
|
||||
@@ -80,6 +118,7 @@ function main() {
|
||||
|
||||
runGit(['config', 'user.email', 'ci@gitea-actions.local'], work);
|
||||
runGit(['config', 'user.name', 'gitea-actions'], work);
|
||||
configureGitHttpForLargePush(work);
|
||||
|
||||
const copied =
|
||||
copyFlatReleaseFiles(winDir, work) +
|
||||
@@ -96,7 +135,7 @@ function main() {
|
||||
const st = execFileSync('git', ['status', '--porcelain'], { cwd: work }).toString().trim();
|
||||
if (st) {
|
||||
runGit(['commit', '-m', `update feed ${tag}`], work);
|
||||
runGit(['push', '-u', 'origin', 'updates'], work);
|
||||
pushUpdatesBranch(work);
|
||||
} else {
|
||||
console.warn('[sync-update-feed] nothing to commit (identical artifacts?)');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user