From e551882bb36478789c3e4c5583b5ee2b50ad013e Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 29 May 2026 16:09:17 +0800 Subject: [PATCH] fix(release): extend OTA sync trigger timeout --- .github/scripts/trigger-ota-sync.mjs | 17 ++++++++++++++++- .github/scripts/trigger-ota-sync.test.ts | 8 ++++++++ .github/workflows/publish-ota.yml | 8 +++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/scripts/trigger-ota-sync.mjs b/.github/scripts/trigger-ota-sync.mjs index 70aa6687a..5978fccb5 100644 --- a/.github/scripts/trigger-ota-sync.mjs +++ b/.github/scripts/trigger-ota-sync.mjs @@ -11,7 +11,21 @@ import { pathToFileURL } from "node:url" * }} TriggerOtaSyncOptions */ -const DEFAULT_TIMEOUT_MS = 10_000 +const DEFAULT_TIMEOUT_MS = 120_000 + +export function readOtaSyncTimeoutMs(value) { + if (!value) { + return DEFAULT_TIMEOUT_MS + } + + const timeoutMs = Number(value) + + if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) { + throw new TypeError("OTA sync timeout must be a positive integer") + } + + return timeoutMs +} /** * @param {TriggerOtaSyncOptions} options @@ -81,6 +95,7 @@ async function main() { baseUrl: process.env.OTA_BASE_URL ?? "", token: process.env.OTA_SYNC_TOKEN ?? "", headerName: process.env.OTA_SYNC_TOKEN_HEADER ?? "", + timeoutMs: readOtaSyncTimeoutMs(process.env.OTA_SYNC_TIMEOUT_MS), }) console.info("Triggered OTA sync successfully") diff --git a/.github/scripts/trigger-ota-sync.test.ts b/.github/scripts/trigger-ota-sync.test.ts index 21fedbd7d..86e0f38e2 100644 --- a/.github/scripts/trigger-ota-sync.test.ts +++ b/.github/scripts/trigger-ota-sync.test.ts @@ -25,6 +25,14 @@ afterEach(async () => { }) describe("triggerOtaSync", () => { + it("reads a configurable OTA sync timeout", async () => { + const { readOtaSyncTimeoutMs } = await import("./trigger-ota-sync.mjs") + + expect(readOtaSyncTimeoutMs()).toBe(120_000) + expect(readOtaSyncTimeoutMs("30000")).toBe(30_000) + expect(() => readOtaSyncTimeoutMs("0")).toThrow("OTA sync timeout must be a positive integer") + }) + it("POSTs to /internal/sync with the configured auth header", async () => { const requests: Array<{ method?: string; url?: string; headerValue?: string }> = [] const headerName = "x-ota-sync-token" diff --git a/.github/workflows/publish-ota.yml b/.github/workflows/publish-ota.yml index 689cf32d4..7bdad2935 100644 --- a/.github/workflows/publish-ota.yml +++ b/.github/workflows/publish-ota.yml @@ -39,6 +39,11 @@ jobs: with: fetch-depth: 0 + - name: Preserve workflow helper scripts + run: | + mkdir -p "$RUNNER_TEMP/folo-release-scripts" + cp .github/scripts/trigger-ota-sync.mjs "$RUNNER_TEMP/folo-release-scripts/trigger-ota-sync.mjs" + - name: Resolve target release tag run: | git fetch --tags --force @@ -96,4 +101,5 @@ jobs: OTA_BASE_URL: ${{ secrets.OTA_BASE_URL }} OTA_SYNC_TOKEN: ${{ secrets.OTA_SYNC_TOKEN }} OTA_SYNC_TOKEN_HEADER: ${{ secrets.OTA_SYNC_TOKEN_HEADER }} - run: node .github/scripts/trigger-ota-sync.mjs + OTA_SYNC_TIMEOUT_MS: 120000 + run: node "$RUNNER_TEMP/folo-release-scripts/trigger-ota-sync.mjs"