From 5899d80c8347e6f5f99a85de505199f1fb3024ae Mon Sep 17 00:00:00 2001 From: Roming22 Date: Thu, 19 Dec 2024 13:57:33 +0000 Subject: [PATCH] fix: improve user feedback When PaC is used with other CIs (eg openshift-ci), it can happen that a `ok-to-test` label managed by the other CI is present. That label may persist after a change, but PaC will report the need for the latest content to be approved. This state is likely to confuse the user. In order to improve the UX, the required action is now explicitely stated in the message in the UI. --- pkg/pipelineascode/match.go | 2 +- pkg/provider/github/status.go | 2 +- pkg/provider/github/status_test.go | 4 ++-- test/pkg/gitea/test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/pipelineascode/match.go b/pkg/pipelineascode/match.go index bb2e8ff70..68ca9c7e5 100644 --- a/pkg/pipelineascode/match.go +++ b/pkg/pipelineascode/match.go @@ -377,7 +377,7 @@ func (p *PacRun) checkAccessOrErrror(ctx context.Context, repo *v1alpha1.Reposit p.eventEmitter.EmitMessage(repo, zap.InfoLevel, "RepositoryPermissionDenied", msg) status := provider.StatusOpts{ Status: queuedStatus, - Title: "Pending approval", + Title: "Pending approval, needs /ok-to-test", Conclusion: pendingConclusion, Text: msg, DetailsURL: p.event.URL, diff --git a/pkg/provider/github/status.go b/pkg/provider/github/status.go index 53397dac8..bdefea05c 100644 --- a/pkg/provider/github/status.go +++ b/pkg/provider/github/status.go @@ -321,7 +321,7 @@ func (v *Provider) createStatusCommit(ctx context.Context, runevent *info.Event, runevent.Organization, runevent.Repository, runevent.SHA, ghstatus); err != nil { return err } - if (status.Status == "completed" || (status.Status == "queued" && status.Title == "Pending approval")) && status.Text != "" && runevent.EventType == triggertype.PullRequest.String() { + if (status.Status == "completed" || (status.Status == "queued" && status.Title == "Pending approval, needs /ok-to-test")) && status.Text != "" && runevent.EventType == triggertype.PullRequest.String() { _, _, err = v.Client.Issues.CreateComment(ctx, runevent.Organization, runevent.Repository, runevent.PullRequestNumber, &github.IssueComment{ diff --git a/pkg/provider/github/status_test.go b/pkg/provider/github/status_test.go index 2157dae92..97583fc02 100644 --- a/pkg/provider/github/status_test.go +++ b/pkg/provider/github/status_test.go @@ -169,7 +169,7 @@ func TestGetExistingPendingApprovalCheckRunID(t *testing.T) { "id": %v, "external_id": "%s", "output": { - "title": "Pending approval", + "title": "Pending approval, needs /ok-to-test", "summary": "My CI is waiting for approval" } } @@ -414,7 +414,7 @@ func TestGithubProviderCreateStatus(t *testing.T) { "status": "queued", "conclusion": "pending", "output": { - "title": "Pending approval", + "title": "Pending approval, needs /ok-to-test", "summary": "My CI is waiting for approval" } } diff --git a/test/pkg/gitea/test.go b/test/pkg/gitea/test.go index 9c610a1f2..690e63c4f 100644 --- a/test/pkg/gitea/test.go +++ b/test/pkg/gitea/test.go @@ -388,7 +388,7 @@ func WaitForStatus(t *testing.T, topts *TestOpts, ref, forcontext string, onlyla } for _, cstatus := range statuses { if topts.CheckForStatus == "Skipped" { - if strings.HasSuffix(cstatus.Description, "Pending approval") { + if strings.HasSuffix(cstatus.Description, "Pending approval, needs /ok-to-test") { numstatus++ break }