Skip to content

Commit 79cc9c3

Browse files
committed
Omit publication error from successful verification
1 parent 32e3118 commit 79cc9c3

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

.github/scripts/run-agent-task/execute-native-agent-task.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ async function verifyPublishedPullRequest(publication, targetRepo, cwd) {
295295
if (response.code !== 0) return { valid: false, error: "Published pull request could not be resolved through GitHub.", stderr: response.stderr, stderr_truncated: response.stderr_truncated }
296296
try {
297297
const pullRequest = JSON.parse(response.stdout)
298-
return {
299-
valid: pullRequest?.html_url === record(publication).pull_request?.url
300-
&& string(pullRequest?.base?.repo?.full_name).toLowerCase() === targetRepo.toLowerCase(),
301-
error: "Published pull request did not resolve to the target repository.",
302-
}
298+
const valid = pullRequest?.html_url === record(publication).pull_request?.url
299+
&& string(pullRequest?.base?.repo?.full_name).toLowerCase() === targetRepo.toLowerCase()
300+
return valid
301+
? { valid: true }
302+
: { valid: false, error: "Published pull request did not resolve to the target repository." }
303303
} catch {
304304
return { valid: false, error: "GitHub pull-request validation did not return JSON." }
305305
}

tests/execute-native-agent-task-lifecycle.test.mjs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ async function run(mode = "success") {
1717
const targetRepo = mode === "canonical-casing" ? "automattic/build-with-wordpress" : "owner/repo"
1818
const publicationRepo = mode === "canonical-casing"
1919
? "Automattic/build-with-wordpress"
20-
: mode === "different-repo" ? "other/repo" : targetRepo
20+
: targetRepo
21+
const resolvedRepo = mode === "different-repo" ? "other/repo" : publicationRepo
2122
await mkdir(join(workspace, ".codebox"), { recursive: true })
2223
await writeFile(join(workspace, "README.md"), "OPENAI_API_KEY\nbefore\n")
2324

@@ -139,8 +140,8 @@ export async function publishRunnerWorkspace({ testHook }) {
139140
const gh = join(temp, "gh")
140141
await writeFile(gh, `#!/usr/bin/env node
141142
process.stdout.write(JSON.stringify({
142-
html_url: ${JSON.stringify(`https://github.com/${publicationRepo}/pull/1`)},
143-
base: { repo: { full_name: ${JSON.stringify(publicationRepo)} } },
143+
html_url: ${JSON.stringify(`https://github.com/${resolvedRepo}/pull/1`)},
144+
base: { repo: { full_name: ${JSON.stringify(resolvedRepo)} } },
144145
}))
145146
`)
146147
await chmod(gh, 0o755)
@@ -189,19 +190,23 @@ assert(!durablePatch.includes("OPENAI_API_KEY"), "durable patch artifacts redact
189190
assert.match(durablePatch, /\[REDACTED\]/)
190191
assert.match(success.order, /runtime\nvalidation\nverification\ndrift\npublish\n/)
191192
assert.equal(success.result.runtime_result.metadata.runner_workspace_publication.pull_request.url, "https://github.com/owner/repo/pull/1")
193+
assert.deepEqual(success.result.publication_verification, { valid: true })
192194
assert.equal(success.result.runtime_result.agent_runtime_diagnostics.prepared_paths.workspaces[0].target, "/workspace")
193195
assert.equal(success.result.runtime_result.agent_runtime_diagnostics.prepared_paths.workspaces[0].mode, "readwrite")
194196
assert.equal(success.result.runtime_result.agent_runtime_diagnostics.sandbox_workspace.mounts[0].target, "/workspace")
195197
assert.equal(success.result.runtime_result.agent_runtime_diagnostics.local_executor_root, "/workspace")
196198

197199
const canonicalCasing = await run("canonical-casing")
198200
assert.equal(canonicalCasing.code, 0, `${canonicalCasing.stderr}\n${JSON.stringify(canonicalCasing.result)}`)
199-
assert.equal(canonicalCasing.result.publication_verification.valid, true)
201+
assert.deepEqual(canonicalCasing.result.publication_verification, { valid: true })
200202

201203
const differentRepository = await run("different-repo")
202204
assert.equal(differentRepository.code, 1)
203-
assert.equal(differentRepository.result.publication_verification.valid, false)
204-
assert.match(differentRepository.result.failure.message, /valid canonical pull-request result/)
205+
assert.deepEqual(differentRepository.result.publication_verification, {
206+
valid: false,
207+
error: "Published pull request did not resolve to the target repository.",
208+
})
209+
assert.equal(differentRepository.result.failure.message, "Published pull request did not resolve to the target repository.")
205210

206211
const failedVerification = await run("verify-fail")
207212
assert.equal(failedVerification.code, 1)

0 commit comments

Comments
 (0)