Skip to content

Commit

Permalink
Add display_title to GitHubWorkflowRun and refine logging and diff lo…
Browse files Browse the repository at this point in the history
…gic in script
  • Loading branch information
pelikhan committed Sep 27, 2024
1 parent 7306524 commit dbb4183
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/auto/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core/src/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/core/src/types/prompt_template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,7 @@ type GitHubWorkflowRunStatus =
interface GitHubWorkflowRun {
id: number
name?: string
display_title: string
status: string
conclusion: string
html_url: string
Expand Down
1 change: 1 addition & 0 deletions packages/sample/genaisrc/blog/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 9 additions & 17 deletions packages/sample/genaisrc/gai.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// Script for analyzing GitHub Action runs to determine the cause of a failure.
script({
title: "GitHub Action Investigator",
description: "Analyze GitHub Action runs to find the root cause of a failure",
description:
"Analyze GitHub Action runs to find the root cause of a failure",
parameters: {
workflow: { type: "string" }, // Workflow name
failure_run_id: { type: "number" }, // ID of the failed run
Expand Down Expand Up @@ -57,31 +58,27 @@ if (ffi < 0) ffi = 0
const ff = runs[ffi]

// Log details of the failed run
console.log(
` run: ${ff.id}, ${ff.conclusion}, ${ff.created_at}, ${ff.head_sha}, ${ff.html_url}`
)
console.log(` run: ${ff.display_title}, ${ff.html_url}`)

// Find the index of the last successful run before the failure
const runsAfterFailure = runs.slice(ffi)
const lsi = lsid
? runs.findIndex(({ id }) => id === lsid)
: runs.slice(ffi).findIndex(({ conclusion }) => conclusion === "success")
: runsAfterFailure.findIndex(({ conclusion }) => conclusion === "success")

const ls = runs[lsi]
const ls = runsAfterFailure[lsi]
if (ls) {
// Log details of the last successful run
console.log(
` last success: ${ls.id}, ${ls.conclusion}, ${ls.created_at}, ${ls.head_sha}, ${ls.html_url}`
)
console.log(` last success: ${ls.display_title}, ${ls.html_url}`)

// Execute git diff between the last success and failed run commits
const gitDiff = await host.exec(
`git diff ${ls.head_sha} ${ff.head_sha} -- . :!**/genaiscript.d.ts`
)
console.log(`> git diff: ${(gitDiff.stdout.length / 1000) | 0}kb`)
def("GIT_DIFF", gitDiff, {
language: "diff",
maxTokens: 10000,
lineNumbers: true,
maxTokens: 10000,
})
}

Expand All @@ -91,7 +88,6 @@ const ffjob =
ffjobs.find(({ conclusion }) => conclusion === "failure") ?? ffjobs[0]
const fflog = ffjob.content
if (!fflog) cancel("No logs found")
console.log(`> run log: ${(fflog.length / 1000) | 0}kb ${ffjob.logs_url}`)

if (!ls) {
// Define log content if no last successful run is available
Expand All @@ -103,14 +99,10 @@ if (!ls) {
console.log(`could not find job ${ffjob.name} in last success run`)
else {
const lslog = lsjob.content
console.log(
`> last success log: ${(lslog.length / 1000) | 0}kb ${lsjob.logs_url}`
)

// Generate a diff of logs between the last success and failed runs
defDiff("LOG_DIFF", lslog, fflog, {
maxTokens: 20000,
lineNumbers: false,
maxTokens: 20000,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/sample/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/genaisrc/node/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/genaisrc/python/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/genaisrc/style/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/src/aici/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/src/errors/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/src/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/src/makecode/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/src/tla/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/sample/src/vision/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/vscode/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions slides/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dbb4183

Please sign in to comment.