fix(ci): bound Windows Testbox phone-home requests (#108755)

This commit is contained in:
Alix-007
2026-07-16 01:57:53 -07:00
committed by GitHub
parent 9da11f7c3f
commit 5cd9243465
2 changed files with 25 additions and 8 deletions
@@ -90,14 +90,19 @@ jobs:
metadata: {}
}' > "$hydrating_body"
hydrating_http_code="$(curl -sS -L --post302 --post303 -o "$hydrating_response" -w '%{http_code}' \
# curl can expose a 2xx status before a response-body timeout, so preserve its exit code.
hydrating_curl_status=0
hydrating_http_code="$(curl -sS -L --post302 --post303 \
--connect-timeout 10 --max-time 30 \
-o "$hydrating_response" -w '%{http_code}' \
-X POST "${api_url}/api/testbox/phone-home" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${auth_token}" \
--data-binary @"$hydrating_body" || true)"
--data-binary @"$hydrating_body")" || hydrating_curl_status=$?
echo "phone_home_hydrating_curl=${hydrating_curl_status}"
echo "phone_home_hydrating_http=${hydrating_http_code}"
if [[ ! "$hydrating_http_code" =~ ^2 ]]; then
if (( hydrating_curl_status != 0 )) || [[ ! "$hydrating_http_code" =~ ^2 ]]; then
echo "Blacksmith phone-home hydrating failed; response body:" >&2
cat "$hydrating_response" >&2 || true
exit 1
@@ -193,13 +198,18 @@ jobs:
metadata: {}
}' > "$ready_body"
http_code="$(curl -sS -L --post302 --post303 -o "$RUNNER_TEMP/testbox-ready.response" -w '%{http_code}' \
# curl can expose a 2xx status before a response-body timeout, so preserve its exit code.
ready_curl_status=0
http_code="$(curl -sS -L --post302 --post303 \
--connect-timeout 10 --max-time 30 \
-o "$RUNNER_TEMP/testbox-ready.response" -w '%{http_code}' \
-X POST "${api_url}/api/testbox/phone-home" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${auth_token}" \
--data-binary @"$ready_body" || true)"
--data-binary @"$ready_body")" || ready_curl_status=$?
echo "phone_home_ready_curl=${ready_curl_status}"
echo "phone_home_ready_http=${http_code}"
if [[ ! "$http_code" =~ ^2 ]]; then
if (( ready_curl_status != 0 )) || [[ ! "$http_code" =~ ^2 ]]; then
echo "Blacksmith phone-home ready failed; response body:" >&2
cat "$RUNNER_TEMP/testbox-ready.response" >&2 || true
exit 1
+9 -2
View File
@@ -2105,7 +2105,10 @@ describe("ci workflow guards", () => {
it("fails Windows Testbox setup when Blacksmith phone-home is not accepted", () => {
const workflow = readFileSync(".github/workflows/windows-blacksmith-testbox.yml", "utf8");
expect(workflow.match(/--connect-timeout 10 --max-time 30/gu)).toHaveLength(2);
expect(workflow).toContain('echo "phone_home_hydrating_curl=${hydrating_curl_status}"');
expect(workflow).toContain('echo "phone_home_hydrating_http=${hydrating_http_code}"');
expect(workflow).toContain('echo "phone_home_ready_curl=${ready_curl_status}"');
expect(workflow).toContain('echo "phone_home_ready_http=${http_code}"');
expect(workflow).toContain('jq -e \'type == "number"\' <<<"$installation_model_id"');
expect(workflow).toContain('--arg testbox_id "$TESTBOX_ID"');
@@ -2114,7 +2117,9 @@ describe("ci workflow guards", () => {
expect(workflow).toContain('--data-binary @"$hydrating_body"');
expect(workflow).toContain('--data-binary @"$ready_body"');
const hydratingFailureBlock = workflow.slice(
workflow.indexOf('if [[ ! "$hydrating_http_code" =~ ^2 ]]; then'),
workflow.indexOf(
'if (( hydrating_curl_status != 0 )) || [[ ! "$hydrating_http_code" =~ ^2 ]]; then',
),
workflow.indexOf('response="$(cat "$hydrating_response")"'),
);
const missingSshKeyFailureBlock = workflow.slice(
@@ -2122,10 +2127,12 @@ describe("ci workflow guards", () => {
workflow.indexOf("mkdir -p ~/.ssh"),
);
const readyFailureBlock = workflow.slice(
workflow.indexOf('if [[ ! "$http_code" =~ ^2 ]]; then'),
workflow.indexOf('if (( ready_curl_status != 0 )) || [[ ! "$http_code" =~ ^2 ]]; then'),
workflow.indexOf('echo "============================================"'),
);
expect(workflow).toContain(')" || hydrating_curl_status=$?');
expect(workflow).toContain(')" || ready_curl_status=$?');
expect(hydratingFailureBlock).toContain("exit 1");
expect(missingSshKeyFailureBlock).toContain("exit 1");
expect(readyFailureBlock).toContain("exit 1");