Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/app/test/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,8 @@ describe("Build a candidate and sign it (spec/release/index.md, \"Story: Build a
}), [row]));
const read = () => stateOf(JSON.parse(readFileSync(path, "utf8")));
const save = (state: Record<string, unknown>) => write(directory, "github.json", state);
writeFileSync(join(directory, "gh"), `#!/usr/bin/env python3
import hashlib,json,os,sys
writeFileSync(join(directory, "gh"), `#!/usr/bin/env -S python3 -S
import json,os,sys
from pathlib import Path
from urllib.parse import urlsplit
file=Path(os.environ["GH_FIXTURE"])
Expand All @@ -869,6 +869,7 @@ if a[:2]==["api","graphql"]:
totalCount=state.get("releaseIndexTotal",len(rows)),nodes=page,pageInfo=dict(hasNextPage=i+1<len(pages))))))
for i,page in enumerate(pages)])
elif a[:4]==["api","--method","POST","https://uploads.github.com/repos/AlphaPhone/alpha/releases/77/assets?name=alpha-release-source.json"]:
import hashlib
data=sys.stdin.buffer.read()
assert a[4:]==["-H","Content-Type: application/json","-H",f"Content-Length: {len(data)}","--input","-","--silent"]
assert any(r["id"]==77 and r["draft"] for r in state["releases"])
Expand Down
12 changes: 11 additions & 1 deletion scripts/ci/app_update_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,20 @@ def copy_verified(source, size, expected_digest, failure, destination=None):
require(remaining == 0 and digest.hexdigest() == expected_digest, failure)


RUN_ATTEMPT = re.compile(rf"repos/{re.escape(REPOSITORY)}/actions/runs/[1-9][0-9]*/attempts/[1-9][0-9]*")
completed_attempts = {}


def gh_json(endpoint):
"""Read one GitHub API document; a completed run attempt never changes, so one command reads it once."""
if endpoint in completed_attempts:
return completed_attempts[endpoint]
result = subprocess.run(["gh", "api", endpoint], check=True, capture_output=True, timeout=60)
require(len(result.stdout) <= 1024**2, "GitHub producer metadata exceeds bound")
return json.loads(result.stdout)
document = json.loads(result.stdout)
if RUN_ATTEMPT.fullmatch(endpoint) and document.get("status") == "completed":
completed_attempts[endpoint] = document
return document


def verify_github_candidate(plan, api, artifact=None):
Expand Down
10 changes: 7 additions & 3 deletions vibestack/remote/test/remote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,14 @@ describe("run links", () => {
const send = (frame: ToBox | Link, n?: number) => { if (child.stdin.writable) child.stdin.write(encode(frame, n)); };
const hello = (seen: number) => send({ t: "hello", seen, client });
const frames = () => lines.filter((line): line is Numbered<FromBox> => "frame" in line);
let acknowledging = acknowledge;
// Like the client: acknowledge what arrived, often enough to keep the lease.
const ping = setInterval(() => { if (acknowledge && lines.some(isAck)) send({ t: "ack", n: frames().at(-1)?.n ?? 0 }); }, 200);
const ping = setInterval(() => { if (acknowledging && lines.some(isAck)) send({ t: "ack", n: frames().at(-1)?.n ?? 0 }); }, 200);
/** From now on the link acknowledges nothing, as a client that dies before it takes what comes next. */
const fallSilent = () => { acknowledging = false; };
const closed = new Promise<void>((resolve) => child.on("close", () => { clearInterval(ping); resolve(); }));
const find = <T extends FromBox["t"]>(t: T) => frames().find((line) => line.frame.t === t);
return { child, client, lines, send, hello, frames, find, closed };
return { child, client, lines, send, hello, frames, find, closed, fallSilent };
}

/** A first link that starts `request` as `runId` and, like the client, acknowledges the run. */
Expand Down Expand Up @@ -822,9 +825,10 @@ describe("run links", () => {
const first = await startRun(home, "img-1", request);
await until(() => (fs.existsSync(path.join(worktree, ".spec-cache", entry)) ? true : undefined), "the check to write its result");
expect(seal("k")).toEqual({ facts: null, busy: 1 });
// Its client never collects it: the result waits on the saved box, and would in a copy.
first.fallSilent();
fs.writeFileSync(path.join(worktree, "go"), "");
const exit = await until(() => first.find("exit"), "the exit frame");
// Its client never collects it: the result waits on the saved box, and would in a copy.
first.child.kill("SIGKILL");
await until(() => (owned(home, "img-1") ? undefined : true), "the check's owner to leave");
const second = await finish(home, "img-2", { ...request, key: "k2", worktree: path.join(home, "wt2"), argv: ["sh", "-c", `test -f .spec-cache/${entry}`] });
Expand Down
Loading