-
Notifications
You must be signed in to change notification settings - Fork 563
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
publish ai summaries #1864
Merged
Merged
publish ai summaries #1864
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66376e1
publish ai summaries
motatoes 6001a9d
tidy
motatoes 2553102
mod tidy
motatoes d76db70
change method name
motatoes e9e2c78
summarise
motatoes af9d4eb
add heading
motatoes 69b2db3
improve summary error reporting
motatoes c08f33c
improved error handling
motatoes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -511,7 +511,18 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR | |
log.Printf("strconv.ParseInt error: %v", err) | ||
commentReporterManager.UpdateComment(fmt.Sprintf(":x: could not handle commentId: %v", err)) | ||
} | ||
batchId, _, err := utils.ConvertJobsToDiggerJobs(*diggerCommand, models.DiggerVCSGithub, organisationId, impactedJobsMap, impactedProjectsMap, projectsGraph, installationId, branch, prNumber, repoOwner, repoName, repoFullName, commitSha, commentId, diggerYmlStr, 0) | ||
|
||
var aiSummaryCommentId = "" | ||
if config.Reporting.AiSummary { | ||
aiSummaryComment, err := ghService.PublishComment(prNumber, "AI Summary will be posted here after completion") | ||
if err != nil { | ||
log.Printf("could not post ai summary comment: %v", err) | ||
commentReporterManager.UpdateComment(fmt.Sprintf(":x: could not post ai comment summary comment id: %v", err)) | ||
} | ||
aiSummaryCommentId = aiSummaryComment.Id | ||
} | ||
|
||
batchId, _, err := utils.ConvertJobsToDiggerJobs(*diggerCommand, models.DiggerVCSGithub, organisationId, impactedJobsMap, impactedProjectsMap, projectsGraph, installationId, branch, prNumber, repoOwner, repoName, repoFullName, commitSha, commentId, diggerYmlStr, 0, aiSummaryCommentId, config.ReportTerraformOutputs) | ||
if err != nil { | ||
log.Printf("ConvertJobsToDiggerJobs error: %v", err) | ||
commentReporterManager.UpdateComment(fmt.Sprintf(":x: ConvertJobsToDiggerJobs error: %v", err)) | ||
|
@@ -768,7 +779,10 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu | |
// terraform code generator | ||
if os.Getenv("DIGGER_GENERATION_ENABLED") == "1" { | ||
err = GenerateTerraformFromCode(payload, commentReporterManager, config, defaultBranch, ghService, repoOwner, repoName, commitSha, issueNumber, branch) | ||
return err | ||
if err != nil { | ||
log.Printf("terraform generation failed: %v", err) | ||
return err | ||
} | ||
} | ||
|
||
commentIdStr := strconv.FormatInt(userCommentId, 10) | ||
|
@@ -902,7 +916,17 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu | |
return fmt.Errorf("comment reporter error: %v", err) | ||
} | ||
|
||
batchId, _, err := utils.ConvertJobsToDiggerJobs(*diggerCommand, "github", orgId, impactedProjectsJobMap, impactedProjectsMap, projectsGraph, installationId, *branch, issueNumber, repoOwner, repoName, repoFullName, *commitSha, reporterCommentId, diggerYmlStr, 0) | ||
var aiSummaryCommentId = "" | ||
if config.Reporting.AiSummary { | ||
aiSummaryComment, err := ghService.PublishComment(issueNumber, "AI Summary will be posted here after completion") | ||
if err != nil { | ||
log.Printf("could not post ai summary comment: %v", err) | ||
commentReporterManager.UpdateComment(fmt.Sprintf(":x: could not post ai comment summary comment id: %v", err)) | ||
} | ||
aiSummaryCommentId = aiSummaryComment.Id | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check for nil after failing to publish the AI summary comment. Similarly to the earlier comment, if Proposed fix: var aiSummaryCommentId = ""
if config.Reporting.AiSummary {
aiSummaryComment, err := ghService.PublishComment(issueNumber, "AI Summary will be posted here after completion")
if err != nil {
log.Printf("could not post ai summary comment: %v", err)
commentReporterManager.UpdateComment(fmt.Sprintf(":x: could not post ai comment summary comment id: %v", err))
+ return
}
aiSummaryCommentId = aiSummaryComment.Id
}
|
||
batchId, _, err := utils.ConvertJobsToDiggerJobs(*diggerCommand, "github", orgId, impactedProjectsJobMap, impactedProjectsMap, projectsGraph, installationId, *branch, issueNumber, repoOwner, repoName, repoFullName, *commitSha, reporterCommentId, diggerYmlStr, 0, aiSummaryCommentId, config.ReportTerraformOutputs) | ||
if err != nil { | ||
log.Printf("ConvertJobsToDiggerJobs error: %v", err) | ||
commentReporterManager.UpdateComment(fmt.Sprintf(":x: ConvertJobsToDiggerJobs error: %v", err)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Modify "digger_batches" table | ||
ALTER TABLE "public"."digger_batches" ADD COLUMN "ai_summary_comment_id" text NULL, ADD COLUMN "report_terraform_outputs" boolean NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for nil after failing to publish the AI summary comment.
If
PublishComment
fails, we log the error but still proceed to useaiSummaryComment.Id
, which may cause a nil pointer dereference. Consider returning early when an error occurs.Proposed fix:
var aiSummaryCommentId = "" if config.Reporting.AiSummary { aiSummaryComment, err := ghService.PublishComment(prNumber, "AI Summary will be posted here after completion") if err != nil { log.Printf("could not post ai summary comment: %v", err) commentReporterManager.UpdateComment(fmt.Sprintf(":x: could not post ai comment summary comment id: %v", err)) + return } aiSummaryCommentId = aiSummaryComment.Id }