2 Commits

Author SHA1 Message Date
Ivan Fontosh e923de350d fix(ci): merge origin/updates before push to avoid fetch-first rejection
Release / release (push) Failing after 6m2s
Shallow clone depth 40 (DND_UPDATES_CLONE_DEPTH); fetch+merge before each push attempt.
Release 1.0.9.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 11:15:33 +08:00
Ivan Fontosh 07641be2d2 fix(ci): resilient large git push to updates feed (1.0.8)
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>
2026-05-12 11:04:31 +08:00
4 changed files with 90 additions and 6 deletions
+24
View File
@@ -360,6 +360,30 @@ git push origin v1.0.1
---
## Если `git push` в `updates` падает: `remote end hung up` / таймаут
Один коммит с **Windows + два AppImage** может быть **сотни МБ** — HTTPS-push иногда рвётся из‑за лимита буфера Git или таймаута **nginx / reverse proxy** перед Gitea.
**В репозитории с кодом** скрипт `scripts/sync-update-feed.mjs` уже выставляет в клоне feed-репо:
- `http.postBuffer` **2 GiB**;
- отключение «медленной передачи» (`http.lowSpeedLimit` / `http.lowSpeedTime`);
- до **3** повторов `git push` с паузой 20 с (переменная **`DND_GIT_PUSH_RETRIES`**, максимум 5).
Если ошибка сохраняется — на **сервере** (nginx и т.п.) проверьте, например:
- `client_max_body_size` — не меньше размера push (или `0` для безлимита, если политика безопасности позволяет);
- `proxy_read_timeout` / `proxy_send_timeout`**несколько минут** и больше для больших загрузок;
- лимиты самого **Gitea** (`[repository.upload]`, `APP_MAX_FILE_SIZE` в зависимости от версии) — в документации вашей сборки Gitea.
---
## Если push отклонён: `(fetch first)` / `rejected`
Пока job собирает артефакты, в **`updates`** мог успеть попасть **другой** коммит (второй релиз, ручная выкладка). Скрипт `sync-update-feed.mjs` перед push делает **`git fetch` + `git merge origin/updates`** (и после клона — то же в начале), плюс shallow **глубина по умолчанию 40** (`DND_UPDATES_CLONE_DEPTH`). Не запускайте **два релиза одного и того же репо одновременно** по двум тегам — возможны конфликты merge.
---
## Поведение приложения
- Проверка только в **собранной** установке (`app.isPackaged`).
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "DndGamePlayer",
"version": "1.0.7",
"version": "1.0.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "DndGamePlayer",
"version": "1.0.7",
"version": "1.0.9",
"hasInstallScript": true,
"license": "ISC",
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "DndGamePlayer",
"version": "1.0.7",
"version": "1.0.9",
"description": "DNDGamePlayer — редактор и проигрыватель игр",
"main": "dist/main/index.cjs",
"scripts": {
+63 -3
View File
@@ -13,6 +13,8 @@
* ARTIFACT_MAC — каталог с файлами macOS
* ARTIFACT_LINUX — каталог с файлами Linux (AppImage и т.д.)
* GIT_COMMIT_TAG — опционально, для сообщения коммита
* DND_GIT_PUSH_RETRIES — опционально, число попыток git push (1–5, по умолчанию 3)
* DND_UPDATES_CLONE_DEPTH — опционально, глубина shallow clone (2200, по умолчанию 40), чтобы merge с remote был надёжнее
*/
import { execFileSync } from 'node:child_process';
import fs from 'node:fs';
@@ -56,6 +58,50 @@ 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 mergeOriginUpdates(work) {
runGit(['fetch', 'origin', 'updates'], work);
runGit(['merge', '--no-edit', 'origin/updates'], work);
}
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 {
console.log(`[sync-update-feed] merge origin/updates before push (attempt ${attempt}/${retries})`);
mergeOriginUpdates(work);
runGit(['push', '-u', 'origin', 'updates'], work);
return;
} catch (err) {
lastError = err;
console.warn(`[sync-update-feed] merge/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');
@@ -71,15 +117,29 @@ function main() {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dnd-feed-'));
const work = path.join(tmp, 'repo');
const cloneDepth = Math.max(
2,
Math.min(200, Number.parseInt(process.env.DND_UPDATES_CLONE_DEPTH || '40', 10) || 40),
);
try {
execFileSync('git', ['clone', '--depth', '1', '-b', 'updates', cloneUrl, work], { stdio: 'inherit' });
execFileSync('git', ['clone', `--depth=${String(cloneDepth)}`, '-b', 'updates', cloneUrl, work], {
stdio: 'inherit',
});
} catch {
execFileSync('git', ['clone', '--depth', '1', cloneUrl, work], { stdio: 'inherit' });
execFileSync('git', ['clone', `--depth=${String(cloneDepth)}`, cloneUrl, work], { stdio: 'inherit' });
runGit(['checkout', '-B', 'updates'], work);
}
runGit(['config', 'user.email', 'ci@gitea-actions.local'], work);
runGit(['config', 'user.name', 'gitea-actions'], work);
configureGitHttpForLargePush(work);
try {
mergeOriginUpdates(work);
} catch {
console.warn('[sync-update-feed] initial merge skipped (новая ветка или пустой remote)');
}
const copied =
copyFlatReleaseFiles(winDir, work) +
@@ -96,7 +156,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?)');
}