From 17b7d855de89e0f5517d1ceee8f3c1a20ed8e7cb Mon Sep 17 00:00:00 2001 From: pelikhan Date: Sat, 21 Nov 2026 15:41:01 -0800 Subject: [PATCH] Require Copilot integration coverage in CI Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/rig-integration.yml | 1 + README.md | 4 +++ scripts/haiku.integration.test.ts | 35 +++++++++++++++------------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/rig-integration.yml b/.github/workflows/rig-integration.yml index dda198a..3de3c6c 100644 --- a/.github/workflows/rig-integration.yml +++ b/.github/workflows/rig-integration.yml @@ -23,5 +23,6 @@ jobs: - name: Run integration tests env: + RIG_REQUIRE_COPILOT_INTEGRATION: "1" COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} run: npm run test:integration diff --git a/README.md b/README.md index 605096d..b4c52e0 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ node skills/rig/run.ts review.ts --typecheck `gh skill install` copies the skill but **does not install SDK dependencies**. For an installed skill, find its directory with `gh skill list` and substitute it for `skills/rig` in the commands above. Without `--server`, Rig selects an engine from your environment or uses the default Copilot endpoint; see [running programs](skills/rig/runtime.md) for launch options. +## Live Copilot integration tests + +Run `npm run test:integration` with `COPILOT_GITHUB_TOKEN` for the local CLI transport, or with `COPILOT_SDK_URI` for a running SDK endpoint (also supply `COPILOT_CONNECTION_TOKEN` if the endpoint requires it). Without either transport, the suite reports a skip. Set `RIG_REQUIRE_COPILOT_INTEGRATION=1` to fail instead, as the Rig Integration Tests workflow does. + ## In agentic workflows Pin the [Rig skill](skills/rig/SKILL.md) and [shared launcher template](.github/workflows/shared/rig.md) to full commit SHAs. The template provides Node.js 24 and a narrow `printf`/`node` allowlist; the consuming workflow must enable the Copilot SDK, grant `copilot-requests: write`, and provision dependencies. See the [workflow setup guide](skills/rig/agentic-workflows.md) for the exact configuration and credential handoff. diff --git a/scripts/haiku.integration.test.ts b/scripts/haiku.integration.test.ts index 779739a..034e85b 100644 --- a/scripts/haiku.integration.test.ts +++ b/scripts/haiku.integration.test.ts @@ -3,9 +3,17 @@ import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { describe, expect, it } from "vitest"; -const token = process.env["COPILOT_GITHUB_TOKEN"]; -const sdkUri = process.env["COPILOT_SDK_URI"]; -const itWithToken = token || sdkUri ? it : it.skip; +const hasToken = Boolean(process.env["COPILOT_GITHUB_TOKEN"]?.trim()); +const hasSdkUri = Boolean(process.env["COPILOT_SDK_URI"]?.trim()); +const hasTransport = hasToken || hasSdkUri; +const missingTransport = "Set COPILOT_GITHUB_TOKEN or COPILOT_SDK_URI to run the live Copilot integration tests."; +if (!hasTransport) { + if (process.env["RIG_REQUIRE_COPILOT_INTEGRATION"] === "1") { + throw new Error(`Live Copilot integration is required but unavailable. ${missingTransport}`); + } + console.warn(`Skipping live Copilot integration tests. ${missingTransport}`); +} +const liveTest = hasTransport ? it : it.skip; const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const haikuSamplePath = resolve(repoRoot, "src/samples/01-single-agent-haiku.ts"); const sonnetSamplePath = resolve(repoRoot, "src/samples/56-single-agent-sonnet.ts"); @@ -18,36 +26,31 @@ async function runIntegrationSample(samplePath: string, input: string): Promise< // Use --server (stdio transport) when running with a personal token. // In agentic workflow context, COPILOT_SDK_URI is provided by the engine // and the URI-based connection is used without --server. - const args = sdkUri ? [launcherPath, samplePath] : [launcherPath, samplePath, "--server"]; + const args = hasSdkUri ? [launcherPath, samplePath] : [launcherPath, samplePath, "--server"]; const child = spawn(process.execPath, args, { cwd: repoRoot, - env: { ...process.env, ...(token ? { COPILOT_GITHUB_TOKEN: token } : {}) }, + stdio: ["pipe", "pipe", "ignore"], }); let stdout = ""; - let stderr = ""; const timer = setTimeout(() => { child.kill("SIGTERM"); - reject(new Error("Timed out waiting for haiku integration run.")); + reject(new Error("Timed out waiting for the Copilot integration sample.")); }, INTEGRATION_TIMEOUT_MS); child.stdout.on("data", (chunk) => { stdout += chunk.toString(); }); - child.stderr.on("data", (chunk) => { - stderr += chunk.toString(); - }); - child.on("error", (error) => { clearTimeout(timer); reject(error); }); - child.on("close", (code) => { + child.on("close", (code, signal) => { clearTimeout(timer); if (code !== 0) { - reject(new Error(`Haiku integration run failed with exit code ${code}.\n${stderr}`)); + reject(new Error(`Copilot integration sample failed (${signal ?? `exit code ${code}`}).`)); return; } resolve(stdout); @@ -58,7 +61,7 @@ async function runIntegrationSample(samplePath: string, input: string): Promise< } describe("rig runtime integration", () => { - itWithToken( + liveTest( "runs a single-agent haiku sample with the real runtime", async () => { const stdout = await runIntegrationSample(haikuSamplePath, "autumn rain on city windows"); @@ -73,7 +76,7 @@ describe("rig runtime integration", () => { INTEGRATION_TIMEOUT_MS, ); - itWithToken( + liveTest( "runs a single-agent sonnet sample with the real runtime", async () => { const stdout = await runIntegrationSample(sonnetSamplePath, "midnight train through fog"); @@ -88,7 +91,7 @@ describe("rig runtime integration", () => { INTEGRATION_TIMEOUT_MS, ); - itWithToken( + liveTest( "runs a complex sonnet sample with tools, addons, intents, and subagent wiring", async () => { const stdout = await runIntegrationSample(