Skip to content

Commit 35ed43d

Browse files
sync from touchless-bot infra/bot-ci@88ae573887b2
1 parent 9d74b0a commit 35ed43d

14 files changed

Lines changed: 52 additions & 67 deletions

‎.synced-from‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e8261f8856460a1953ef16162fa33422fcf26de9
1+
88ae573887b21f17713c6b72c9a6dc77dab1d90a

‎actions/second-look/action.yml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ inputs:
4545
required: false
4646
openai-model:
4747
required: false
48-
mode:
49-
description: "advisory (default): the check is never red; enforce: a block or a failed review turns it red"
50-
required: false
5148
budget-usd:
5249
description: "the Claude reviewer's spend cap per run (default 3)"
5350
required: false
@@ -177,7 +174,6 @@ runs:
177174
SECOND_LOOK_OPENAI_API_KEY: ${{ inputs.openai-api-key }}
178175
SECOND_LOOK_ANTHROPIC_MODEL: ${{ inputs.anthropic-model }}
179176
SECOND_LOOK_OPENAI_MODEL: ${{ inputs.openai-model }}
180-
SECOND_LOOK_MODE: ${{ inputs.mode }}
181177
SECOND_LOOK_BUDGET_USD: ${{ inputs.budget-usd }}
182178
SECOND_LOOK_REPORTS_DIRECTORY: ${{ runner.temp }}/second-look-reports
183179
SECOND_LOOK_DEFAULT_RULES: ${{ github.action_path }}/rules.md

‎actions/second-look/approveHintOf.ts‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎actions/second-look/checkRun.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
/**
33
* second look's check on the pr, in a dispatched run: `start` opens it on the head while the
4-
* review runs, `abandon` closes it when the run ended without a review, unless something already did (the relay's
5-
* forced approval turns it green and cancels the run). synthesize.ts closes it
4+
* review runs, `abandon` closes it when the run ended without a review, unless something already closed it.
5+
* synthesize.ts closes it
66
* with the verdict. best effort: without the app's checks permission there's just no check,
77
* and the review comment still posts.
88
*
@@ -30,7 +30,7 @@ const main = async () => {
3030
const id = process.env.SECOND_LOOK_CHECK_RUN_ID
3131
if (!id) return console.log("second look: no check to close")
3232
const current = await fetch(`https://api.github.com/repos/${repository}/check-runs/${id}`, { headers: { authorization: `Bearer ${token}`, accept: "application/vnd.github+json" } })
33-
if (current.ok && ((await current.json()) as { status?: string }).status === "completed") return console.log("second look: the check is already closed (a forced approval?), leaving it")
33+
if (current.ok && ((await current.json()) as { status?: string }).status === "completed") return console.log("second look: the check is already closed, leaving it")
3434
await sendCheckRun({ token, repository, id, body: checkAbandonedOf({ result: process.env.SECOND_LOOK_RESULT || "failure", detailsUrl }) })
3535
return console.log(`second look: closed the check on ${repository} (${id})`)
3636
}

‎actions/second-look/checkRunBodyOf.ts‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Verdict } from "./types.ts"
22

3-
/** the check second look puts on a pr it was asked to review, named like the old required check */
3+
/** the check second look puts on a pr it reviews, named like the old required check */
44
export const checkName = "Second Look (beta)"
55

66
/** the body that opens the check on the pr's head while the review runs */
@@ -16,14 +16,16 @@ export const checkStartOf = ({ headSha, detailsUrl, requestedBy }: { headSha: st
1616
})
1717

1818
/**
19-
* the body that closes the check with the review's outcome: a pass is green and anything else
20-
* neutral, unless enforcing, where a block (the review requests changes either way) or a failed review is red
19+
* the body that closes the check with the review's outcome. outside the beta scope the check is informational: a pass
20+
* is green ("no changes requested", never an approval) and anything else neutral, never red. on a beta-enabled pr it
21+
* enforces: a pass is an approval, and a block (the review requests changes either way) or a failed review is red
2122
*/
22-
export const checkEndOf = ({ verdict, error, enforcing, commentUrl }: { verdict?: Verdict; error?: string; enforcing: boolean; commentUrl?: string }) => {
23+
export const checkEndOf = ({ verdict, error, betaEnabled, commentUrl }: { verdict?: Verdict; error?: string; betaEnabled: boolean; commentUrl?: string }) => {
2324
const link = commentUrl ? `\n\n[The review](${commentUrl})` : ""
24-
if (error || !verdict) return { status: "completed", conclusion: enforcing ? "failure" : "neutral", output: { title: "Couldn't review", summary: `${error ?? "no verdict"}${link}` } }
25-
if (verdict.verdict === "pass") return { status: "completed", conclusion: "success", output: { title: "Approved", summary: `${verdict.summary}${link}` } }
26-
return { status: "completed", conclusion: enforcing ? "failure" : "neutral", output: { title: "Changes requested", summary: `${verdict.summary}${link}` } }
25+
const notPassing = betaEnabled ? "failure" : "neutral"
26+
if (error || !verdict) return { status: "completed", conclusion: notPassing, output: { title: "Couldn't review", summary: `${error ?? "no verdict"}${link}` } }
27+
if (verdict.verdict === "pass") return { status: "completed", conclusion: "success", output: { title: betaEnabled ? "Approved" : "No changes requested", summary: `${verdict.summary}${link}` } }
28+
return { status: "completed", conclusion: notPassing, output: { title: "Changes requested", summary: `${verdict.summary}${link}` } }
2729
}
2830

2931
/** the body that closes a check whose run didn't get to a review (cancelled by a newer request, or a job failed) */

‎actions/second-look/commentBodyOf.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ const reportSectionOf = (report: AgentReport) => {
7272
* the sticky comment, kept short: the call, the reviewer's summary, each new finding in a line (linking the ones
7373
* on the diff, in the review at `reviewUrl`) and links to the earlier threads (`followUps`) that are fixed or still
7474
* open. the ticket fit and testing, each tester's steps and the intended architecture sit collapsed below.
75-
* `error` replaces the summary when the main reviewer didn't answer.
75+
* `error` replaces the summary when the main reviewer didn't answer. `betaEnabled` is whether a pass is an approval
7676
*/
77-
export const commentBodyOf = ({ verdict, error, reports, reviewer, reviewerModel, harness, headSha, scopeReason, onDiff = new Set(), reviewUrl, followUps = [] }: {
77+
export const commentBodyOf = ({ verdict, error, reports, reviewer, reviewerModel, harness, headSha, scopeReason, onDiff = new Set(), reviewUrl, followUps = [], betaEnabled = false }: {
7878
verdict?: Verdict
7979
error?: string
8080
reports: AgentReport[]
@@ -86,12 +86,13 @@ export const commentBodyOf = ({ verdict, error, reports, reviewer, reviewerModel
8686
onDiff?: ReadonlySet<Finding>
8787
reviewUrl?: string
8888
followUps?: ThreadOutcome[]
89+
betaEnabled?: boolean
8990
}) => {
9091
const cost = reports.reduce((total, report) => total + (report.costUsd ?? 0), 0)
9192
const linked = threadKeysLinkedOf(followUps.map(({ thread }) => thread))
9293
const lines = [
9394
commentMarker,
94-
headlineOf({ verdict, open: followUps.filter(({ status }) => status !== "fixed").length }),
95+
headlineOf({ verdict, open: followUps.filter(({ status }) => status !== "fixed").length, betaEnabled }),
9596
"",
9697
verdict ? linked(verdict.summary) : `The main reviewer didn't answer: ${error ?? "unknown error"}. The testers' reports are below.`,
9798
...(verdict?.findings.length ? ["", ...verdict.findings.map(findingLineOf(onDiff, linked, reviewUrl))] : []),

‎actions/second-look/headlineOf.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ const countOf = (count: number, noun: string) => (count ? [`${count} ${noun}${co
55

66
/**
77
* the first line of the review and the summary comment: the call, then what's behind it, like
8-
* "**Second Look (beta): changes requested** · 2 warnings, 1 nit, 3 still open". `open` is earlier threads not fixed yet
8+
* "**Second Look (beta): changes requested** · 2 warnings, 1 nit, 3 still open". `open` is earlier threads not fixed yet.
9+
* a pass reads "approved" only on a beta-enabled pr, where it is one; elsewhere it's "no changes requested"
910
*/
10-
export const headlineOf = ({ verdict, open = 0 }: { verdict?: Verdict; open?: number }) => {
11-
const call = !verdict ? "couldn't finish" : verdict.verdict === "pass" ? "approved" : "changes requested"
11+
export const headlineOf = ({ verdict, open = 0, betaEnabled = false }: { verdict?: Verdict; open?: number; betaEnabled?: boolean }) => {
12+
const call = !verdict ? "couldn't finish" : verdict.verdict === "block" ? "changes requested" : betaEnabled ? "approved" : "no changes requested"
1213
const findings = verdict?.findings ?? []
1314
const counts = [
1415
...countOf(findings.filter(({ severity }) => severity === "warning").length, "warning"),

‎actions/second-look/isEnforcing.ts‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎actions/second-look/notifyUnfinished.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
/**
33
* second look's wrap-up when a run ended without a review (and wasn't cancelled): the relay already
44
* told the pr a review is coming, so this says it isn't, with a link to the run, as a comment review
5-
* that tags the author with the force-approval hint (a plain pr comment when a review can't be posted). best effort.
5+
* (a plain pr comment when a review can't be posted). best effort.
66
*
77
* node notifyUnfinished.ts
88
*
99
* env: SECOND_LOOK_POST_TOKEN (clanker-in-chief's PAT) or GITHUB_TOKEN (the app, issues + pull requests write),
1010
* SECOND_LOOK_REPOSITORY (validated by prepare), SECOND_LOOK_NUMBER, SECOND_LOOK_RESULT, SECOND_LOOK_STAGE,
1111
* GITHUB_SERVER_URL, GITHUB_REPOSITORY, GITHUB_RUN_ID.
1212
*/
13-
import { approveHintOf } from "./approveHintOf.ts"
1413
import { unfinishedReplyOf } from "./unfinishedReplyOf.ts"
1514

1615
const main = async () => {
@@ -25,9 +24,7 @@ const main = async () => {
2524
...(body === undefined ? {} : { body: JSON.stringify(body) }),
2625
})
2726
const detailsUrl = `${process.env.GITHUB_SERVER_URL || "https://github.com"}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
28-
const pull = await api(`pulls/${number}`)
29-
const author = pull.ok ? ((await pull.json()) as { user?: { login?: string } }).user?.login : undefined
30-
const body = `${unfinishedReplyOf({ result: process.env.SECOND_LOOK_RESULT || "failure", stage: process.env.SECOND_LOOK_STAGE || "review", detailsUrl })}\n\n${approveHintOf(author)}`
27+
const body = unfinishedReplyOf({ result: process.env.SECOND_LOOK_RESULT || "failure", stage: process.env.SECOND_LOOK_STAGE || "review", detailsUrl })
3128
const review = await api(`pulls/${number}/reviews`, { event: "COMMENT", body })
3229
if (review.ok) return console.log(`second look: told ${repository}#${number} the run didn't finish (comment review)`)
3330
const comment = await api(`issues/${number}/comments`, { body })

‎actions/second-look/postReview.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { InlineComment } from "./inlineCommentsOf.ts"
22
import type { ReviewEvent } from "./reviewEventOf.ts"
33

44
/**
5-
* submits one review on `commitId` as `event`, carrying the new inline comments; every run gets one, so the pr always
6-
* shows an approval, a change request or a comment from second look. github answers 422 when the poster can't approve
7-
* or request changes (its own pr), so that one goes in as a plain comment review instead. resolves to the review's url
5+
* submits one review on `commitId` as `event` (reviewEventOf.ts), carrying the new inline comments; every run gets one,
6+
* so the pr always shows a change request or a comment from second look (an approval only on a beta-enabled pr). github
7+
* answers 422 when the poster can't approve or request changes (its own pr), so that one goes in as a plain comment review instead. resolves to the review's url
88
* and the event it went in as
99
*/
1010
export const postReview = async ({ token, repository, number, commitId, event, comments, body, fetchImpl = fetch }: {

0 commit comments

Comments
 (0)