Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding build failure investigator script #7412

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore.genai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/genaiscript.d.ts
**/package-lock.json
**/yarn.lock
17 changes: 17 additions & 0 deletions genaisrc/gai.genai.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
script({
tools: ["agent_fs", "agent_git", "agent_github"],
})

const {
workflow = "latest failed",
failure_run_id = "latest",
branch = await git.defaultBranch(),
} = env.vars

$`Investigate the status of the ${workflow} workflow and identify the root cause of the failure of run ${failure_run_id} in branch ${branch}.

- Correlate the failure with the relevant commits, pull requests or issues.
- Compare the source code between the failed run commit and the last successful run commit before that run.

In your report, include html links to the relevant runs, commits, pull requests or issues.
`
30 changes: 9 additions & 21 deletions genaisrc/gcm.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,16 @@ script({
description: "Generate a commit message for all staged changes",
})

// TODO: update this diff command to match your workspace
const diffCmd = "git diff --cached -- . :!**/genaiscript.d.ts"

// Check for staged changes and stage all changes if none are staged
let diff = await host.exec(diffCmd)
if (!diff.stdout) {
/**
* Ask user to stage all changes if none are staged
*/
const stage = await host.confirm("No staged changes. Stage all changes?", {
default: true,
})
if (stage) {
// Stage all changes and recompute diff
await host.exec("git add .")
diff = await host.exec(diffCmd)
}
if (!diff.stdout) cancel("no staged changes")
}
const diff = await git.diff({
staged: true,
excludedPaths: "**/genaiscript.d.ts",
askStageOnEmpty: true,
})
if (!diff) cancel("no staged changes")

// show diff in the console
console.log(diff.stdout)
console.log(diff)

let choice
let message
Expand Down Expand Up @@ -79,9 +67,9 @@ Please generate a concise, one-line commit message for these changes.
}
// Regenerate message
if (choice === "commit" && message) {
console.log((await host.exec("git", ["commit", "-m", message])).stdout)
console.log(await git.exec(["commit", "-m", message]))
if (await host.confirm("Push changes?", { default: true }))
console.log((await host.exec("git push")).stdout)
console.log(await git.exec("push"))
break
}
} while (choice !== "commit")
Loading