@@ -34,7 +34,6 @@ import (
3434 "net/http"
3535 "net/url"
3636 "os"
37- "path"
3837 "path/filepath"
3938 "reflect"
4039 "runtime/debug"
@@ -511,7 +510,19 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
511510 log .Printf ("strconv.ParseInt error: %v" , err )
512511 commentReporterManager .UpdateComment (fmt .Sprintf (":x: could not handle commentId: %v" , err ))
513512 }
514- batchId , _ , err := utils .ConvertJobsToDiggerJobs (* diggerCommand , models .DiggerVCSGithub , organisationId , impactedJobsMap , impactedProjectsMap , projectsGraph , installationId , branch , prNumber , repoOwner , repoName , repoFullName , commitSha , commentId , diggerYmlStr , 0 )
513+
514+ var aiSummaryCommentId = ""
515+ if config .Reporting .AiSummary {
516+ aiSummaryComment , err := ghService .PublishComment (prNumber , "AI Summary will be posted here after completion" )
517+ if err != nil {
518+ log .Printf ("could not post ai summary comment: %v" , err )
519+ commentReporterManager .UpdateComment (fmt .Sprintf (":x: could not post ai comment summary comment id: %v" , err ))
520+ return fmt .Errorf ("could not post ai summary comment: %v" , err )
521+ }
522+ aiSummaryCommentId = aiSummaryComment .Id
523+ }
524+
525+ batchId , _ , err := utils .ConvertJobsToDiggerJobs (* diggerCommand , models .DiggerVCSGithub , organisationId , impactedJobsMap , impactedProjectsMap , projectsGraph , installationId , branch , prNumber , repoOwner , repoName , repoFullName , commitSha , commentId , diggerYmlStr , 0 , aiSummaryCommentId , config .ReportTerraformOutputs )
515526 if err != nil {
516527 log .Printf ("ConvertJobsToDiggerJobs error: %v" , err )
517528 commentReporterManager .UpdateComment (fmt .Sprintf (":x: ConvertJobsToDiggerJobs error: %v" , err ))
@@ -585,8 +596,11 @@ func GetDiggerConfigForBranch(gh utils.GithubClientProvider, installationId int6
585596 var dependencyGraph graph.Graph [string , dg_configuration.Project ]
586597
587598 err = utils .CloneGitRepoAndDoAction (cloneUrl , branch , "" , * token , func (dir string ) error {
588- diggerYmlBytes , err := os .ReadFile (path .Join (dir , "digger.yml" ))
589- diggerYmlStr = string (diggerYmlBytes )
599+ diggerYmlStr , err = dg_configuration .ReadDiggerYmlFileContents (dir )
600+ if err != nil {
601+ log .Printf ("could not load digger config: %v" , err )
602+ return err
603+ }
590604 config , _ , dependencyGraph , err = dg_configuration .LoadDiggerConfig (dir , true , changedFiles )
591605 if err != nil {
592606 log .Printf ("Error loading digger config: %v" , err )
@@ -768,7 +782,10 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
768782 // terraform code generator
769783 if os .Getenv ("DIGGER_GENERATION_ENABLED" ) == "1" {
770784 err = GenerateTerraformFromCode (payload , commentReporterManager , config , defaultBranch , ghService , repoOwner , repoName , commitSha , issueNumber , branch )
771- return err
785+ if err != nil {
786+ log .Printf ("terraform generation failed: %v" , err )
787+ return err
788+ }
772789 }
773790
774791 commentIdStr := strconv .FormatInt (userCommentId , 10 )
@@ -902,7 +919,18 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
902919 return fmt .Errorf ("comment reporter error: %v" , err )
903920 }
904921
905- batchId , _ , err := utils .ConvertJobsToDiggerJobs (* diggerCommand , "github" , orgId , impactedProjectsJobMap , impactedProjectsMap , projectsGraph , installationId , * branch , issueNumber , repoOwner , repoName , repoFullName , * commitSha , reporterCommentId , diggerYmlStr , 0 )
922+ var aiSummaryCommentId = ""
923+ if config .Reporting .AiSummary {
924+ aiSummaryComment , err := ghService .PublishComment (issueNumber , "AI Summary will be posted here after completion" )
925+ if err != nil {
926+ log .Printf ("could not post ai summary comment: %v" , err )
927+ commentReporterManager .UpdateComment (fmt .Sprintf (":x: could not post ai comment summary comment id: %v" , err ))
928+ return fmt .Errorf ("could not post ai summary comment: %v" , err )
929+ }
930+ aiSummaryCommentId = aiSummaryComment .Id
931+ }
932+
933+ batchId , _ , err := utils .ConvertJobsToDiggerJobs (* diggerCommand , "github" , orgId , impactedProjectsJobMap , impactedProjectsMap , projectsGraph , installationId , * branch , issueNumber , repoOwner , repoName , repoFullName , * commitSha , reporterCommentId , diggerYmlStr , 0 , aiSummaryCommentId , config .ReportTerraformOutputs )
906934 if err != nil {
907935 log .Printf ("ConvertJobsToDiggerJobs error: %v" , err )
908936 commentReporterManager .UpdateComment (fmt .Sprintf (":x: ConvertJobsToDiggerJobs error: %v" , err ))
0 commit comments