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
1 change: 1 addition & 0 deletions .github/workflows/rig-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 19 additions & 16 deletions scripts/haiku.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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(
Expand Down
Loading