Skip to content

Commit

Permalink
post error if digger.yml load failed (#1592)
Browse files Browse the repository at this point in the history
* post comment error if digger.yml load failed
  • Loading branch information
motatoes committed Jun 27, 2024
1 parent 3dd12d5 commit f609b72
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/controllers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR

diggerYmlStr, ghService, config, projectsGraph, _, _, err := getDiggerConfigForPR(gh, installationId, repoFullName, repoOwner, repoName, cloneURL, prNumber)
if err != nil {
ghService, _, err := utils.GetGithubService(gh, installationId, repoFullName, repoOwner, repoName)
if err != nil {
log.Printf("GetGithubService error: %v", err)
return fmt.Errorf("error getting ghService to post error comment")
}
utils.InitCommentReporter(ghService, prNumber, fmt.Sprintf(":x: Could not load digger config, error: %v", err))
log.Printf("getDiggerConfigForPR error: %v", err)
return fmt.Errorf("error getting digger config")
}
Expand Down Expand Up @@ -666,6 +672,7 @@ func getDiggerConfigForBranch(gh utils.GithubClientProvider, installationId int6
return diggerYmlStr, ghService, config, dependencyGraph, nil
}

// TODO: Refactor this func to receive ghService as input
func getDiggerConfigForPR(gh utils.GithubClientProvider, installationId int64, repoFullName string, repoOwner string, repoName string, cloneUrl string, prNumber int) (string, *dg_github.GithubService, *dg_configuration.DiggerConfig, graph.Graph[string, dg_configuration.Project], *string, *string, error) {
ghService, _, err := utils.GetGithubService(gh, installationId, repoFullName, repoOwner, repoName)
if err != nil {
Expand Down Expand Up @@ -747,6 +754,12 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu

diggerYmlStr, ghService, config, projectsGraph, branch, commitSha, err := getDiggerConfigForPR(gh, installationId, repoFullName, repoOwner, repoName, cloneURL, issueNumber)
if err != nil {
ghService, _, err := utils.GetGithubService(gh, installationId, repoFullName, repoOwner, repoName)
if err != nil {
log.Printf("GetGithubService error: %v", err)
return fmt.Errorf("error getting ghService to post error comment")
}
utils.InitCommentReporter(ghService, issueNumber, fmt.Sprintf(":x: Could not load digger config, error: %v", err))
log.Printf("getDiggerConfigForPR error: %v", err)
return fmt.Errorf("error getting digger config")
}
Expand Down

0 comments on commit f609b72

Please sign in to comment.