Repository navigation
fix(e2e): remove stale PR catalog resolver #10693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
333254b
fix(e2e): remove stale PR catalog resolver
prekshivyas a54e36a
test(e2e): execute CLI catalog packaging guard
prekshivyas 0e2e3f4
fix(e2e): reject inherited catalog inputs
prekshivyas 1e84474
test(e2e): cover retired catalog staging
prekshivyas 27e7817
Merge branch 'main' into codex/fix-manual-pr-managed-image-catalog
prekshivyas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { execFileSync, spawnSync } from "node:child_process"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { CLI_ARTIFACT_PACKAGE_STEP } from "../../../tools/e2e/cli-artifact-workflow-boundary.mts"; | ||
| import { readWorkflow, type Workflow } from "../../helpers/e2e-workflow-contract"; | ||
|
|
||
| type CatalogInput = "absent" | "file" | "symlink"; | ||
|
|
||
| const CATALOG_INPUT_WRITERS = { | ||
| absent: () => undefined, | ||
| file: (catalog: string) => fs.writeFileSync(catalog, "{}\n"), | ||
| symlink: (catalog: string) => fs.symlinkSync("missing-catalog.json", catalog), | ||
| } satisfies Record<CatalogInput, (catalog: string) => void>; | ||
|
|
||
| function runCliArtifactPackaging(catalogInput: CatalogInput) { | ||
| const root = fs.mkdtempSync(path.join(os.tmpdir(), "cli-artifact-package-")); | ||
| const workspace = path.join(root, "workspace"); | ||
| const runnerTemp = path.join(root, "runner-temp"); | ||
| const toolDirectory = path.join(root, "tools"); | ||
| fs.mkdirSync(workspace); | ||
| fs.mkdirSync(runnerTemp); | ||
| fs.mkdirSync(toolDirectory); | ||
| const systemTar = execFileSync("which", ["tar"], { encoding: "utf8" }).trim(); | ||
| fs.writeFileSync( | ||
| path.join(toolDirectory, "tar"), | ||
| `#!/usr/bin/env bash | ||
| set -euo pipefail | ||
| args=() | ||
| for argument in "$@"; do | ||
| case "$argument" in | ||
| --sort=name|--mtime=@0|--owner=0|--group=0|--numeric-owner) ;; | ||
| *) args+=("$argument") ;; | ||
| esac | ||
| done | ||
| exec ${JSON.stringify(systemTar)} "\${args[@]}" | ||
| `, | ||
| { mode: 0o755 }, | ||
| ); | ||
| fs.writeFileSync(path.join(workspace, "package-lock.json"), '{"lockfileVersion":3}\n'); | ||
| execFileSync("git", ["init", "--quiet"], { cwd: workspace }); | ||
| execFileSync("git", ["add", "package-lock.json"], { cwd: workspace }); | ||
| execFileSync( | ||
| "git", | ||
| [ | ||
| "-c", | ||
| "commit.gpgsign=false", | ||
| "-c", | ||
| "user.name=NemoClaw Test", | ||
| "-c", | ||
| "user.email=test@localhost", | ||
| "commit", | ||
| "--quiet", | ||
| "-m", | ||
| "fixture", | ||
| ], | ||
| { cwd: workspace }, | ||
| ); | ||
| const candidateSha = execFileSync("git", ["rev-parse", "HEAD"], { | ||
| cwd: workspace, | ||
| encoding: "utf8", | ||
| }).trim(); | ||
|
|
||
| const dist = path.join(workspace, "dist"); | ||
| const shared = path.join(workspace, "nemoclaw", "dist", "shared"); | ||
| fs.mkdirSync(dist); | ||
| fs.mkdirSync(shared, { recursive: true }); | ||
| fs.writeFileSync(path.join(dist, "nemoclaw.js"), 'console.log("fixture");\n'); | ||
| fs.writeFileSync( | ||
| path.join(dist, "build-identity.json"), | ||
| `${JSON.stringify({ nemoclawVersion: "0.0.0", sourceRevision: candidateSha })}\n`, | ||
| ); | ||
| for (const boundary of [ | ||
| "openshell-policy-boundary.cjs", | ||
| "sandbox-name.cjs", | ||
| "snapshot-sanitizer-boundary.cjs", | ||
| ]) { | ||
| fs.writeFileSync(path.join(shared, boundary), "module.exports = {};\n"); | ||
| } | ||
|
|
||
| const catalog = path.join(dist, "e2e-managed-image-catalog.json"); | ||
| CATALOG_INPUT_WRITERS[catalogInput](catalog); | ||
|
|
||
| const workflow = readWorkflow() as Workflow; | ||
| const packageStep = workflow.jobs["generate-matrix"]?.steps?.find( | ||
| (step) => step.name === CLI_ARTIFACT_PACKAGE_STEP, | ||
| ); | ||
| expect(packageStep?.run).toEqual(expect.any(String)); | ||
| const result = spawnSync("bash", ["-c", packageStep!.run!], { | ||
| cwd: workspace, | ||
| encoding: "utf8", | ||
| env: { | ||
| ...process.env, | ||
| CANDIDATE_REPOSITORY: "NVIDIA/NemoClaw", | ||
| CANDIDATE_SHA: candidateSha, | ||
| GITHUB_OUTPUT: path.join(root, "github-output"), | ||
| PATH: `${toolDirectory}:${process.env.PATH ?? ""}`, | ||
| RUN_ATTEMPT: "1", | ||
| RUN_ID: "12345", | ||
| RUNNER_ARCH: "X64", | ||
| RUNNER_OS: "Linux", | ||
| RUNNER_TEMP: runnerTemp, | ||
| WORKFLOW_SHA: "d".repeat(40), | ||
| }, | ||
| }); | ||
| return { | ||
| artifactExists: fs.existsSync(path.join(runnerTemp, "nemoclaw-cli-artifact")), | ||
| cleanup: () => fs.rmSync(root, { force: true, recursive: true }), | ||
| output: `${result.stdout}${result.stderr}`, | ||
| result, | ||
| }; | ||
| } | ||
|
|
||
| describe("CLI artifact packaging", () => { | ||
| it("packages the candidate CLI when no managed-image catalog exists", () => { | ||
| const fixture = runCliArtifactPackaging("absent"); | ||
| try { | ||
| expect(fixture.result.status, fixture.output).toBe(0); | ||
| expect(fixture.artifactExists).toBe(true); | ||
| } finally { | ||
| fixture.cleanup(); | ||
| } | ||
| }); | ||
|
|
||
| it.each(["file", "symlink"] as const)( | ||
| "rejects a candidate-created managed-image catalog %s before artifact creation", | ||
| (catalogInput) => { | ||
| const fixture = runCliArtifactPackaging(catalogInput); | ||
| try { | ||
| expect(fixture.result.status, fixture.output).not.toBe(0); | ||
| expect(fixture.output).toContain("candidate build created the managed-image catalog path"); | ||
| expect(fixture.artifactExists).toBe(false); | ||
| } finally { | ||
| fixture.cleanup(); | ||
| } | ||
| }, | ||
| ); | ||
| }); |
37 changes: 37 additions & 0 deletions
37
test/e2e/support/pr-managed-image-workflow-boundary.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { | ||
| readE2eOperationsWorkflow, | ||
| validateE2eOperationsWorkflow, | ||
| } from "../../../tools/e2e/operations-workflow-boundary.mts"; | ||
|
|
||
| describe("manual PR managed-image workflow boundary", () => { | ||
| it("rejects restoration of the obsolete manual PR catalog resolver", () => { | ||
| const workflow = readE2eOperationsWorkflow(); | ||
| const matrixJob = workflow.jobs["generate-matrix"]; | ||
| matrixJob.outputs!.managed_image_catalog = | ||
| "${{ steps.resolve_pr_managed_image_catalog.outputs.catalog }}"; | ||
| const checkoutIndex = matrixJob.steps!.findIndex( | ||
| (step) => step.name === "Check out E2E candidate", | ||
| ); | ||
| matrixJob.steps!.splice(checkoutIndex, 0, { | ||
| id: "resolve_pr_managed_image_catalog", | ||
| name: "Resolve exact PR managed-image catalog", | ||
| shell: "bash", | ||
| run: "node tools/e2e/pr-managed-image-publication.mts catalog.json", | ||
| }); | ||
| const packageStep = matrixJob.steps!.find((step) => step.name === "Package exact-commit CLI")!; | ||
| packageStep.env!.MANAGED_IMAGE_CATALOG = | ||
| "${{ steps.resolve_pr_managed_image_catalog.outputs.catalog }}"; | ||
|
|
||
| expect(validateE2eOperationsWorkflow(workflow)).toEqual( | ||
| expect.arrayContaining([ | ||
| "Manual PR E2E must not resolve an exact candidate managed-image catalog", | ||
| "Manual PR CLI packaging must not accept obsolete managed-image catalog authority", | ||
| ]), | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.