From cbf4fa568c9d0d6174132065f619865ae2542e0e Mon Sep 17 00:00:00 2001 From: Tiffany Chiang Date: Thu, 31 Oct 2024 15:31:24 -0400 Subject: [PATCH] provide links to runs in queue instead of commits in queue --- .../workflows/activities/github/revision_url_markdown.go | 5 +++++ .../workflows/internal/deploy/revision/queue/queue.go | 8 ++++---- .../neptune/workflows/internal/deploy/terraform/state.go | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/server/neptune/workflows/activities/github/revision_url_markdown.go b/server/neptune/workflows/activities/github/revision_url_markdown.go index b64bdffb8..4d7a0e487 100644 --- a/server/neptune/workflows/activities/github/revision_url_markdown.go +++ b/server/neptune/workflows/activities/github/revision_url_markdown.go @@ -6,3 +6,8 @@ func BuildRevisionURLMarkdown(repoFullName string, revision string) string { // uses Markdown formatting to generate the link on GH return fmt.Sprintf("[%s](https://github.com/%s/commit/%s)", revision, repoFullName, revision) } + +func BuildRunURLMarkdown(repoFullName string, revision string, runId int64) string { + // uses Markdown formatting to generate the link on GH + return fmt.Sprintf("[%s](https://github.com/%s/runs/%d)", revision, repoFullName, runId) +} diff --git a/server/neptune/workflows/internal/deploy/revision/queue/queue.go b/server/neptune/workflows/internal/deploy/revision/queue/queue.go index ef5e02bea..7a77a0199 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/queue.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/queue.go @@ -90,13 +90,13 @@ func (q *Deploy) Push(msg terraform.DeploymentInfo) { func (q *Deploy) GetQueuedRevisionsSummary() string { var revisions []string if q.IsEmpty() { - return "No other revisions ahead In queue." + return "No other runs ahead in queue." } for _, deploy := range q.Scan() { - revisionLink := github.BuildRevisionURLMarkdown(deploy.Repo.GetFullName(), deploy.Commit.Revision) - revisions = append(revisions, revisionLink) + runLink := github.BuildRunURLMarkdown(deploy.Repo.GetFullName(), deploy.Commit.Revision, deploy.CheckRunID) + revisions = append(revisions, runLink) } - return fmt.Sprintf("Revisions in queue: %s", strings.Join(revisions, ", ")) + return fmt.Sprintf("Runs in queue: %s", strings.Join(revisions, ", ")) } // priority is a simple 2 priority queue implementation diff --git a/server/neptune/workflows/internal/deploy/terraform/state.go b/server/neptune/workflows/internal/deploy/terraform/state.go index 241c42c9e..2a1da6213 100644 --- a/server/neptune/workflows/internal/deploy/terraform/state.go +++ b/server/neptune/workflows/internal/deploy/terraform/state.go @@ -56,8 +56,8 @@ func (n *StateReceiver) Receive(ctx workflow.Context, c workflow.ReceiveChannel, revisionsSummary := n.Queue.GetQueuedRevisionsSummary() state := github.CheckRunQueued - revisionLink := github.BuildRevisionURLMarkdown(deploymentInfo.Repo.GetFullName(), deploymentInfo.Commit.Revision) - summary := fmt.Sprintf("This deploy is queued pending action on revision %s.\n%s", revisionLink, revisionsSummary) + runLink := github.BuildRunURLMarkdown(deploymentInfo.Repo.GetFullName(), deploymentInfo.Commit.Revision, deploymentInfo.CheckRunID) + summary := fmt.Sprintf("This deploy is queued pending action on run for revision %s.\n%s", runLink, revisionsSummary) for _, i := range infos { request := notifier.GithubCheckRunRequest{