diff --git a/.github/workflows/e2e-vitest-scenarios.yaml b/.github/workflows/e2e-vitest-scenarios.yaml index e23eb79240b..02d5ca403be 100644 --- a/.github/workflows/e2e-vitest-scenarios.yaml +++ b/.github/workflows/e2e-vitest-scenarios.yaml @@ -40,7 +40,7 @@ jobs: SCENARIOS: ${{ inputs.scenarios }} run: | set -euo pipefail - allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,hermes-e2e-vitest,network-policy-vitest,token-rotation-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery" + allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,credential-migration-vitest,hermes-e2e-vitest,network-policy-vitest,token-rotation-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery" if [ -n "${JOBS}" ] && [ -n "${SCENARIOS}" ]; then echo "::error::Use either scenarios or jobs, not both." >&2 exit 1 @@ -93,7 +93,7 @@ jobs: SCENARIOS: ${{ inputs.scenarios }} run: | set -euo pipefail - allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,hermes-e2e-vitest,network-policy-vitest,token-rotation-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery" + allowed_jobs="openshell-version-pin-vitest,onboard-negative-paths-vitest,credential-migration-vitest,hermes-e2e-vitest,network-policy-vitest,token-rotation-vitest,openclaw-tui-chat-correlation-vitest,gateway-guard-recovery" args=(--emit-live-matrix) matrix="" hermes_selected=false @@ -363,6 +363,84 @@ jobs: if-no-files-found: ignore retention-days: 14 + credential-migration-vitest: + needs: validate-jobs + if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',credential-migration-vitest,') }} + runs-on: ubuntu-latest + timeout-minutes: 50 + env: + E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/credential-migration + NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js + NEMOCLAW_RUN_E2E_SCENARIOS: "1" + NEMOCLAW_SANDBOX_NAME: "e2e-cred-migration" + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + with: + persist-credentials: false + + - name: Authenticate to Docker Hub + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + shell: bash + run: | + set -euo pipefail + if [[ -z "${DOCKERHUB_USERNAME}" || -z "${DOCKERHUB_TOKEN}" ]]; then + echo "::notice::Docker Hub credentials not configured; continuing with anonymous pulls." + exit 0 + fi + login_succeeded=0 + for attempt in 1 2 3; do + if echo "${DOCKERHUB_TOKEN}" | timeout 30s docker login docker.io --username "${DOCKERHUB_USERNAME}" --password-stdin; then + login_succeeded=1 + break + fi + if [[ "$attempt" -lt 3 ]]; then + echo "::warning::Docker Hub login attempt ${attempt} failed; retrying." + sleep 5 + fi + done + if [[ "$login_succeeded" -ne 1 ]]; then + echo "::warning::Docker Hub login failed after 3 attempts; continuing with anonymous pulls." + fi + + - 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 credential migration live test + # Migrated from test/e2e/test-credential-migration.sh. This live test + # needs NVIDIA_API_KEY only as the staged legacy credential value; it + # preserves the default NVIDIA provider/key migration path while + # pinning a lower-quota catalog model in the test fixture. + env: + NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }} + run: | + set -euo pipefail + npx vitest run --project e2e-scenarios-live \ + test/e2e-scenario/live/credential-migration.test.ts \ + --silent=false --reporter=default + + - name: Upload credential migration artifacts + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: e2e-vitest-scenarios-credential-migration + path: e2e-artifacts/vitest/credential-migration/ + include-hidden-files: false + if-no-files-found: ignore + retention-days: 14 + + + hermes-e2e-vitest: needs: [validate-jobs, generate-matrix] if: ${{ needs.generate-matrix.outputs.hermes_selected == 'true' }} @@ -743,6 +821,7 @@ jobs: live-scenarios, openshell-version-pin-vitest, onboard-negative-paths-vitest, + credential-migration-vitest, hermes-e2e-vitest, network-policy-vitest, token-rotation-vitest, diff --git a/.github/workflows/nightly-e2e.yaml b/.github/workflows/nightly-e2e.yaml index 0ebd5d0d840..a8f018c9b44 100644 --- a/.github/workflows/nightly-e2e.yaml +++ b/.github/workflows/nightly-e2e.yaml @@ -1516,17 +1516,51 @@ jobs: github.repository == 'NVIDIA/NemoClaw' && (github.event_name != 'workflow_dispatch' || inputs.jobs == '' || contains(format(',{0},', inputs.jobs), ',credential-migration-e2e,')) - uses: ./.github/workflows/e2e-script.yaml - with: - ref: ${{ inputs.target_ref || github.ref }} - script: test/e2e/test-credential-migration.sh - timeout_minutes: 30 - artifact_name: "install-log-credential-migration" - artifact_path: "/tmp/nemoclaw-e2e-install.log" - env_json: '{"NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE":"1","NEMOCLAW_NON_INTERACTIVE":"1","NEMOCLAW_RECREATE_SANDBOX":"1","NEMOCLAW_SANDBOX_NAME":"e2e-cred-migration"}' - nvidia_api_key: true - github_token: true - secrets: *nightly-e2e-default-secrets + runs-on: ubuntu-latest + permissions: + contents: read + timeout-minutes: 50 + steps: + - *target-ref-checkout + + - *dockerhub-auth-step + - name: Setup Node + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + 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 credential migration Vitest test + # Trusted-code boundary: this job runs the checked-out target ref with + # NVIDIA_API_KEY because it validates live credential migration into the + # OpenShell gateway. Keep checkout credentials disabled, do not pass + # GITHUB_TOKEN, and rely on reviewed/maintainer-dispatched refs. + env: + NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }} + E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/credential-migration + NEMOCLAW_RUN_E2E_SCENARIOS: "1" + NEMOCLAW_SANDBOX_NAME: "e2e-cred-migration" + run: | + set -euo pipefail + npx vitest run --project e2e-scenarios-live \ + test/e2e-scenario/live/credential-migration.test.ts \ + --silent=false --reporter=default + + - name: Upload credential migration artifacts + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: credential-migration-artifacts + path: e2e-artifacts/vitest/credential-migration/ + include-hidden-files: false + if-no-files-found: ignore + retention-days: 14 snapshot-commands-e2e: if: >- github.repository == 'NVIDIA/NemoClaw' && (github.event_name != 'workflow_dispatch' || diff --git a/test/e2e-scenario/live/credential-migration.test.ts b/test/e2e-scenario/live/credential-migration.test.ts new file mode 100644 index 00000000000..a020a5a1133 --- /dev/null +++ b/test/e2e-scenario/live/credential-migration.test.ts @@ -0,0 +1,314 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; + +import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts"; +import type { HostCliClient } from "../fixtures/clients/host.ts"; +import { validateSandboxName } from "../fixtures/clients/sandbox.ts"; +import { expect, test } from "../fixtures/e2e-test.ts"; +import { shouldRunLiveE2EScenarios } from "../fixtures/live-project-gate.ts"; + +// Migrated from test/e2e/test-credential-migration.sh. This is a focused live +// Vitest test for the credential migration contract: a pre-gateway plaintext +// ~/.nemoclaw/credentials.json is staged only for allowlisted credential keys, +// a successful real onboard registers the migrated value with the OpenShell +// gateway, the plaintext file is removed after success, credentials list reads +// from the gateway, and secure unlink removes a planted symlink without touching +// its target. The live onboard intentionally follows the legacy default NVIDIA +// Endpoints path: NVIDIA_API_KEY is present only in the legacy file, absent from +// the onboard child env, and must migrate into the nvidia-prod gateway provider. +// No registry, migration ledger, or shared helper is introduced. + +const REPO_ROOT = path.resolve(import.meta.dirname, "../../.."); +const CLI_ENTRYPOINT = path.join(REPO_ROOT, "bin", "nemoclaw.js"); +const DIST_CREDENTIAL_STORE = path.join(REPO_ROOT, "dist", "lib", "credentials", "store.js"); +const ONBOARD_TIMEOUT_MS = 30 * 60_000; +const INSTALL_TIMEOUT_MS = 10 * 60_000; +const SANDBOX_NAME = process.env.NEMOCLAW_SANDBOX_NAME ?? `e2e-cred-migration-${process.pid}`; +const CREDENTIAL_MIGRATION_MODEL = "openai/gpt-oss-120b"; +validateSandboxName(SANDBOX_NAME); + +const runCredentialMigrationTest = shouldRunLiveE2EScenarios() ? test : test.skip; + +type CommandResult = { stdout: string; stderr: string; exitCode: number | null }; + +function resultText(result: { stdout: string; stderr: string }): string { + return [result.stdout, result.stderr].filter(Boolean).join("\n"); +} + +function testEnv(home: string, extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv { + const base = buildAvailabilityProbeEnv(); + return { + ...base, + HOME: home, + PATH: [path.join(home, ".local", "bin"), base.PATH].filter(Boolean).join(":"), + NEMOCLAW_NON_INTERACTIVE: "1", + NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1", + ...extra, + }; +} + +async function bestEffort(run: () => Promise): Promise { + try { + await run(); + } catch { + // Cleanup probes are intentionally best-effort. Some paths fail before + // openshell is installed or before gateway/sandbox state exists. + } +} + +async function ensureOpenshellAvailable(host: HostCliClient, home: string): Promise { + const env = testEnv(home); + const current = await host.command( + "bash", + ["-lc", "command -v openshell && openshell --version"], + { + artifactName: "prereq-openshell-version", + env, + timeoutMs: 30_000, + }, + ); + if (current.exitCode === 0) return current; + + const install = await host.command( + "bash", + [path.join(REPO_ROOT, "scripts", "install-openshell.sh")], + { + artifactName: "prereq-install-openshell", + cwd: REPO_ROOT, + env, + timeoutMs: INSTALL_TIMEOUT_MS, + }, + ); + expect(install.exitCode, `install-openshell.sh failed\n${resultText(install)}`).toBe(0); + + const afterInstall = await host.command( + "bash", + ["-lc", "command -v openshell && openshell --version"], + { + artifactName: "prereq-openshell-version-after-install", + env: testEnv(home), + timeoutMs: 30_000, + }, + ); + expect( + afterInstall.exitCode, + `openshell missing after install\n${resultText(afterInstall)}`, + ).toBe(0); + return afterInstall; +} + +async function cleanupCredentialMigrationState(host: HostCliClient, home: string): Promise { + const env = testEnv(home); + await bestEffort(() => + host.command("node", [CLI_ENTRYPOINT, SANDBOX_NAME, "destroy", "--yes"], { + artifactName: "cleanup-nemoclaw-destroy", + env, + redactionValues: [process.env.NVIDIA_API_KEY ?? ""], + timeoutMs: 120_000, + }), + ); + await bestEffort(() => + host.command("openshell", ["sandbox", "delete", SANDBOX_NAME], { + artifactName: "cleanup-openshell-sandbox-delete", + env, + timeoutMs: 60_000, + }), + ); + await bestEffort(() => + host.command("openshell", ["forward", "stop", "18789"], { + artifactName: "cleanup-openshell-forward-stop", + env, + timeoutMs: 30_000, + }), + ); + await bestEffort(() => + host.command("openshell", ["gateway", "destroy", "-g", "nemoclaw"], { + artifactName: "cleanup-openshell-gateway-destroy", + env, + timeoutMs: 120_000, + }), + ); +} + +runCredentialMigrationTest( + "credential migration stages legacy file into gateway and removes plaintext safely", + { timeout: ONBOARD_TIMEOUT_MS + INSTALL_TIMEOUT_MS + 5 * 60_000 }, + async ({ artifacts, cleanup, host, secrets, skip }) => { + // Use the existing nightly secret as the legacy NVIDIA credential. The + // onboard child env below deliberately does not receive NVIDIA_API_KEY, so + // the only source is ~/.nemoclaw/credentials.json — matching the retired + // shell lane's migration contract. + const migratedCredentialValue = secrets.required("NVIDIA_API_KEY"); + expect( + migratedCredentialValue.startsWith("nvapi-"), + "NVIDIA_API_KEY must start with nvapi-", + ).toBe(true); + expect(fs.existsSync(CLI_ENTRYPOINT), "bin/nemoclaw.js missing").toBe(true); + expect( + fs.existsSync(DIST_CREDENTIAL_STORE), + "run `npm run build:cli` before this live test", + ).toBe(true); + + const docker = await host.command("docker", ["info"], { + artifactName: "prereq-docker-info", + env: buildAvailabilityProbeEnv(), + timeoutMs: 30_000, + }); + if (docker.exitCode !== 0) { + if (process.env.GITHUB_ACTIONS === "true") { + throw new Error( + `Docker is required for credential migration live E2E: ${resultText(docker)}`, + ); + } + skip("Docker is required for credential migration live E2E"); + } + + const home = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-cred-migration-")); + const nemoclawDir = path.join(home, ".nemoclaw"); + const legacyFile = path.join(nemoclawDir, "credentials.json"); + cleanup.add(`remove credential migration state for ${SANDBOX_NAME}`, async () => { + await cleanupCredentialMigrationState(host, home); + fs.rmSync(home, { recursive: true, force: true }); + }); + + await artifacts.writeJson("scenario.json", { + id: "credential-migration", + runner: "vitest", + boundary: "real-onboard-openshell-gateway", + migratedFrom: "test/e2e/test-credential-migration.sh", + sandboxName: SANDBOX_NAME, + contracts: [ + "legacy credentials.json stages allowlisted provider keys into onboard env", + "successful default NVIDIA Endpoints onboard registers the migrated value with OpenShell gateway", + "onboard keeps the default NVIDIA provider/key/endpoint/policy path while pinning a low-quota catalog model", + "successful onboard removes plaintext credentials.json", + "tampered non-credential keys do not become gateway providers", + "credentials list reads providers from the gateway, not disk", + "secure unlink removes a final-component symlink without touching its target", + ], + }); + + await ensureOpenshellAvailable(host, home); + await cleanupCredentialMigrationState(host, home); + + fs.rmSync(nemoclawDir, { recursive: true, force: true }); + fs.mkdirSync(nemoclawDir, { recursive: true, mode: 0o700 }); + fs.writeFileSync( + legacyFile, + JSON.stringify( + { + NVIDIA_API_KEY: migratedCredentialValue, + OPENSHELL_GATEWAY: "evil-gw-from-tampered-file", + NODE_OPTIONS: "--require=/tmp/evil.js", + }, + null, + 2, + ), + { mode: 0o600 }, + ); + + const onboard = await host.command("node", [CLI_ENTRYPOINT, "onboard", "--non-interactive"], { + artifactName: "onboard-from-legacy-credentials", + env: testEnv(home, { + NEMOCLAW_SANDBOX_NAME: SANDBOX_NAME, + NEMOCLAW_RECREATE_SANDBOX: "1", + // Keep the default NVIDIA provider/key/endpoint/policy path while + // avoiding the high-quota default Nemotron validation model. + NEMOCLAW_MODEL: CREDENTIAL_MIGRATION_MODEL, + }), + redactionValues: [migratedCredentialValue], + timeoutMs: ONBOARD_TIMEOUT_MS, + }); + const onboardText = resultText(onboard); + expect(onboard.exitCode, onboardText).toBe(0); + expect(onboardText).toContain( + "Staged 1 legacy credential(s) for migration to the OpenShell gateway.", + ); + expect(fs.existsSync(legacyFile), "legacy credentials.json must be removed after onboard").toBe( + false, + ); + + const providers = await host.command( + "openshell", + ["-g", "nemoclaw", "provider", "list", "--names"], + { + artifactName: "gateway-provider-list", + env: testEnv(home), + timeoutMs: 60_000, + }, + ); + const providersText = resultText(providers); + expect(providers.exitCode, providersText).toBe(0); + const providerNames = providers.stdout + .split(/\r?\n/) + .map((line) => line.trim()) + .filter((line) => /^[a-zA-Z][a-zA-Z0-9_-]*$/.test(line)); + expect(providerNames, `expected migrated NVIDIA provider\n${providersText}`).toContain( + "nvidia-prod", + ); + expect(providerNames).not.toContain("OPENSHELL_GATEWAY"); + expect(providerNames).not.toContain("NODE_OPTIONS"); + + const credentialsList = await host.command("node", [CLI_ENTRYPOINT, "credentials", "list"], { + artifactName: "nemoclaw-credentials-list", + env: testEnv(home), + redactionValues: [migratedCredentialValue], + timeoutMs: 60_000, + }); + const credentialsText = resultText(credentialsList); + expect(credentialsList.exitCode, credentialsText).toBe(0); + expect(credentialsText).toContain("Providers registered with the OpenShell gateway"); + expect( + fs.existsSync(legacyFile), + "credentials list must not recreate plaintext credentials.json", + ).toBe(false); + + const victimFile = path.join(home, "victim.txt"); + const victimPayload = "important data the attacker should not touch"; + fs.writeFileSync(victimFile, victimPayload, { mode: 0o600 }); + fs.symlinkSync(victimFile, legacyFile); + + const unlink = await host.command( + "node", + [ + "-e", + `const { removeLegacyCredentialsFile } = require(${JSON.stringify(DIST_CREDENTIAL_STORE)}); removeLegacyCredentialsFile();`, + ], + { + artifactName: "remove-legacy-credentials-symlink", + env: testEnv(home), + timeoutMs: 30_000, + }, + ); + expect(unlink.exitCode, resultText(unlink)).toBe(0); + expect(fs.existsSync(legacyFile), "symlink at credentials path must be removed").toBe(false); + expect(fs.existsSync(victimFile), "symlink target must remain present").toBe(true); + expect(fs.readFileSync(victimFile, "utf-8")).toBe(victimPayload); + + await artifacts.writeJson("scenario-result.json", { + id: "credential-migration", + sandboxName: SANDBOX_NAME, + model: CREDENTIAL_MIGRATION_MODEL, + providerNames, + assertions: { + onboardSucceeded: onboard.exitCode === 0, + migrationNoticeEmitted: onboardText.includes( + "Staged 1 legacy credential(s) for migration to the OpenShell gateway.", + ), + legacyFileRemovedAfterOnboard: !fs.existsSync(legacyFile), + migratedNvidiaProviderRegistered: providerNames.includes("nvidia-prod"), + tamperedKeysExcluded: + !providerNames.includes("OPENSHELL_GATEWAY") && !providerNames.includes("NODE_OPTIONS"), + credentialsListReadsGateway: credentialsText.includes( + "Providers registered with the OpenShell gateway", + ), + symlinkTargetUntouched: + fs.existsSync(victimFile) && fs.readFileSync(victimFile, "utf-8") === victimPayload, + }, + }); + }, +); 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 2a1385c2e60..c150e0be03f 100644 --- a/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts +++ b/test/e2e-scenario/support-tests/e2e-scenarios-workflow.test.ts @@ -407,6 +407,8 @@ jobs: "onboard-negative-paths-vitest artifact upload must set include-hidden-files: false", "onboard-negative-paths-vitest artifact upload must ignore missing fixture artifacts", "onboard-negative-paths-vitest artifact upload retention-days must be 14", + "credential-migration-vitest job must depend on validate-jobs", + "credential-migration-vitest job must use the shared jobs selector condition", "network-policy-vitest checkout action must be pinned to a full commit SHA", "network-policy-vitest checkout step must set persist-credentials=false", "network-policy-vitest must not include unused Docker Hub authentication", @@ -429,6 +431,7 @@ jobs: "network-policy-vitest artifact upload must set include-hidden-files: false", "network-policy-vitest artifact upload must ignore missing fixture artifacts", "network-policy-vitest artifact upload retention-days must be 14", + "report-to-pr job must wait for credential-migration-vitest", "report-to-pr job must wait for network-policy-vitest", "workflow missing hermes-e2e-vitest job", "report-to-pr job must wait for hermes-e2e-vitest", diff --git a/test/e2e-script-workflow.test.ts b/test/e2e-script-workflow.test.ts index 020c39e9f38..eb24a4eb9a9 100644 --- a/test/e2e-script-workflow.test.ts +++ b/test/e2e-script-workflow.test.ts @@ -98,7 +98,6 @@ const NIGHTLY_E2E_SCRIPT_ALLOWLIST = [ "test/e2e/test-cloud-onboard-e2e.sh", "test/e2e/test-common-egress-agent-e2e.sh", "test/e2e/test-concurrent-gateway-ports.sh", - "test/e2e/test-credential-migration.sh", "test/e2e/test-credential-sanitization.sh", "test/e2e/test-cron-preflight-inference-local-e2e.sh", "test/e2e/test-device-auth-health.sh", @@ -368,6 +367,48 @@ describe("E2E reusable workflow contract", () => { expect(uploadStep?.with?.["retention-days"]).toBe(14); }); + it("runs credential migration on the former shell runner through Vitest artifacts", () => { + const job = nightlyWorkflow.jobs["credential-migration-e2e"]; + const checkoutStep = job.steps?.find((step) => + String(step.uses ?? "").startsWith("actions/checkout@"), + ); + const authStep = job.steps?.find((step) => step.name === "Authenticate to Docker Hub"); + const installStep = job.steps?.find((step) => step.name === "Install root dependencies"); + const buildStep = job.steps?.find((step) => step.name === "Build CLI"); + const setupNodeStep = job.steps?.find((step) => + String(step.uses ?? "").startsWith("actions/setup-node@"), + ); + const runStep = job.steps?.find((step) => step.name === "Run credential migration Vitest test"); + const uploadStep = job.steps?.find( + (step) => step.name === "Upload credential migration artifacts", + ); + + expect(job["runs-on"]).toBe("ubuntu-latest"); + expect(job["timeout-minutes"]).toBe(50); + expect(checkoutStep?.with?.ref).toBe("${{ inputs.target_ref || github.ref }}"); + expect(checkoutStep?.with?.["persist-credentials"]).toBe(false); + expect(authStep).toBeDefined(); + expect(setupNodeStep?.uses).toMatch(/^actions\/setup-node@[0-9a-f]{40}$/); + expect(setupNodeStep?.with?.cache).toBe("npm"); + expect(installStep?.run).toBe("npm ci --ignore-scripts"); + expect(buildStep?.run).toBe("npm run build:cli"); + expect(runStep?.run).toContain("npx vitest run --project e2e-scenarios-live"); + expect(runStep?.run).toContain("test/e2e-scenario/live/credential-migration.test.ts"); + expect(runStep?.run).not.toContain("test/e2e/test-credential-migration.sh"); + expect(runStep?.env?.NVIDIA_API_KEY).toBe("${{ secrets.NVIDIA_API_KEY }}"); + expect(runStep?.env?.GITHUB_TOKEN).toBeUndefined(); + expect(runStep?.env?.NEMOCLAW_RUN_E2E_SCENARIOS).toBe("1"); + expect(runStep?.env?.NEMOCLAW_SANDBOX_NAME).toBe("e2e-cred-migration"); + expect(runStep?.env?.E2E_ARTIFACT_DIR).toBe( + "${{ github.workspace }}/e2e-artifacts/vitest/credential-migration", + ); + expect(uploadStep?.if).toBe("always()"); + expect(uploadStep?.with?.path).toBe("e2e-artifacts/vitest/credential-migration/"); + expect(uploadStep?.with?.["include-hidden-files"]).toBe(false); + expect(uploadStep?.with?.["if-no-files-found"]).toBe("ignore"); + expect(uploadStep?.with?.["retention-days"]).toBe(14); + }); + it("authenticates Docker Hub pulls in direct nightly E2E jobs", () => { const directE2eJobs = [ "openclaw-tui-chat-correlation-e2e", @@ -376,6 +417,7 @@ describe("E2E reusable workflow contract", () => { "bedrock-runtime-compatible-anthropic-e2e", "token-rotation-e2e", "sandbox-operations-e2e", + "credential-migration-e2e", "openshell-gateway-upgrade-e2e", "double-onboard-e2e", "onboard-repair-e2e", diff --git a/test/helpers/e2e-workflow-contract.ts b/test/helpers/e2e-workflow-contract.ts index b76db7ce131..f8ff5460850 100644 --- a/test/helpers/e2e-workflow-contract.ts +++ b/test/helpers/e2e-workflow-contract.ts @@ -9,6 +9,8 @@ import YAML from "yaml"; const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", ".."); export type WorkflowJob = { + "runs-on"?: string; + "timeout-minutes"?: number; uses?: string; secrets?: Record; steps?: WorkflowStep[]; diff --git a/tools/e2e-scenarios/workflow-boundary.mts b/tools/e2e-scenarios/workflow-boundary.mts index 48f4e3dc85b..d9e45fff7b6 100644 --- a/tools/e2e-scenarios/workflow-boundary.mts +++ b/tools/e2e-scenarios/workflow-boundary.mts @@ -28,6 +28,7 @@ const FREE_STANDING_SCENARIO_JOBS = new Map([ ]); const ALLOWED_FREE_STANDING_JOBS = new Set([ ...FREE_STANDING_SCENARIO_JOBS.values(), + "credential-migration-vitest", "gateway-guard-recovery", ]); @@ -274,6 +275,7 @@ function validateJobsSelector(errors: string[], jobs: WorkflowRecord): void { requireRunContains(errors, validate, "allowed_jobs="); requireRunContains(errors, validate, "openshell-version-pin-vitest"); requireRunContains(errors, validate, "onboard-negative-paths-vitest"); + requireRunContains(errors, validate, "credential-migration-vitest"); requireRunContains(errors, validate, "hermes-e2e-vitest"); requireRunContains(errors, validate, "network-policy-vitest"); requireRunContains(errors, validate, "token-rotation-vitest"); @@ -1015,6 +1017,7 @@ export function validateE2eVitestScenariosWorkflowBoundary( validateOpenShellVersionPinVitestJob(errors, jobs); validateOnboardNegativePathsVitestJob(errors, jobs); + validateFreeStandingJobSelector(errors, jobs, "credential-migration-vitest"); validateHermesE2EVitestJob(errors, jobs); validateNetworkPolicyVitestJob(errors, jobs); validateTokenRotationVitestJob(errors, jobs); @@ -1037,6 +1040,7 @@ export function validateE2eVitestScenariosWorkflowBoundary( "live-scenarios", "openshell-version-pin-vitest", "onboard-negative-paths-vitest", + "credential-migration-vitest", "hermes-e2e-vitest", "network-policy-vitest", "token-rotation-vitest",