fix(release): extend OTA sync trigger timeout
This commit is contained in:
parent
0fb64b5fb8
commit
e551882bb3
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue