diff --git a/src/selftest/cases/20-runner-k8s-job.ts b/src/selftest/cases/20-runner-k8s-job.ts index 0e087eb..258c75b 100644 --- a/src/selftest/cases/20-runner-k8s-job.ts +++ b/src/selftest/cases/20-runner-k8s-job.ts @@ -6,12 +6,13 @@ import { MemoryAgentRunStore } from "../../mgr/store.js"; import { ManagerClient } from "../../mgr/client.js"; import { renderRunnerJobDryRun } from "../../runner/k8s-job.js"; import type { JsonRecord, RunRecord } from "../../common/types.js"; -import { assertNoSecretLeak, createRunWithCommand, type SelfTestCase } from "../harness.js"; +import { assertNoSecretLeak, createRunWithCommand, loadArtificerImageRef, type SelfTestCase } from "../harness.js"; const selfTest: SelfTestCase = async (context) => { const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore() }); try { const client = new ManagerClient(server.baseUrl); + const artificerImageRef = await loadArtificerImageRef(context.root); const githubToolCredentials = [{ tool: "github", purpose: "pull-request", @@ -188,7 +189,7 @@ process.exit(1); imageRef: { kind: "env-image-dockerfile", repoUrl: "git@github.com:pikasTech/agentrun.git", - commitId: "59272f8edb4e23d805b7b9da0050ec40cfc0233d", + commitId: artificerImageRef.commitId, dockerfilePath: "deploy/container/Containerfile", }, transientEnv: [ diff --git a/src/selftest/cases/75-queue-q2-dispatch.ts b/src/selftest/cases/75-queue-q2-dispatch.ts index 4767760..5143469 100644 --- a/src/selftest/cases/75-queue-q2-dispatch.ts +++ b/src/selftest/cases/75-queue-q2-dispatch.ts @@ -6,7 +6,7 @@ import { startManagerServer } from "../../mgr/server.js"; import { MemoryAgentRunStore } from "../../mgr/store.js"; import { ManagerClient } from "../../mgr/client.js"; import type { JsonRecord, QueueDispatchResult, QueueTaskRecord } from "../../common/types.js"; -import { assertNoSecretLeak, type SelfTestCase } from "../harness.js"; +import { assertNoSecretLeak, loadArtificerImageRef, type SelfTestCase } from "../harness.js"; const selfTest: SelfTestCase = async (context) => { const fakeKubectl = path.join(context.tmp, "fake-kubectl-queue-q2.js"); @@ -39,10 +39,11 @@ process.exit(1); `); await chmod(fakeKubectl, 0o755); const store = new MemoryAgentRunStore(); + const artificerImageRef = await loadArtificerImageRef(context.root); const aipodImageRef = { kind: "env-image-dockerfile", repoUrl: "git@github.com:pikasTech/agentrun.git", - commitId: "59272f8edb4e23d805b7b9da0050ec40cfc0233d", + commitId: artificerImageRef.commitId, dockerfilePath: "deploy/container/Containerfile", }; const server = await startManagerServer({ diff --git a/src/selftest/cases/76-aipod-spec.ts b/src/selftest/cases/76-aipod-spec.ts index 44cb35c..ebb8680 100644 --- a/src/selftest/cases/76-aipod-spec.ts +++ b/src/selftest/cases/76-aipod-spec.ts @@ -6,12 +6,13 @@ import { startManagerServer } from "../../mgr/server.js"; import { MemoryAgentRunStore } from "../../mgr/store.js"; import type { JsonRecord } from "../../common/types.js"; import { resolveGitBundleFetchSource } from "../../runner/resource-bundle.js"; -import { assertNoSecretLeak, type SelfTestCase } from "../harness.js"; +import { assertNoSecretLeak, loadArtificerImageRef, type SelfTestCase } from "../harness.js"; const selfTest: SelfTestCase = async (context) => { const server = await startManagerServer({ port: 0, host: "127.0.0.1", sourceCommit: "self-test", store: new MemoryAgentRunStore(), aipodSpecDir: path.join(context.root, "config", "aipods") }); try { const client = new ManagerClient(server.baseUrl); + const artificerImageRef = await loadArtificerImageRef(context.root); const parsedWithoutBunGlobal = await runNodeParserCompat(context); assert.equal(parsedWithoutBunGlobal.name, "Artificer"); assert.equal(parsedWithoutBunGlobal.hasBunGlobal, false); @@ -27,7 +28,7 @@ const selfTest: SelfTestCase = async (context) => { const shownImageRef = shownItem.imageRef as JsonRecord; assert.equal(shownImageRef.kind, "env-image-dockerfile"); assert.equal(shownImageRef.repoUrl, "git@github.com:pikasTech/agentrun.git"); - assert.equal(shownImageRef.commitId, "59272f8edb4e23d805b7b9da0050ec40cfc0233d"); + assert.equal(shownImageRef.commitId, artificerImageRef.commitId); assert.equal(shownImageRef.dockerfilePath, "deploy/container/Containerfile"); assert.equal(((shownItem.resourceBundleRef as JsonRecord).gitMirror as JsonRecord).enabled, false); diff --git a/src/selftest/cases/90-runner-image-tools.ts b/src/selftest/cases/90-runner-image-tools.ts index 8d10417..595aab5 100644 --- a/src/selftest/cases/90-runner-image-tools.ts +++ b/src/selftest/cases/90-runner-image-tools.ts @@ -6,6 +6,7 @@ import path from "node:path"; import type { SelfTestCase } from "../harness.js"; import { imageRefSourceIdentity, imageRefSourceSummary, isDigestPinnedImage, validateAipodImageRef } from "../../common/env-image-ref.js"; import { smokeBundledWorkReadyCapabilities, smokeImageWorkReadyCapabilities, staticWorkReadyCapabilitySummary } from "../../common/work-ready.js"; +import { loadArtificerImageRef } from "../harness.js"; const requiredRunnerPackages = Object.freeze(["ca-certificates", "curl", "git", "github-cli", "kubectl", "nodejs", "npm", "openssh-client", "ripgrep"]); const execFileAsync = promisify(execFile); @@ -54,7 +55,8 @@ const selfTest: SelfTestCase = async (context) => { assert.equal(((bundleSmoke.smoke as { ok?: unknown }).ok), true); assert.equal(bundleSmoke.valuesPrinted, false); assert.equal(JSON.stringify({ imageSmoke, bundleSmoke }).includes("GH_TOKEN"), false); - const imageRef = validateAipodImageRef({ kind: "env-image-dockerfile", repoUrl: "git@github.com:pikasTech/agentrun.git", commitId: "59272f8edb4e23d805b7b9da0050ec40cfc0233d", dockerfilePath: "deploy/container/Containerfile" }); + const artificerImageRef = await loadArtificerImageRef(context.root); + const imageRef = validateAipodImageRef({ kind: "env-image-dockerfile", repoUrl: "git@github.com:pikasTech/agentrun.git", commitId: artificerImageRef.commitId, dockerfilePath: "deploy/container/Containerfile" }); assert.equal(imageRefSourceIdentity(imageRef).length, 20); assert.equal((imageRefSourceSummary(imageRef).valuesPrinted), false); assert.equal(isDigestPinnedImage("127.0.0.1:5000/agentrun/agentrun-mgr@sha256:1111111111111111111111111111111111111111111111111111111111111111"), true); diff --git a/src/selftest/harness.ts b/src/selftest/harness.ts index 3b5c67c..e4fd235 100644 --- a/src/selftest/harness.ts +++ b/src/selftest/harness.ts @@ -1,10 +1,11 @@ -import { chmod, mkdtemp, mkdir, writeFile, rm } from "node:fs/promises"; +import { chmod, mkdtemp, mkdir, readFile, writeFile, rm } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import assert from "node:assert/strict"; import { ManagerClient } from "../mgr/client.js"; -import type { BackendProfile, JsonRecord } from "../common/types.js"; +import type { AipodImageRef, BackendProfile, JsonRecord } from "../common/types.js"; import { backendProfileSpec } from "../common/backend-profiles.js"; +import { parseAipodSpecYaml } from "../common/aipod-specs.js"; import { dsflashGoModelCatalogJson } from "../common/model-catalogs.js"; export interface SelfTestContext { @@ -133,6 +134,12 @@ export function profileSecretHome(context: Pick & return context.codexHome; } +export async function loadArtificerImageRef(root: string): Promise { + const text = await readFile(path.join(root, "config", "aipods", "artificer.yaml"), "utf8"); + const spec = parseAipodSpecYaml(text, "selftest-artificer-image-ref"); + return spec.spec.imageRef; +} + function defaultFakeCommand(): string { return process.versions.bun ? process.execPath : "npx"; }