Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 150 additions & 15 deletions internal/apiclient/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 64 additions & 2 deletions internal/output/lavaflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ func LavaflowStats(w io.Writer, stats *apiclient.LavaflowStats) {
summary(w, on, "%d issue(s) opened and %d fix pull request(s) opened, %s to %s",
stats.Totals.IssuesOpened, stats.Totals.PullRequestsOpened,
stats.WindowStart.Format(time.DateOnly), stats.WindowEnd.Format(time.DateOnly))
if delivery := stats.Delivery; delivery != nil {
kv(w, on, "Runs without an owned PR", "%d of %d (%d finished)", delivery.RunsWithoutOwnedPr, delivery.Runs, delivery.FinishedWithoutOwnedPr)
kv(w, on, "Issues with PR coverage", "%d of %d", delivery.IssuesWithPrCoverage, delivery.IssuesWithRuns)
if delivery.MeanTimeToPrSeconds != nil {
kv(w, on, "Mean time to PR", "%ds (%d samples)", *delivery.MeanTimeToPrSeconds, delivery.TimeToPrSamples)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ P3: Stats print mean latency as raw seconds

Mean time to PR and Mean time to coverage print %ds, so a one-day mean reads as 86400s. Other output in this package formats second counts with (time.Duration(n) * time.Second).String() (see deployments.go:74 and durable.go:418). Formatting these the same way would make them readable and consistent. The companion docs PR would need the same change.

Found by claude-opus-5-5

}
if delivery.MeanTimeToCoverageSeconds != nil {
kv(w, on, "Mean time to coverage", "%ds (%d samples)", *delivery.MeanTimeToCoverageSeconds, delivery.TimeToCoverageSamples)
}
}
}

// LavaflowResources renders every function, frontend and durable function with
Expand Down Expand Up @@ -160,14 +170,40 @@ func LavaflowRuns(w io.Writer, page LavaflowRunsPage) {
for _, run := range page.Runs {
fmt.Fprintf(w, "%-36s %-31s %-24s %-30s %-16s %s\n",
run.Id.String(), Truncate(lavaflowRunListStatus(run), 31), Truncate(clean(run.Resource.Name), 24),
Truncate(clean(stringOr(run.Title, "-")), 30), formatLavaflowTime(run.CreatedAt), lavaflowPullRequestCell(run.PullRequest))
Truncate(clean(stringOr(run.Title, "-")), 30), formatLavaflowTime(run.CreatedAt), lavaflowDeliveryCell(run.PullRequest, run.Delivery))
}
summary(w, on, "Showing %d run(s)", len(page.Runs))
if page.NextCommand != "" {
nextPage(w, on, clean(page.NextCommand))
}
}

func lavaflowDeliveryCell(pr *apiclient.LavaflowPullRequest, delivery *apiclient.LavaflowDelivery) string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ P3: New delivery rendering has no tests

The diff adds lavaflowDeliveryCell, three new branches in lavaflowFix (prior skips, coverage, next action) and the stats delivery lines, but no _test.go changes. A search of the head checkout finds no test that mentions Delivery, "Covered by", "Previous blocker" or "Runs without an owned PR". The output tests the description says passed only cover the old paths, where Delivery is nil. Add table cases for each delivery state, coverage with and without a deployment, next_action with and without a PR, and stats with null and non-null means.

Found by claude-opus-5-5

if pr != nil || delivery == nil {
return lavaflowPullRequestCell(pr)
}
if cover := delivery.Coverage; cover != nil {
return fmt.Sprintf("Covered by #%d (%s)", cover.Number, clean(string(cover.State)))
}
if status := lavaflowDeliveryStatus(delivery.State); status != "" {
return status
}
return "-"
}

func lavaflowDeliveryStatus(state apiclient.LavaflowDeliveryState) string {
switch state {
case apiclient.LavaflowDeliveryStateWaitingForPrerequisite:
return "Waiting"
case apiclient.LavaflowDeliveryStateTerminalMiss:
return "Undelivered"
case apiclient.LavaflowDeliveryStateStopped:
return "Stopped"
default:
return ""
}
}

// LavaflowRunStarted renders a run a person started: its ID and status, and
// the command that follows it.
func LavaflowRunStarted(w io.Writer, runID string, status apiclient.LavaflowRunStatus, showCommand string) {
Expand Down Expand Up @@ -463,7 +499,33 @@ func lavaflowHumanReviewPaths(w io.Writer, on bool, policy apiclient.LavaflowMer
// state and where its merge is, or why the run has no pull request.
func lavaflowFix(w io.Writer, on bool, run *apiclient.LavaflowRun) {
fmt.Fprintln(w, theme.Dim("Fix:", on))
pr := run.PullRequest
pr, delivery := run.PullRequest, run.Delivery
if delivery != nil {
for _, skip := range delivery.PriorSkips {
fixKV(w, on, "Previous blocker", "%s (%s)", clean(string(skip.Reason)), formatLavaflowTimePtr(skip.RecordedAt, "time unknown"))
}
if delivery.NextAction != nil {
defer fixKV(w, on, "Next action", "%s", clean(*delivery.NextAction))
}
if cover := delivery.Coverage; cover != nil && pr == nil {
fixKV(w, on, "Covering pull request", "#%d %s", cover.Number, clean(cover.Url))
fixKV(w, on, "State", "%s", clean(string(cover.State)))
if cover.State == apiclient.LavaflowDeliveryCoverageStateMerged {
fixKV(w, on, "Deployment", "%s", formatLavaflowTimePtr(cover.DeployedAt, "unconfirmed"))
}
return
}
if state := lavaflowDeliveryStatus(delivery.State); state != "" && pr == nil {
if delivery.Reason != nil {
fixKV(w, on, "Delivery", "%s (%s)", state, clean(*delivery.Reason))
} else {
fixKV(w, on, "Delivery", "%s", state)
}
if delivery.State == apiclient.LavaflowDeliveryStateWaitingForPrerequisite || run.PullRequestSkipped == nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ P3: A waiting delivery with no next_action shows only a raw skip code

For waiting_for_prerequisite, lavaflowFix prints Delivery: Waiting (<reason>) and returns before lavaflowNoFix, even when run.PullRequestSkipped is set. The schema says next_action is sent only "when known". If it is missing, show prints a bare code such as ungated_workflows or permission_missing and skips the existing plain-language advice, for example "Gate that workflow on a label a person adds…". One fix is to fall through to the lavaflowNoFix text, or a waiting-specific version of it, when NextAction is nil.

Found by claude-opus-5-5

return
}
}
}
if pr == nil {
fmt.Fprintf(w, " %s\n", lavaflowNoFix(run))
return
Expand Down
40 changes: 40 additions & 0 deletions internal/output/lavaflow_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package output

import (
"bytes"
"testing"

"github.com/stretchr/testify/require"

"github.com/Kong/volcano-cli/internal/apiclient"
)

func TestLavaflowDeliveryStatus(t *testing.T) {
t.Parallel()

nextAction := "Check the repository connection."
reason := "source_unavailable"
for _, tc := range []struct {
state apiclient.LavaflowDeliveryState
label string
action *string
}{
{apiclient.LavaflowDeliveryStateWaitingForPrerequisite, "Waiting", nil},
{apiclient.LavaflowDeliveryStateTerminalMiss, "Undelivered", &nextAction},
{apiclient.LavaflowDeliveryStateStopped, "Stopped", &nextAction},
} {
t.Run(string(tc.state), func(t *testing.T) {
t.Parallel()
delivery := &apiclient.LavaflowDelivery{State: tc.state, Reason: &reason, NextAction: tc.action}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ P3: Covering-PR and delivery-stat output remain untested

The new test covers three delivery states, but no tests populate coverage, prior skips, or stats delivery fields. The covering-PR precedence, deployment output, and nullable latency branches therefore lack regression coverage. Add focused output cases for these paths.

Found by gpt-6.1-sol

run := &apiclient.LavaflowRun{Status: apiclient.LavaflowRunStatusCompleted, Delivery: delivery}

require.Equal(t, tc.label, lavaflowDeliveryCell(nil, delivery))
var out bytes.Buffer
lavaflowFix(&out, false, run)
require.Contains(t, out.String(), "Delivery: "+tc.label+" ("+reason+")")
if tc.action != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ P3: New test skips the coverage, prior-skip, fall-through and stats paths

TestLavaflowDeliveryStatus covers only the three status labels with PullRequestSkipped nil, so every case returns early. Several paths are never exercised: the covering-PR list cell and detail block (including merged with and without deployed_at), Previous blocker lines, the non-waiting fall-through to lavaflowNoFix when PullRequestSkipped is set, Next action alongside a real PR, and the new LavaflowStats delivery lines with null and non-null means. Adding table cases for these would protect the precedence rules this PR set.

Found by claude-opus-5-5

require.Contains(t, out.String(), "Next action: "+*tc.action)
}
})
}
}
Loading
Loading