Skip to content
55 changes: 54 additions & 1 deletion .github/workflows/e2e-vitest-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,6 @@ jobs:
if-no-files-found: ignore
retention-days: 14


cloud-onboard-vitest:
needs: generate-matrix
if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',cloud-onboard-vitest,') || contains(format(',{0},', inputs.scenarios), ',cloud-onboard,') }}
Expand Down Expand Up @@ -4867,6 +4866,59 @@ jobs:
docker logout docker.io || true
rm -rf "${DOCKER_CONFIG}"

spark-install-vitest:
needs: generate-matrix
if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',spark-install-vitest,') || contains(format(',{0},', inputs.scenarios), ',spark-install,') }}
runs-on: ubuntu-latest
timeout-minutes: 45
env:
FREE_STANDING_VITEST_JOB: "1"
FREE_STANDING_SCENARIO_ID: "spark-install"
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/spark-install
NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js
NEMOCLAW_RUN_E2E_SCENARIOS: "1"
NEMOCLAW_NON_INTERACTIVE: "1"
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1"
NEMOCLAW_FRESH: "1"
NEMOCLAW_SANDBOX_NAME: "e2e-spark-install-vitest"
NEMOCLAW_PROVIDER: "cloud"
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: Run Spark install live test
# Migrated from test/e2e/test-spark-install.sh. This preserves the
# Linux + Docker prerequisite gate, the plain non-interactive
# install.sh/public curl|bash boundary, install-log retention, PATH
# refresh, and post-install nemoclaw/openshell/--help checks.
env:
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
run: |
set -euo pipefail
npx vitest run --project e2e-scenarios-live \
test/e2e-scenario/live/spark-install.test.ts \
--silent=false --reporter=default

- name: Upload Spark install artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-vitest-scenarios-spark-install
path: e2e-artifacts/vitest/spark-install/
include-hidden-files: false
if-no-files-found: ignore
retention-days: 14

# ── PR result comment (mirrors nightly-e2e.yaml's report-to-pr) ───────────
# Posts a results table on the open PR for the dispatching branch (or the
Expand Down Expand Up @@ -4942,6 +4994,7 @@ jobs:
openclaw-discord-pairing-vitest,
openclaw-slack-pairing-vitest,
channels-stop-start-vitest,
spark-install-vitest,
]
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
permissions:
Expand Down
145 changes: 145 additions & 0 deletions test/e2e-scenario/live/spark-install-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import fs from "node:fs";

import { resultText } from "../fixtures/clients/command.ts";
import { validateSandboxName } from "../fixtures/clients/sandbox.ts";
import { redactString } from "../fixtures/redaction.ts";
import type { ShellProbeResult } from "../fixtures/shell-probe.ts";

export const DEFAULT_SPARK_INSTALL_SANDBOX_NAME = "e2e-spark-install-vitest";
export const DEFAULT_INSTALL_URL = "https://www.nvidia.com/nemoclaw.sh";

export type InstallerInvocation = {
mode: "local" | "public";
script: string;
installUrl?: string;
};

type InstallerInvocationOptions = {
repoRoot: string;
env?: NodeJS.ProcessEnv;
};

function fail(message: string): never {
throw new Error(message);
}

function requireSparkInstallContract(condition: boolean, message: string): void {
condition || fail(message);
}

function shellQuote(value: string): string {
return `'${value.replace(/'/g, `'"'"'`)}'`;
}

export function assertSparkInstallSandboxName(name: string): string {
validateSandboxName(name);
requireSparkInstallContract(
name.startsWith("e2e-spark-install-"),
`spark install sandbox must use the e2e-spark-install- prefix: ${name}`,
);
return name;
}

export function assertRequiredInstallerEnv(env: NodeJS.ProcessEnv): void {
requireSparkInstallContract(
env.NEMOCLAW_NON_INTERACTIVE === "1",
"NEMOCLAW_NON_INTERACTIVE=1 is required for the Spark install migration",
);
requireSparkInstallContract(
env.NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE === "1",
"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 is required for the Spark install migration",
);
}

export function validatePublicInstallUrl(raw: string): string {
const url = new URL(raw);
const hostname = url.hostname.toLowerCase();
requireSparkInstallContract(url.protocol === "https:", "public installer URL must use https");
requireSparkInstallContract(
url.username === "" && url.password === "",
"public installer URL must not include credentials",
);
requireSparkInstallContract(
hostname === "www.nvidia.com",
`public installer URL host is not allowed: ${url.hostname}`,
);
requireSparkInstallContract(
url.pathname === "/nemoclaw.sh",
`public installer URL path is not allowed: ${url.pathname}`,
);
requireSparkInstallContract(
url.search === "" && url.hash === "",
"public installer URL must not include query or fragment data",
);
return url.toString();
}

export function buildInstallerInvocation({
repoRoot,
env = process.env,
}: InstallerInvocationOptions): InstallerInvocation {
return env.NEMOCLAW_E2E_PUBLIC_INSTALL === "1"
? (() => {
const installUrl = validatePublicInstallUrl(
env.NEMOCLAW_INSTALL_SCRIPT_URL ?? DEFAULT_INSTALL_URL,
);
return {
mode: "public" as const,
installUrl,
script: [
"set -euo pipefail",
"&&",
`curl -fsSL ${shellQuote(installUrl)}`,
"|",
"NEMOCLAW_NON_INTERACTIVE=1",
"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1",
"bash",
].join(" "),
};
})()
: {
mode: "local",
script: [
`cd ${shellQuote(repoRoot)}`,
"&&",
"NEMOCLAW_NON_INTERACTIVE=1",
"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1",
"bash install.sh --non-interactive",
].join(" "),
};
}

export function writeRedactedInstallLog(
file: string,
result: Pick<ShellProbeResult, "stdout" | "stderr">,
redactionValues: readonly string[] = [],
): void {
fs.writeFileSync(file, redactString(resultText(result), redactionValues));
}

export function logTail(
file: string,
lineCount = 80,
redactionValues: readonly string[] = [],
): string {
const lines = fs.existsSync(file) ? fs.readFileSync(file, "utf8").split(/\r?\n/) : [];
return redactString(lines.slice(-lineCount).join("\n"), redactionValues);
}

export function exitDetail(
result: Pick<ShellProbeResult, "stdout" | "stderr">,
installLog?: string,
redactionValues: readonly string[] = [],
): string {
return [
redactString(resultText(result), redactionValues),
installLog
? `--- install log tail (${installLog}) ---\n${logTail(installLog, 80, redactionValues)}`
: "",
]
.filter(Boolean)
.join("\n");
}
162 changes: 162 additions & 0 deletions test/e2e-scenario/live/spark-install.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

/** Live Vitest replacement for test/e2e/test-spark-install.sh. */

import fs from "node:fs";
import path from "node:path";

import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts";
import { resultText } from "../fixtures/clients/command.ts";
import type { HostCliClient } from "../fixtures/clients/host.ts";
import { expect, test } from "../fixtures/e2e-test.ts";
import {
shouldRunInstallerIntegration,
shouldRunLiveE2EScenarios,
} from "../fixtures/live-project-gate.ts";
import {
assertRequiredInstallerEnv,
assertSparkInstallSandboxName,
buildInstallerInvocation,
DEFAULT_INSTALL_URL,
DEFAULT_SPARK_INSTALL_SANDBOX_NAME,
exitDetail,
writeRedactedInstallLog,
} from "./spark-install-helpers.ts";

const REPO_ROOT = path.resolve(import.meta.dirname, "../../..");
const SANDBOX_NAME = assertSparkInstallSandboxName(
process.env.NEMOCLAW_SANDBOX_NAME ?? DEFAULT_SPARK_INSTALL_SANDBOX_NAME,
);
const LIVE_TIMEOUT_MS = 40 * 60_000;
const INSTALL_TIMEOUT_MS = 30 * 60_000;
const liveTest =
process.platform === "linux" && (shouldRunLiveE2EScenarios() || shouldRunInstallerIntegration())
? test
: test.skip;

function shellQuote(value: string): string {
return `'${value.replace(/'/g, `'"'"'`)}'`;
}

function env(extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
return {
...buildAvailabilityProbeEnv(),
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1",
NEMOCLAW_NON_INTERACTIVE: "1",
NEMOCLAW_FRESH: "1",
NEMOCLAW_RECREATE_SANDBOX: "1",
NEMOCLAW_SANDBOX_NAME: SANDBOX_NAME,
NEMOCLAW_PROVIDER: "cloud",
OPENSHELL_GATEWAY: "nemoclaw",
...extra,
};
}

function sourceInstalledPathProbe(): string {
return [
'if [ -f "$HOME/.bashrc" ]; then source "$HOME/.bashrc" 2>/dev/null || true; fi',
'export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"',
'if [ -s "$NVM_DIR/nvm.sh" ]; then . "$NVM_DIR/nvm.sh"; fi',
'if [ -d "$HOME/.local/bin" ] && [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then export PATH="$HOME/.local/bin:$PATH"; fi',
"command -v nemoclaw",
"command -v openshell",
"nemoclaw --help >/dev/null",
].join("; ");
}

async function bestEffortCleanup(host: HostCliClient): Promise<void> {
const cleanup = [
`if command -v nemoclaw >/dev/null 2>&1; then nemoclaw ${shellQuote(SANDBOX_NAME)} destroy --yes >/dev/null 2>&1 || true; fi`,
`if command -v openshell >/dev/null 2>&1; then openshell sandbox delete ${shellQuote(SANDBOX_NAME)} >/dev/null 2>&1 || true; fi`,
"if command -v openshell >/dev/null 2>&1; then openshell gateway destroy -g nemoclaw >/dev/null 2>&1 || true; fi",
].join("\n");
await host.command("bash", ["-lc", cleanup], {
artifactName: "cleanup-spark-install-state",
env: env(),
timeoutMs: 120_000,
});
}

liveTest(
"spark install path: standard non-interactive install leaves NemoClaw and OpenShell usable",
{ timeout: LIVE_TIMEOUT_MS },
async ({ artifacts, cleanup, host, secrets }) => {
await artifacts.writeJson("scenario.json", {
id: "spark-install",
legacySource: "test/e2e/test-spark-install.sh",
sandboxName: SANDBOX_NAME,
contracts: [
"Linux + Docker prerequisite gate",
"NEMOCLAW_NON_INTERACTIVE=1 and NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 are required for the install",
"standard installer path runs without Spark-specific setup",
"optional NEMOCLAW_E2E_PUBLIC_INSTALL=1 curl|bash path is selected by the same env gate",
"install log is retained",
"nemoclaw and openshell are on PATH after profile refresh",
"nemoclaw --help exits 0",
],
});

expect(process.platform).toBe("linux");

expect(fs.existsSync(path.join(REPO_ROOT, "install.sh")), "repo install.sh must exist").toBe(
true,
);

const docker = await host.command("docker", ["info"], {
artifactName: "phase-0-docker-info",
env: env(),
timeoutMs: 30_000,
});
expect(docker.exitCode, resultText(docker)).toBe(0);

assertRequiredInstallerEnv(process.env);

const apiKey = secrets.required("NVIDIA_API_KEY");
const redactionValues = [apiKey];
cleanup.add(`remove ${SANDBOX_NAME} after Spark install smoke`, () => bestEffortCleanup(host));
await bestEffortCleanup(host);

const installLog = process.env.INSTALL_LOG ?? artifacts.pathFor("logs/install.log");
fs.mkdirSync(path.dirname(installLog), { recursive: true });
const installer = buildInstallerInvocation({
repoRoot: REPO_ROOT,
env: process.env,
});
await artifacts.writeJson("installer.json", {
mode: installer.mode,
installUrl: installer.installUrl,
installLog,
});
expect(installer.script).toContain("NEMOCLAW_NON_INTERACTIVE=1");
expect(installer.script).toContain("NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1");
expect(
installer.mode === "local"
? installer.script.includes("bash install.sh --non-interactive") &&
!installer.script.includes("setup-spark")
: installer.script.includes("curl -fsSL") && installer.installUrl === DEFAULT_INSTALL_URL,
).toBe(true);

const install = await host.command("bash", ["-lc", installer.script], {
artifactName: `phase-1-${installer.mode}-install`,
cwd: REPO_ROOT,
env: env({
NVIDIA_API_KEY: apiKey,
}),
redactionValues,
timeoutMs: INSTALL_TIMEOUT_MS,
});
writeRedactedInstallLog(installLog, install, redactionValues);
expect(install.exitCode, exitDetail(install, installLog, redactionValues)).toBe(0);
expect(fs.existsSync(installLog), `${installLog} should be written`).toBe(true);

const installedCommands = await host.command("bash", ["-lc", sourceInstalledPathProbe()], {
artifactName: "phase-2-installed-cli-path-probe",
env: env(),
timeoutMs: 60_000,
});
expect(installedCommands.exitCode, resultText(installedCommands)).toBe(0);
expect(installedCommands.stdout).toContain("nemoclaw");
expect(installedCommands.stdout).toContain("openshell");
},
);
Loading