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
26 changes: 26 additions & 0 deletions .github/actions/provide-chromium-libs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Provide Chromium libraries
description: Make the shared libraries Playwright's Chromium shell needs available without root.
runs:
using: composite
steps:
- name: Provide Chromium libraries for the voice latency browser test
shell: bash
run: |
set -euo pipefail
if test -e /usr/lib/x86_64-linux-gnu/libnspr4.so; then
printf 'Chromium libraries present\n'
exit 0
fi
dir="$RUNNER_TEMP/chromium-libs"
mkdir -p "$dir/lists/partial" "$dir/cache/archives/partial" "$dir/root"
apt_opts=(-o Debug::NoLocking=1 -o Dir::State::Lists="$dir/lists" -o Dir::Cache="$dir/cache")
apt-get "${apt_opts[@]}" -qq update
apt-get "${apt_opts[@]}" -qq install --download-only --no-install-recommends -y \
libasound2t64 libatk-bridge2.0-0t64 libatk1.0-0t64 libatspi2.0-0t64 libcairo2 \
libcups2t64 libdbus-1-3 libdrm2 libgbm1 libglib2.0-0t64 libnspr4 libnss3 \
libpango-1.0-0 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 \
libxkbcommon0 libxrandr2
for deb in "$dir"/cache/archives/*.deb; do dpkg-deb -x "$deb" "$dir/root"; done
lib_dir="$dir/root/usr/lib/x86_64-linux-gnu"
test -f "$lib_dir/libnspr4.so"
printf 'LD_LIBRARY_PATH=%s\n' "$lib_dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
30 changes: 30 additions & 0 deletions .github/actions/provide-libatomic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Provide libatomic
description: Make libatomic.so.1 available to official Node binaries without root.
runs:
using: composite
steps:
- name: Provide libatomic for official Node binaries
shell: bash
run: |
set -euo pipefail
# Official Node 26 linux-x64 binaries link libatomic.so.1. The pinned
# actions-runner image (dotnet runtime-deps:8.0-noble) lacks it, and
# the ARC pod cannot use sudo/apt (no privilege escalation). Without
# it, Vite+ self-setup fails with exit 127. Use Ubuntu noble's
# immutable release-pocket package, pinned by SHA-256.
lib_system=/usr/lib/x86_64-linux-gnu/libatomic.so.1
if test -e "$lib_system"; then
printf 'libatomic present at %s\n' "$lib_system"
exit 0
fi
test "$(uname -m)" = x86_64
deb_url='https://archive.ubuntu.com/ubuntu/pool/main/g/gcc-14/libatomic1_14-20240412-0ubuntu1_amd64.deb'
deb_sha256='f496d80626e1512456273965d44f47b281edf53fa26d0d8bd0defc5be7e4601c'
dir="$RUNNER_TEMP/libatomic"
mkdir -p "$dir"
curl -fsSL --connect-timeout 10 --max-time 120 -o "$dir/libatomic1.deb" "$deb_url"
printf '%s %s\n' "$deb_sha256" "$dir/libatomic1.deb" | sha256sum -c -
dpkg-deb -x "$dir/libatomic1.deb" "$dir/root"
lib_dir="$dir/root/usr/lib/x86_64-linux-gnu"
test -f "$lib_dir/libatomic.so.1"
printf 'LD_LIBRARY_PATH=%s\n' "$lib_dir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
10 changes: 9 additions & 1 deletion .github/actions/setup-ci-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,18 @@ runs:
# default, saves a ~1 GB store only its own reruns can read, so it only restores.
# Concurrent jobs with the same install args reserve one key, so the losers
# compress the store for nothing; all but one pass save-pnpm-store: false.
#
# A pull_request cache is scoped to that PR, so only the push to the default
# branch writes the store later runs share. This fork's default branch is
# `release/native-0.1.10`, so that push writes it and a PR into it reads it.
# A push to `feat/assemblyai-current` writes a store only that branch's own
# runs can read, which is the same scoping the action already gives any
# non-default branch.
- name: Save pnpm store
if: >-
inputs.install == 'true' && inputs.save-pnpm-store == 'true' &&
(github.event_name != 'pull_request' || github.base_ref == github.event.repository.default_branch) &&
(github.event_name != 'pull_request' ||
github.base_ref == github.event.repository.default_branch) &&
steps.pnpm_cache.outputs.cache-hit != 'true' &&
(steps.pnpm_store.outputs.namespace == 'full' ||
steps.pnpm_cache.outputs.cache-matched-key != format('pnpm-full-v1-{0}-{1}-{2}', runner.os, runner.arch, hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'package.json')))
Expand Down
229 changes: 229 additions & 0 deletions .github/scripts/arc-ci-coverage.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
const fs = require("node:fs");
const path = require("node:path");

const WORKFLOW = ".github/workflows/closura-arc-ci.yml";
const REQUIRED_CHECK = "Voice + founder inbox (Linux ARC)";
const WORKERS = ["voice-and-inbox-core", "voice-and-inbox-web", "voice-and-inbox-mobile"];

// Every test the single serial job ran before the split. A parallel job that
// drops one of these makes the required check pass without running it.
const REQUIRED_TESTS = [
"apps/server/src/speech/CloudSpeech.test.ts",
"apps/server/src/speech/GroqSpeechStream.test.ts",
"apps/server/src/speech/stream.test.ts",
"packages/contracts/src/threadInbox.test.ts",
"packages/contracts/src/threadInbox.invariants.test.ts",
"packages/contracts/src/threadInbox.upgrade.test.ts",
"packages/contracts/src/threadMetadataMcp.test.ts",
"apps/web/src/components/threadActionMenu.logic.test.ts",
"apps/web/src/components/sidebar/threadListFilter.logic.test.ts",
"packages/client-runtime/src/state/threadAttribution.test.ts",
"apps/server/src/orchestration-v2/ThreadLaunchService.test.ts",
"apps/server/src/orchestration-v2/SubagentProjection.test.ts",
"apps/server/src/orchestration-v2/ModelAlertReactor.test.ts",
"apps/server/src/orchestration-v2/ThreadEventAlerts.test.ts",
"apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts",
"packages/shared/src/threadPlacement.test.ts",
"apps/server/src/peer/RemoteDelegation.test.ts",
"apps/server/src/mcp/OrchestratorMcpService.test.ts",
"apps/server/src/cli/thread.test.ts",
"apps/web/src/composerDraftStore.test.ts",
"packages/client-runtime/src/voice-input/controller.test.ts",
"apps/web/src/components/chat/composerSend.logic.test.ts",
"apps/web/src/components/chat/chatViewSend.test.ts",
"apps/web/src/components/chat/composerImagePersistence.test.ts",
"apps/web/src/components/chat/draftPlacement.test.ts",
"apps/web/src/components/chat/draftAttachmentUploads.test.ts",
"apps/web/src/components/chat/draftUploadReconcile.test.ts",
"apps/web/src/lib/attachmentUploadQueue.test.ts",
"apps/server/src/ws.test.ts",
"packages/contracts/src/environment.test.ts",
"scripts/feature-map.test.ts",
"apps/mobile/src/state/thread-placement.model.test.ts",
"apps/mobile/src/state/threadOutboxDelivery.placement.test.ts",
"apps/mobile/src/state/composer-attachment-uploads.test.ts",
"apps/mobile/src/lib/composerAttachmentUploadQueue.test.ts",
"apps/mobile/src/lib/attachmentUpload.test.ts",
"apps/mobile/src/state/use-composer-drafts.test.ts",
"apps/mobile/src/state/thread-outbox.test.ts",
"apps/mobile/src/state/threadOutboxDelivery.permissions.test.ts",
"apps/mobile/src/state/threadOutboxDelivery.test.ts",
"apps/mobile/src/state/pending-thread-creation.test.ts",
"apps/mobile/src/lib/projectThreadStartTurn.test.ts",
"apps/mobile/src/features/threads/thread-route-state.test.ts",
"apps/mobile/src/features/threads/new-task-flow-provider.test.tsx",
"apps/mobile/src/features/home/pendingTaskRoute.test.tsx",
"apps/mobile/src/features/threads/NewTaskDraftRouteScreen.test.tsx",
"apps/web/src/speech/voiceInputLatency.browser.test.ts",
"apps/web/src/speech/useEnvironmentSpeechInput.browser.test.tsx",
];

function unquote(value) {
const trimmed = value.trim();
if (
(trimmed.startsWith('"') && trimmed.endsWith('"')) ||
(trimmed.startsWith("'") && trimmed.endsWith("'"))
) {
return trimmed.slice(1, -1);
}
return trimmed;
}

// Workflow files are small and this only needs the step structure, so a flat
// scan beats pulling in a YAML parser. It tracks job ids, job names, `needs`,
// and the `run` / `working-directory` pairs inside each job's steps.
function parseWorkflow(source) {
const jobs = {};
let current = null;
let inRun = false;
let runIndent = 0;
let inTriggers = true;
const lines = source.split("\n");
for (const line of lines) {
if (inRun) {
const indent = line.match(/^\s*/)[0].length;
if (line.trim() !== "" && indent <= runIndent) inRun = false;
else {
current.run.push(line.trim().replace(/\\$/, "").trim());
continue;
}
}
if (inTriggers) {
if (line === "jobs:") inTriggers = false;
continue;
}
const job = line.match(/^ {2}([\w-]+):\s*$/);
if (job) {
current = { id: job[1], name: null, needs: [], condition: null, steps: [] };
jobs[current.id] = current;
continue;
}
if (!current) continue;
const condition = line.match(/^ {4}if:\s*(.+)$/);
if (condition && current.condition === null && current.steps.length === 0) {
current.condition = unquote(condition[1]);
continue;
}
if (!current) continue;
const name = line.match(/^ {4}name:\s*(.+)$/);
if (name) {
current.name = unquote(name[1]);
continue;
}
const needs = line.match(/^ {4}needs:\s*\[([^\]]*)\]/);
if (needs) {
current.needs = needs[1]
.split(",")
.map((item) => unquote(item))
.filter(Boolean);
continue;
}
const directory = line.match(/^ {8}working-directory:\s*(.+)$/);
if (directory) {
current.directory = unquote(directory[1]);
continue;
}
const run = line.match(/^ {8}run:\s*(\||>)?\s*$/);
if (run) {
const step = { directory: current.directory ?? "", run: [] };
current.steps.push(step);
current.run = step.run;
current.directory = "";
inRun = true;
runIndent = 8;
}
}
return jobs;
}

// A test path only counts when a worker actually invokes it. A path that only
// appears inside a comment or a branch that never runs would otherwise let the
// guard pass while the required check runs nothing.
function testsIn(job) {
const found = [];
for (const step of job.steps) {
const prefix = step.directory ? `${step.directory}/` : "";
let skipping = false;
for (const line of step.run) {
if (/^(?:if\s+false\b|exit\b)/.test(line)) skipping = true;
else if (skipping && /^(?:fi|else|elif)\b/.test(line)) skipping = false;
if (skipping || line.startsWith("#")) continue;
if (/^[\w./-]+\.(ts|tsx)$/.test(line)) found.push(prefix + line);
}
}
return found;
}

function jobBody(source, id) {
const marker = `\n ${id}:`;
const start = source.indexOf(marker);
if (start < 0) return "";
const rest = source.slice(start + marker.length);
const next = rest.search(/\n {2}[\w-]+:\s*\n/);
return next < 0 ? rest : rest.slice(0, next);
}

function checkCoverage(source) {
const jobs = parseWorkflow(source);
const problems = [];
const aggregator = jobs["voice-and-inbox"];
if (!aggregator) problems.push("missing voice-and-inbox job");
else {
if (aggregator.name !== REQUIRED_CHECK) {
problems.push(`required check is named ${JSON.stringify(aggregator.name)}`);
}
const needs = [...aggregator.needs].sort();
if (needs.join() !== [...WORKERS].sort().join()) {
problems.push(`aggregator needs ${needs.join(", ") || "nothing"}`);
}
// `always()` is true for a cancelled run, and a worker that never started
// reports success, so the required check would pass with nothing tested.
if (!aggregator.condition || !aggregator.condition.includes("!cancelled()")) {
problems.push("aggregator runs when the workflow is cancelled");
}
// The ARC image has no node on PATH. setup-node downloads an official
// Node 26 binary that needs libatomic, so both have to run first.
const body = jobBody(source, "voice-and-inbox");
const libatomic = body.indexOf("uses: ./.github/actions/provide-libatomic");
const setupNode = body.indexOf("uses: actions/setup-node@");
const guard = body.indexOf("run: node .github/scripts/arc-ci-coverage.cjs");
if (
libatomic < 0 ||
setupNode < 0 ||
guard < 0 ||
!(libatomic < setupNode && setupNode < guard)
) {
problems.push("coverage guard runs before Node is on PATH");
}
}
const ran = [];
for (const id of WORKERS) {
if (!jobs[id]) {
problems.push(`missing worker ${id}`);
continue;
}
ran.push(...testsIn(jobs[id]));
}
const ranSet = new Set(ran);
for (const test of REQUIRED_TESTS) {
if (!ranSet.has(test)) problems.push(`no worker runs ${test}`);
}
const duplicates = ran.filter((test, index) => ran.indexOf(test) !== index);
for (const test of new Set(duplicates)) problems.push(`run twice: ${test}`);
return problems;
}

module.exports = { REQUIRED_CHECK, REQUIRED_TESTS, WORKERS, checkCoverage, parseWorkflow };

if (require.main === module) {
const root = process.argv[2] ?? process.cwd();
const source = fs.readFileSync(path.join(root, WORKFLOW), "utf8");
const problems = checkCoverage(source);
if (problems.length > 0) {
for (const problem of problems) process.stderr.write(`${problem}\n`);
process.exit(1);
}
process.stdout.write(
`${REQUIRED_CHECK} covers ${REQUIRED_TESTS.length} tests across ${WORKERS.length} workers\n`,
);
}
52 changes: 52 additions & 0 deletions .github/scripts/arc-ci-coverage.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const test = require("node:test");
const { REQUIRED_TESTS, checkCoverage } = require("./arc-ci-coverage.cjs");

const root = path.resolve(__dirname, "../..");
const workflow = fs.readFileSync(
path.join(root, ".github/workflows/closura-arc-ci.yml"),
"utf8",
);

test("the parallel workers cover every test the serial job ran", () => {
assert.deepEqual(checkCoverage(workflow), []);
});

test("renaming the aggregator or dropping a test fails the check", () => {
const renamed = workflow.replace(
"name: Voice + founder inbox (Linux ARC)",
"name: Voice and inbox",
);
assert.ok(checkCoverage(renamed).some((problem) => problem.startsWith("required check")));

const dropped = workflow.replace(` ${REQUIRED_TESTS[0]} \\\n`, "");
assert.ok(checkCoverage(dropped).some((problem) => problem.includes(REQUIRED_TESTS[0])));
});

test("a test that only appears in dead code does not count as run", () => {
const buried = workflow.replace(
` ${REQUIRED_TESTS[0]} \\\n`,
` if false; then echo ${REQUIRED_TESTS[0]}; fi\n`,
);
assert.ok(checkCoverage(buried).some((problem) => problem.includes(REQUIRED_TESTS[0])));
});

test("the coverage guard refuses to run before Node is on PATH", () => {
const withoutNode = workflow.replace(
/ {6}- name: Provide libatomic for official Node binaries\n {8}uses: \.\/\.github\/actions\/provide-libatomic\n\n {6}- name: Setup Node\n {8}uses: actions\/setup-node@\S+ # v6\.5\.0\n {8}with:\n {10}node-version-file: package\.json\n\n/,
"",
);
assert.notEqual(withoutNode, workflow);
assert.ok(
checkCoverage(withoutNode).some((problem) => problem.includes("Node is on PATH")),
);
});

test("an aggregator that runs on cancellation fails the check", () => {
const always = workflow.replace("if: ${{ !cancelled() }}", "if: always()");
assert.ok(
checkCoverage(always).some((problem) => problem.includes("cancelled")),
);
});
Loading
Loading