diff --git a/.github/workflows/e2e-vitest-scenarios.yaml b/.github/workflows/e2e-vitest-scenarios.yaml index 5e8700ad1e6..890eeccbdbd 100644 --- a/.github/workflows/e2e-vitest-scenarios.yaml +++ b/.github/workflows/e2e-vitest-scenarios.yaml @@ -605,6 +605,59 @@ jobs: if-no-files-found: ignore retention-days: 14 + cloud-inference-vitest: + needs: generate-matrix + if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',cloud-inference-vitest,') || contains(format(',{0},', inputs.scenarios), ',cloud-inference,') }} + runs-on: ubuntu-latest + timeout-minutes: 50 + env: + FREE_STANDING_VITEST_JOB: "1" + FREE_STANDING_SCENARIO_ID: "cloud-inference" + E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/cloud-inference + NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js + NEMOCLAW_RUN_E2E_SCENARIOS: "1" + NEMOCLAW_SANDBOX_NAME: "e2e-cloud-inference" + OPENSHELL_GATEWAY: "nemoclaw" + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + persist-credentials: false + + - name: Set up Node + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0 + with: + node-version: 22 + cache: npm + + - name: Install root dependencies + run: npm ci --ignore-scripts + + - name: Build CLI + run: npm run build:cli + + - name: Run cloud inference live test + # Migrated from test/e2e/test-cloud-inference-e2e.sh. The Vitest test + # preserves the legacy install.sh/onboard path, posts a live PONG + # request through sandbox inference.local, and reuses the skill + # filesystem validators from the retained bash helpers. + env: + NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }} + run: | + set -euo pipefail + npx vitest run --project e2e-scenarios-live \ + test/e2e-scenario/live/cloud-inference.test.ts \ + --silent=false --reporter=default + + - name: Upload cloud inference artifacts + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: e2e-vitest-scenarios-cloud-inference + path: e2e-artifacts/vitest/cloud-inference/ + include-hidden-files: false + if-no-files-found: ignore + retention-days: 14 + issue-4434-tui-unreachable-inference-vitest: needs: generate-matrix if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',issue-4434-tui-unreachable-inference-vitest,') || contains(format(',{0},', inputs.scenarios), ',issue-4434-tui-unreachable-inference,') }} @@ -2005,6 +2058,7 @@ jobs: onboard-negative-paths-vitest, skill-agent-vitest, inference-routing-vitest, + cloud-inference-vitest, credential-sanitization-vitest, credential-migration-vitest, runtime-overrides-vitest, diff --git a/test/e2e-scenario/live/cloud-inference-provider-skip.ts b/test/e2e-scenario/live/cloud-inference-provider-skip.ts new file mode 100644 index 00000000000..06d797dc78b --- /dev/null +++ b/test/e2e-scenario/live/cloud-inference-provider-skip.ts @@ -0,0 +1,88 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import type { ShellProbeResult } from "../fixtures/shell-probe.ts"; +import { isTransientProviderValidationFailure } from "./network-policy-transient-provider.ts"; + +const ENDPOINT_VALIDATION_RE = + /endpoint validation failed|failed to verify inference endpoint|Chat Completions API validation/i; +const RATE_LIMIT_OR_SANITIZED_EXTERNAL_RE = + /HTTP 429|\b429\b|rate[- ]?limit|too many requests|quota|temporar|timed? out|timeout|ETIMEDOUT|ECONNRESET|EAI_AGAIN|ENOTFOUND|failed to connect|error sending request|\b(redacted|sanitized)\b/i; +const CREDENTIAL_OR_AUTH_RE = + /invalid.*(api[_-]?key|credential)|unauthorized|forbidden|HTTP 40[13]\b|\b40[13]\b/i; + +export const PRE_CONTRACT_EXTERNAL_PROVIDER_SKIP_REASON = + "external-provider-validation-unavailable-before-legacy-contract"; +export const PRE_CONTRACT_EXTERNAL_PROVIDER_SOURCE_BOUNDARY = + "external NVIDIA Endpoints provider availability"; +export const PRE_CONTRACT_EXTERNAL_PROVIDER_REMOVAL_CONDITION = + "remove once CI endpoint validation is stable for a release cycle or covered by a hermetic provider-validation fixture"; + +export interface PreContractExternalProviderFailure { + classifier: "transient-endpoint-validation" | "rate-limited-or-sanitized-endpoint-validation"; + outputTail: string; +} + +export interface PreContractExternalProviderSkipEvidence { + id: "cloud-inference"; + status: "skipped"; + reason: typeof PRE_CONTRACT_EXTERNAL_PROVIDER_SKIP_REASON; + classifier: PreContractExternalProviderFailure["classifier"]; + phase: "install-sh-onboard"; + legacyContractStarted: false; + installExitCode: ShellProbeResult["exitCode"]; + installTimedOut: boolean; + outputTail: string; + artifacts: ShellProbeResult["artifacts"]; + sourceBoundary: typeof PRE_CONTRACT_EXTERNAL_PROVIDER_SOURCE_BOUNDARY; + removalCondition: typeof PRE_CONTRACT_EXTERNAL_PROVIDER_REMOVAL_CONDITION; +} + +function resultText(result: Pick): string { + return [result.stdout, result.stderr].filter(Boolean).join("\n"); +} + +function tailForEvidence(text: string, maxLength = 1600): string { + return text.length > maxLength ? text.slice(-maxLength) : text; +} + +export function classifyPreContractExternalProviderFailure( + result: Pick, +): PreContractExternalProviderFailure | null { + const output = resultText(result); + if (!ENDPOINT_VALIDATION_RE.test(output)) return null; + if (CREDENTIAL_OR_AUTH_RE.test(output)) return null; + if (isTransientProviderValidationFailure(result)) { + return { + classifier: "transient-endpoint-validation", + outputTail: tailForEvidence(output), + }; + } + if (RATE_LIMIT_OR_SANITIZED_EXTERNAL_RE.test(output)) { + return { + classifier: "rate-limited-or-sanitized-endpoint-validation", + outputTail: tailForEvidence(output), + }; + } + return null; +} + +export function buildPreContractExternalProviderSkipEvidence( + install: Pick, + classification: PreContractExternalProviderFailure, +): PreContractExternalProviderSkipEvidence { + return { + id: "cloud-inference", + status: "skipped", + reason: PRE_CONTRACT_EXTERNAL_PROVIDER_SKIP_REASON, + classifier: classification.classifier, + phase: "install-sh-onboard", + legacyContractStarted: false, + installExitCode: install.exitCode, + installTimedOut: install.timedOut, + outputTail: classification.outputTail, + artifacts: install.artifacts, + sourceBoundary: PRE_CONTRACT_EXTERNAL_PROVIDER_SOURCE_BOUNDARY, + removalCondition: PRE_CONTRACT_EXTERNAL_PROVIDER_REMOVAL_CONDITION, + }; +} diff --git a/test/e2e-scenario/live/cloud-inference.test.ts b/test/e2e-scenario/live/cloud-inference.test.ts new file mode 100644 index 00000000000..9af5ea9ebc0 --- /dev/null +++ b/test/e2e-scenario/live/cloud-inference.test.ts @@ -0,0 +1,355 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +/** + * Live Vitest replacement for test/e2e/test-cloud-inference-e2e.sh. + * + * Preserves the legacy real boundaries: install.sh non-interactive setup, + * Docker, a named OpenClaw sandbox, inference.local chat completion from + * inside the sandbox, repo skill validation, and sandbox /sandbox/.openclaw + * filesystem validation via the same shell helpers the bash suite uses. + */ + +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; +import type { ArtifactSink } from "../fixtures/artifacts.ts"; +import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts"; +import type { HostCliClient } from "../fixtures/clients/host.ts"; +import { type SandboxClient, validateSandboxName } from "../fixtures/clients/sandbox.ts"; +import { expect, test } from "../fixtures/e2e-test.ts"; +import { shouldRunLiveE2EScenarios } from "../fixtures/live-project-gate.ts"; +import type { ShellProbeResult } from "../fixtures/shell-probe.ts"; +import { + buildPreContractExternalProviderSkipEvidence, + classifyPreContractExternalProviderFailure, + type PreContractExternalProviderFailure, +} from "./cloud-inference-provider-skip.ts"; + +const REPO_ROOT = path.resolve(import.meta.dirname, "../../.."); +const CLI_ENTRYPOINT = path.join(REPO_ROOT, "bin", "nemoclaw.js"); +const REPO_SKILL_VALIDATOR = path.join( + REPO_ROOT, + "test", + "e2e", + "e2e-cloud-experimental", + "features", + "skill", + "lib", + "validate_repo_skills.sh", +); +const SANDBOX_SKILL_VALIDATOR = path.join( + REPO_ROOT, + "test", + "e2e", + "e2e-cloud-experimental", + "features", + "skill", + "lib", + "validate_sandbox_openclaw_skills.sh", +); +const SANDBOX_NAME = process.env.NEMOCLAW_SANDBOX_NAME ?? "e2e-cloud-inference"; +const CLOUD_MODEL = + process.env.NEMOCLAW_CLOUD_EXPERIMENTAL_MODEL ?? "nvidia/nemotron-3-super-120b-a12b"; +const INSTALL_TIMEOUT_MS = 25 * 60_000; +const CHAT_TIMEOUT_MS = 120_000; +const TEST_TIMEOUT_MS = 40 * 60_000; +const MAX_ATTEMPTS = positiveInteger(process.env.E2E_PHASE_5B_MAX_ATTEMPTS, 3); +const RETRY_SLEEP_MS = positiveInteger(process.env.E2E_PHASE_5B_RETRY_SLEEP_SEC, 5) * 1_000; + +validateSandboxName(SANDBOX_NAME); + +function positiveInteger(value: string | undefined, fallback: number): number { + if (!value || !/^[1-9][0-9]*$/.test(value)) return fallback; + return Number.parseInt(value, 10); +} + +function sleep(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + +function resultText(result: Pick): string { + return [result.stdout, result.stderr].filter(Boolean).join("\n"); +} + +async function writePreContractExternalProviderSkip( + artifacts: ArtifactSink, + install: ShellProbeResult, + classification: PreContractExternalProviderFailure, +): Promise { + const evidence = buildPreContractExternalProviderSkipEvidence(install, classification); + await artifacts.writeJson("transient-provider-validation.skip.json", evidence); + await artifacts.writeJson("scenario-result.json", evidence); +} + +function testEnv(home: string, extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv { + const base = buildAvailabilityProbeEnv(); + return { + ...base, + HOME: home, + PATH: [path.join(home, ".local", "bin"), path.join(home, ".npm-global", "bin"), base.PATH] + .filter(Boolean) + .join(":"), + NEMOCLAW_NON_INTERACTIVE: "1", + NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1", + OPENSHELL_GATEWAY: "nemoclaw", + ...extra, + }; +} + +async function bestEffort(run: () => Promise): Promise { + try { + await run(); + } catch { + // Cleanup mirrors the legacy teardown: best effort, because some failures + // happen before OpenShell or the sandbox exists. + } +} + +async function cleanupCloudInferenceState( + host: HostCliClient, + sandbox: SandboxClient, + home: string, +): Promise { + const env = testEnv(home); + await bestEffort(() => + host.command("node", [CLI_ENTRYPOINT, SANDBOX_NAME, "destroy", "--yes"], { + artifactName: "cleanup-nemoclaw-destroy-cloud-inference", + env, + timeoutMs: 120_000, + }), + ); + await bestEffort(() => + sandbox.openshell(["sandbox", "delete", SANDBOX_NAME], { + artifactName: "cleanup-openshell-sandbox-delete-cloud-inference", + env, + timeoutMs: 60_000, + }), + ); +} + +function openAiChatContent(raw: string): string { + const parsed = JSON.parse(raw) as { + choices?: Array<{ + message?: { + content?: unknown; + reasoning?: unknown; + reasoning_content?: unknown; + }; + text?: unknown; + }>; + }; + const first = parsed.choices?.[0]; + const message = first?.message; + for (const value of [ + message?.content, + message?.reasoning_content, + message?.reasoning, + first?.text, + ]) { + if (typeof value === "string" && value.trim()) return value.trim(); + } + return ""; +} + +async function expectCliOnPath(host: HostCliClient, home: string): Promise { + const result = await host.command( + "bash", + [ + "-lc", + "command -v nemoclaw && command -v openshell && nemoclaw --version && openshell --version", + ], + { + artifactName: "phase-1-cli-path-check", + env: testEnv(home), + timeoutMs: 30_000, + }, + ); + expect(result.exitCode, resultText(result)).toBe(0); +} + +async function expectLiveChatPong( + sandbox: SandboxClient, + home: string, + apiKey: string, +): Promise<{ attempt: number; content: string }> { + const payload = JSON.stringify({ + model: CLOUD_MODEL, + messages: [{ role: "user", content: "Reply with exactly one word: PONG" }], + max_tokens: 100, + }); + let lastFailure = "chat completion was not attempted"; + + for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) { + const response = await sandbox.exec( + SANDBOX_NAME, + [ + "curl", + "-sS", + "--max-time", + "90", + "https://inference.local/v1/chat/completions", + "-H", + "Content-Type: application/json", + "--data-raw", + payload, + ], + { + artifactName: `phase-2-inference-local-chat-attempt-${attempt}`, + env: testEnv(home), + redactionValues: [apiKey], + timeoutMs: CHAT_TIMEOUT_MS, + }, + ); + + if (response.exitCode !== 0) { + lastFailure = `ssh/curl failed (exit ${response.exitCode}): ${resultText(response).slice(0, 500)}`; + } else if (!response.stdout.trim()) { + lastFailure = "empty response from inference.local"; + } else { + try { + const content = openAiChatContent(response.stdout); + if (/pong/i.test(content)) return { attempt, content }; + lastFailure = `expected PONG, got: ${content.slice(0, 300)}`; + } catch (error) { + lastFailure = `response was not parseable JSON: ${ + error instanceof Error ? error.message : String(error) + }; body: ${response.stdout.slice(0, 500)}`; + } + } + + if (attempt < MAX_ATTEMPTS) await sleep(RETRY_SLEEP_MS); + } + + throw new Error(`Live chat failed after ${MAX_ATTEMPTS} attempt(s): ${lastFailure}`); +} + +test.skipIf(!shouldRunLiveE2EScenarios())( + "cloud inference: inference.local chat and OpenClaw skill filesystem validate", + async ({ artifacts, cleanup, host, sandbox, secrets, skip }) => { + const apiKey = secrets.required("NVIDIA_API_KEY"); + expect(apiKey.startsWith("nvapi-"), "NVIDIA_API_KEY must start with nvapi-").toBe(true); + + expect(fs.existsSync(CLI_ENTRYPOINT), `missing CLI entrypoint: ${CLI_ENTRYPOINT}`).toBe(true); + expect( + fs.existsSync(REPO_SKILL_VALIDATOR), + `missing repo skill validator: ${REPO_SKILL_VALIDATOR}`, + ).toBe(true); + expect( + fs.existsSync(SANDBOX_SKILL_VALIDATOR), + `missing sandbox skill validator: ${SANDBOX_SKILL_VALIDATOR}`, + ).toBe(true); + + await artifacts.writeJson("scenario.json", { + id: "cloud-inference", + runner: "vitest", + boundary: "install-sh-onboard-sandbox-inference-local-skill-filesystem", + legacySource: "test/e2e/test-cloud-inference-e2e.sh", + contracts: [ + "Docker is running before install/onboard", + "NVIDIA_API_KEY is present and nvapi-prefixed", + "install.sh --non-interactive creates or recreates the named OpenClaw sandbox", + "nemoclaw and openshell are available on PATH after install", + "curl inside the sandbox reaches https://inference.local/v1/chat/completions and returns PONG", + "repo .agents/skills SKILL.md frontmatter and body validate", + "sandbox /sandbox/.openclaw and openclaw.json validate; skills subdir may be present or absent", + ], + model: CLOUD_MODEL, + maxChatAttempts: MAX_ATTEMPTS, + preContractExternalProviderFailureHandling: { + status: "skip", + sourceBoundary: "external NVIDIA Endpoints provider availability", + evidenceArtifact: "transient-provider-validation.skip.json", + }, + }); + + const docker = await host.command("docker", ["info"], { + artifactName: "phase-1-docker-info-cloud-inference", + env: buildAvailabilityProbeEnv(), + timeoutMs: 30_000, + }); + if (docker.exitCode !== 0) { + if (process.env.GITHUB_ACTIONS === "true") { + throw new Error(`Docker is required for cloud inference E2E: ${resultText(docker)}`); + } + return skip("Docker is required for cloud inference E2E"); + } + + const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-cloud-inference-home-")); + cleanup.add(`remove cloud inference state for ${SANDBOX_NAME}`, async () => { + await cleanupCloudInferenceState(host, sandbox, home); + fs.rmSync(home, { recursive: true, force: true }); + }); + await cleanupCloudInferenceState(host, sandbox, home); + + const install = await host.command( + "bash", + ["install.sh", "--non-interactive", "--yes-i-accept-third-party-software"], + { + artifactName: "phase-1-install-and-onboard-cloud-inference", + cwd: REPO_ROOT, + env: testEnv(home, { + NVIDIA_API_KEY: apiKey, + NEMOCLAW_AGENT: "openclaw", + NEMOCLAW_PROVIDER: "cloud", + NEMOCLAW_RECREATE_SANDBOX: "1", + NEMOCLAW_SANDBOX_NAME: SANDBOX_NAME, + }), + redactionValues: [apiKey], + timeoutMs: INSTALL_TIMEOUT_MS, + }, + ); + const preContractFailure = + install.exitCode === 0 ? null : classifyPreContractExternalProviderFailure(install); + if (preContractFailure) { + await writePreContractExternalProviderSkip(artifacts, install, preContractFailure); + return skip("NVIDIA endpoint validation was unavailable/rate-limited during install/onboard"); + } + expect(install.exitCode, resultText(install)).toBe(0); + + await expectCliOnPath(host, home); + + const chat = await expectLiveChatPong(sandbox, home, apiKey); + await artifacts.writeJson("phase-2-chat-result.json", { + model: CLOUD_MODEL, + attempt: chat.attempt, + content: chat.content, + }); + + const repoSkills = await host.command("bash", [REPO_SKILL_VALIDATOR, "--repo", REPO_ROOT], { + artifactName: "phase-3-validate-repo-skills", + cwd: REPO_ROOT, + env: testEnv(home), + timeoutMs: 60_000, + }); + expect(repoSkills.exitCode, resultText(repoSkills)).toBe(0); + + const sandboxSkills = await host.command("bash", [SANDBOX_SKILL_VALIDATOR], { + artifactName: "phase-3-validate-sandbox-openclaw-skills", + cwd: REPO_ROOT, + env: testEnv(home, { SANDBOX_NAME }), + timeoutMs: 90_000, + }); + expect(sandboxSkills.exitCode, resultText(sandboxSkills)).toBe(0); + const sandboxSkillStatus = /SKILLS_SUBDIR=present/.test(sandboxSkills.stdout) + ? "present" + : /SKILLS_SUBDIR=absent/.test(sandboxSkills.stdout) + ? "absent" + : "unknown"; + expect(sandboxSkillStatus, resultText(sandboxSkills)).not.toBe("unknown"); + + await artifacts.writeJson("scenario-result.json", { + id: "cloud-inference", + status: "passed", + assertions: { + dockerRunning: docker.exitCode === 0, + installCompleted: install.exitCode === 0, + chatReturnedPong: /pong/i.test(chat.content), + repoSkillsValidated: repoSkills.exitCode === 0, + sandboxOpenClawLayoutValidated: sandboxSkills.exitCode === 0, + sandboxSkillsSubdir: sandboxSkillStatus, + }, + }); + }, + TEST_TIMEOUT_MS, +); diff --git a/test/e2e-scenario/support-tests/cloud-inference-provider-skip.test.ts b/test/e2e-scenario/support-tests/cloud-inference-provider-skip.test.ts new file mode 100644 index 00000000000..f5dda0199e6 --- /dev/null +++ b/test/e2e-scenario/support-tests/cloud-inference-provider-skip.test.ts @@ -0,0 +1,109 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, expect, it } from "vitest"; +import { + buildPreContractExternalProviderSkipEvidence, + classifyPreContractExternalProviderFailure, + PRE_CONTRACT_EXTERNAL_PROVIDER_REMOVAL_CONDITION, + PRE_CONTRACT_EXTERNAL_PROVIDER_SKIP_REASON, + PRE_CONTRACT_EXTERNAL_PROVIDER_SOURCE_BOUNDARY, +} from "../live/cloud-inference-provider-skip.ts"; + +function probeOutput(output: string): { stdout: string; stderr: string } { + return { stdout: "", stderr: output }; +} + +describe("cloud inference pre-contract provider skip classifier", () => { + it("skips only endpoint validation failures with transient provider evidence", () => { + expect( + classifyPreContractExternalProviderFailure( + probeOutput("Chat Completions API validation failed: returned HTTP 429 from provider"), + ), + ).toMatchObject({ + classifier: "transient-endpoint-validation", + }); + + expect( + classifyPreContractExternalProviderFailure( + probeOutput("install failed: returned HTTP 429 while downloading a package"), + ), + ).toBeNull(); + }); + + it("skips sanitized endpoint-validation failures before the legacy contract starts", () => { + const classification = classifyPreContractExternalProviderFailure( + probeOutput("failed to verify inference endpoint: provider response was sanitized"), + ); + + expect(classification).toMatchObject({ + classifier: "rate-limited-or-sanitized-endpoint-validation", + outputTail: "failed to verify inference endpoint: provider response was sanitized", + }); + }); + + it("does not skip credential or auth endpoint-validation failures", () => { + expect( + classifyPreContractExternalProviderFailure( + probeOutput("endpoint validation failed: invalid NVIDIA_API_KEY credential"), + ), + ).toBeNull(); + expect( + classifyPreContractExternalProviderFailure( + probeOutput("failed to verify inference endpoint: returned HTTP 401 unauthorized"), + ), + ).toBeNull(); + expect( + classifyPreContractExternalProviderFailure( + probeOutput("Chat Completions API validation failed: HTTP 403 forbidden"), + ), + ).toBeNull(); + }); + + it("does not skip non-transient product validation failures", () => { + expect( + classifyPreContractExternalProviderFailure( + probeOutput( + "endpoint validation failed: install.sh wrote an invalid inference configuration schema", + ), + ), + ).toBeNull(); + }); + + it("builds skip evidence with the source boundary and removal condition", () => { + const classification = classifyPreContractExternalProviderFailure( + probeOutput("endpoint validation failed: returned HTTP 429 from provider"), + ); + expect(classification).not.toBeNull(); + + const evidence = buildPreContractExternalProviderSkipEvidence( + { + exitCode: 1, + timedOut: false, + artifacts: { + stdout: "shell/install.stdout.txt", + stderr: "shell/install.stderr.txt", + result: "shell/install.result.json", + }, + }, + classification!, + ); + + expect(evidence).toMatchObject({ + id: "cloud-inference", + status: "skipped", + reason: PRE_CONTRACT_EXTERNAL_PROVIDER_SKIP_REASON, + phase: "install-sh-onboard", + legacyContractStarted: false, + sourceBoundary: PRE_CONTRACT_EXTERNAL_PROVIDER_SOURCE_BOUNDARY, + removalCondition: PRE_CONTRACT_EXTERNAL_PROVIDER_REMOVAL_CONDITION, + installExitCode: 1, + installTimedOut: false, + artifacts: { + stdout: "shell/install.stdout.txt", + stderr: "shell/install.stderr.txt", + result: "shell/install.result.json", + }, + }); + }); +}); diff --git a/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts b/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts index 450d18f0e70..4cfd808d80c 100644 --- a/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts +++ b/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts @@ -181,6 +181,22 @@ describe("e2e-vitest-scenarios workflow boundary", () => { selectedFreeStandingJobs: ["inference-routing-vitest"], registryScenarios: [], }); + expect( + evaluateE2eVitestWorkflowDispatchSelectors({ scenarios: "cloud-inference" }), + ).toMatchObject({ + valid: true, + liveScenariosRuns: false, + selectedFreeStandingJobs: ["cloud-inference-vitest"], + registryScenarios: [], + }); + expect( + evaluateE2eVitestWorkflowDispatchSelectors({ jobs: "cloud-inference-vitest" }), + ).toMatchObject({ + valid: true, + liveScenariosRuns: false, + selectedFreeStandingJobs: ["cloud-inference-vitest"], + registryScenarios: [], + }); expect(evaluateE2eVitestWorkflowDispatchSelectors({ scenarios: "hermes-e2e" })).toMatchObject({ valid: true, liveScenariosRuns: false, diff --git a/tools/e2e-scenarios/workflow-boundary.mts b/tools/e2e-scenarios/workflow-boundary.mts index a8c226c516b..3a757d18c9c 100644 --- a/tools/e2e-scenarios/workflow-boundary.mts +++ b/tools/e2e-scenarios/workflow-boundary.mts @@ -1291,6 +1291,107 @@ function validateOnboardNegativePathsVitestJob(errors: string[], jobs: WorkflowR } } +function validateCloudInferenceVitestJob(errors: string[], jobs: WorkflowRecord): void { + const jobName = "cloud-inference-vitest"; + const job = asRecord(jobs[jobName]); + if (Object.keys(job).length === 0) { + errors.push("workflow missing cloud-inference-vitest job"); + return; + } + + if (job["runs-on"] !== "ubuntu-latest") { + errors.push("cloud-inference-vitest job must run on ubuntu-latest"); + } + validateFreeStandingJobSelector(errors, jobs, jobName, "cloud-inference"); + if (job["timeout-minutes"] !== 50) { + errors.push("cloud-inference-vitest job must keep the 50 minute timeout"); + } + + const jobEnv = asRecord(job.env); + if ( + jobEnv.E2E_ARTIFACT_DIR !== + "${{ github.workspace }}/e2e-artifacts/vitest/cloud-inference" + ) { + errors.push( + "cloud-inference-vitest job must write artifacts under e2e-artifacts/vitest/cloud-inference", + ); + } + if (jobEnv.NEMOCLAW_CLI_BIN !== "${{ github.workspace }}/bin/nemoclaw.js") { + errors.push("cloud-inference-vitest job must point NEMOCLAW_CLI_BIN at the repo CLI"); + } + if (jobEnv.NEMOCLAW_RUN_E2E_SCENARIOS !== "1") { + errors.push("cloud-inference-vitest job must set NEMOCLAW_RUN_E2E_SCENARIOS=1"); + } + if (jobEnv.NEMOCLAW_SANDBOX_NAME !== "e2e-cloud-inference") { + errors.push("cloud-inference-vitest job must set NEMOCLAW_SANDBOX_NAME=e2e-cloud-inference"); + } + if (jobEnv.OPENSHELL_GATEWAY !== "nemoclaw") { + errors.push("cloud-inference-vitest job must force OPENSHELL_GATEWAY=nemoclaw"); + } + requireEnvDoesNotExposeSecret(errors, "cloud-inference-vitest job", jobEnv, "NVIDIA_API_KEY"); + + const steps = asSteps(job.steps); + requireNoDispatchInputInterpolation(errors, steps); + for (const step of steps) { + if (step.name !== "Run cloud inference live test") { + requireEnvDoesNotExposeSecret( + errors, + `cloud-inference-vitest step '${step.name ?? step.uses ?? ""}'`, + asRecord(step.env), + "NVIDIA_API_KEY", + ); + } + } + + const checkout = steps.find((step) => stringValue(step.uses).startsWith("actions/checkout@")); + if (!checkout) errors.push("cloud-inference-vitest job missing checkout step"); + requireFullShaAction(errors, checkout, "cloud-inference-vitest checkout"); + if (asRecord(checkout?.with)["persist-credentials"] !== false) { + errors.push("cloud-inference-vitest checkout step must set persist-credentials=false"); + } + + const setupNode = namedStep(steps, "Set up Node"); + if (!setupNode) errors.push("cloud-inference-vitest job missing step: Set up Node"); + requireFullShaAction(errors, setupNode, "cloud-inference-vitest setup-node"); + + const installRootDependencies = requireJobStep( + errors, + jobName, + steps, + "Install root dependencies", + ); + requireRunContains(errors, installRootDependencies, "npm ci --ignore-scripts"); + + const buildCli = requireJobStep(errors, jobName, steps, "Build CLI"); + requireRunContains(errors, buildCli, "npm run build:cli"); + + const runVitest = requireJobStep(errors, jobName, steps, "Run cloud inference live test"); + const runVitestEnv = asRecord(runVitest?.env); + if (runVitestEnv.NVIDIA_API_KEY !== "${{ secrets.NVIDIA_API_KEY }}") { + errors.push("cloud-inference-vitest run step must receive NVIDIA_API_KEY from secrets"); + } + requireRunContains(errors, runVitest, "npx vitest run --project e2e-scenarios-live"); + requireRunContains(errors, runVitest, "test/e2e-scenario/live/cloud-inference.test.ts"); + + const upload = requireJobStep(errors, jobName, steps, "Upload cloud inference artifacts"); + requireFullShaAction(errors, upload, "cloud-inference-vitest upload-artifact"); + const uploadWith = asRecord(upload?.with); + if (uploadWith.name !== "e2e-vitest-scenarios-cloud-inference") { + errors.push("cloud-inference-vitest artifact upload name must be stable"); + } + const uploadPath = stringValue(uploadWith.path); + requireUploadPathContains(errors, uploadPath, "e2e-artifacts/vitest/cloud-inference/"); + if (uploadWith["include-hidden-files"] !== false) { + errors.push("cloud-inference-vitest artifact upload must set include-hidden-files: false"); + } + if (uploadWith["if-no-files-found"] !== "ignore") { + errors.push("cloud-inference-vitest artifact upload must ignore missing fixture artifacts"); + } + if (uploadWith["retention-days"] !== 14) { + errors.push("cloud-inference-vitest artifact upload retention-days must be 14"); + } +} + function requireNoDockerHubAuthInRun( errors: string[], owner: string, @@ -2154,6 +2255,7 @@ export function validateE2eVitestScenariosWorkflowBoundary( validateSkillAgentVitestJob(errors, jobs); validateFreeStandingJobSelector(errors, jobs, "credential-migration-vitest"); validateFreeStandingJobSelector(errors, jobs, "inference-routing-vitest", "inference-routing"); + validateCloudInferenceVitestJob(errors, jobs); validateRuntimeOverridesVitestJob(errors, jobs); validateDoubleOnboardVitestJob(errors, jobs); validateHermesE2EVitestJob(errors, jobs);