From 244c3b98a63c2ce34b2716d1555f8e842b7d79ea Mon Sep 17 00:00:00 2001 From: umaru Date: Fri, 21 Aug 2026 21:44:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E7=AD=89=E5=BE=85=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=20smoke=20=E8=AF=B7=E6=B1=82=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-personal.yml | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.github/workflows/deploy-personal.yml b/.github/workflows/deploy-personal.yml index 350e3b25..d654a46e 100644 --- a/.github/workflows/deploy-personal.yml +++ b/.github/workflows/deploy-personal.yml @@ -211,6 +211,48 @@ jobs: return parsedBody; } + async function waitForRequestSettlement(apiKeyId, expectedRequestCount) { + const deadline = Date.now() + 30_000; + let latestLogs = []; + + while (Date.now() < deadline) { + const query = new URLSearchParams({ + api_key_id: apiKeyId, + model: "gpt-4.1-smoke", + page: "1", + page_size: "10", + sort: "created_at", + order: "asc", + }); + const result = await fetchJson( + `${baseUrl}/api/admin/logs?${query.toString()}`, + { + headers: { + authorization: `Bearer ${adminToken}`, + }, + }, + [200] + ); + latestLogs = Array.isArray(result?.items) ? result.items : []; + + const settled = latestLogs.length >= expectedRequestCount && + latestLogs.slice(0, expectedRequestCount).every( + (item) => + typeof item?.status_code === "number" && + Object.prototype.hasOwnProperty.call(item, "billing_status") + ); + if (settled) { + return; + } + + await delay(250); + } + + throw new Error( + `Timed out waiting for ${expectedRequestCount} smoke request logs to settle; observed ${latestLogs.length}` + ); + } + async function main() { assert(adminToken, "Missing AUTOROUTER_ADMIN_TOKEN"); @@ -402,6 +444,7 @@ jobs: assert(streamText.includes("[DONE]"), "Deployment smoke stream missing [DONE]"); assert(requests.length >= 2, "Deployment smoke mock upstream did not receive requests"); + await waitForRequestSettlement(apiKey.id, 2); } finally { for (const apiKeyId of resources.apiKeyIds) { try {