From 78f339e51f29893ffa791cf8ea100dc1c44a02c5 Mon Sep 17 00:00:00 2001 From: Takumaron Date: Wed, 8 Nov 2023 15:49:12 +0700 Subject: [PATCH 1/2] Send error comment before plan preview exit Signed-off-by: Takumaron --- tool/actions-plan-preview/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tool/actions-plan-preview/main.go b/tool/actions-plan-preview/main.go index 9194030543..f5f3fd7401 100644 --- a/tool/actions-plan-preview/main.go +++ b/tool/actions-plan-preview/main.go @@ -101,14 +101,14 @@ func main() { } if event.PRClosed { - doComment(failureBadgeURL + "Unable to run plan-preview for a closed pull request.") + doComment(failureBadgeURL + "\nUnable to run plan-preview for a closed pull request.") return } // TODO: When PR opened, `Mergeable` is nil for calculation. // Here it is not considered for now, but needs to be handled. if event.PRMergeable != nil && *event.PRMergeable == false { - doComment(failureBadgeURL + "Unable to run plan-preview for an un-mergeable pull request. Please resolve the conficts and try again.") + doComment(failureBadgeURL + "\nUnable to run plan-preview for an un-mergeable pull request. Please resolve the conficts and try again.") return } @@ -123,6 +123,7 @@ func main() { args.Timeout, ) if err != nil { + doComment(failureBadgeURL + "\nUnable to run plan-preview. \ncause: " + err.Error()) log.Fatal(err) } log.Println("Successfully retrieved plan-preview result") @@ -131,10 +132,11 @@ func main() { if result.HasError() { pr, err := getPullRequest(ctx, ghClient.PullRequests, event.Owner, event.Repo, event.PRNumber) if err != nil { + doComment(failureBadgeURL + "\nUnable to run plan-preview. \ncause: " + err.Error()) log.Fatal(err) } if !pr.GetClosedAt().IsZero() { - doComment(failureBadgeURL + "Unable to run plan-preview for a closed pull request.") + doComment(failureBadgeURL + "\nUnable to run plan-preview for a closed pull request.") return } } @@ -152,7 +154,7 @@ func main() { return } - if bool(comment.IsMinimized) { + if comment.IsMinimized { log.Printf("Previous plan-preview comment has already minimized. So don't minimize anything\n") return } From 5aded83c517202ee7b890c473c523e330fd0539d Mon Sep 17 00:00:00 2001 From: Takumaron Date: Thu, 9 Nov 2023 09:02:56 +0700 Subject: [PATCH 2/2] Apply review commnet Signed-off-by: Takumaron --- tool/actions-plan-preview/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tool/actions-plan-preview/main.go b/tool/actions-plan-preview/main.go index f5f3fd7401..0bf0ecdcc3 100644 --- a/tool/actions-plan-preview/main.go +++ b/tool/actions-plan-preview/main.go @@ -154,7 +154,7 @@ func main() { return } - if comment.IsMinimized { + if bool(comment.IsMinimized) { log.Printf("Previous plan-preview comment has already minimized. So don't minimize anything\n") return }