Skip to content

Commit

Permalink
Handle missing last success run and match logs by job name.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 26, 2024
1 parent bfe6551 commit 088b3a6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/sample/genaisrc/gai.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const lsi = lsid
? runs.findIndex(({ id }) => id === lsid)
: runs.findIndex(({ conclusion }) => conclusion === "success")
const ls = runs[lsi]
if (!ls) cancel("last success run not found")
console.log(
`> last success: ${ls.id}, ${ls.created_at}, ${ls.head_sha}, ${ls.html_url}`
)
Expand All @@ -42,19 +43,20 @@ const gitDiff = await host.exec(
console.log(`> source diff: ${(gitDiff.stdout.length / 1000) | 0}kb`)

// download logs
const lsjobs = await downlo adRunLog(ls.id)
const lsjob = lsjobs[0]
const lslog = lsjob.text
console.log(
`> last success log: ${(lslog.length / 1000) | 0}kb ${lsjob.logUrl}`
)
const ffjobs = await downloadRunLog(ff.id)
const ffjob = ffjobs[0]
const ffjob = ffjobs.find(({ conclusion }) => conclusion === "failure")
const fflog = ffjob.text
console.log(
`> first failure log: ${(fflog.length / 1000) | 0}kb ${ffjob.logUrl}`
)

const lsjobs = await downloadRunLog(ls.id)
const lsjob = lsjobs.find(({ name }) => ffjob.name === name)
const lslog = lsjob.text
console.log(
`> last success log: ${(lslog.length / 1000) | 0}kb ${lsjob.logUrl}`
)

const logDiff = diffJobLogs(lslog, fflog)
console.log(`> log diff: ${(logDiff.length / 1000) | 0}kb`)

Expand Down

0 comments on commit 088b3a6

Please sign in to comment.