From d53708231c4b650982e4586a597713a41ad88abf Mon Sep 17 00:00:00 2001 From: Amp Date: Fri, 25 Sep 2026 16:14:58 +0000 Subject: [PATCH 1/2] Fix UTC labeling of server build time in version output Co-authored-by: Evan Phoenix --- cli/commands/version.go | 2 +- cli/commands/version_test.go | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 cli/commands/version_test.go diff --git a/cli/commands/version.go b/cli/commands/version.go index 8c274c04d..f217e8008 100644 --- a/cli/commands/version.go +++ b/cli/commands/version.go @@ -145,7 +145,7 @@ func printBuildLines(ctx *Context, ver, commit string, built time.Time) { ctx.Printf(" Commit: %s\n", commit) } if !built.IsZero() { - ctx.Printf(" Built: %s\n", built.Format("2006-01-02 15:04:05 UTC")) + ctx.Printf(" Built: %s\n", built.UTC().Format("2006-01-02 15:04:05 UTC")) } } diff --git a/cli/commands/version_test.go b/cli/commands/version_test.go new file mode 100644 index 000000000..61e1b5307 --- /dev/null +++ b/cli/commands/version_test.go @@ -0,0 +1,39 @@ +package commands + +import ( + "bytes" + "testing" + "time" +) + +func TestPrintBuildLinesUTC(t *testing.T) { + tests := []struct { + name string + built time.Time + want string + }{ + { + name: "server build in local timezone", + built: time.Date(2026, 9, 14, 12, 48, 18, 0, time.FixedZone("CDT", -5*60*60)), + want: " Version: v1\n Built: 2026-09-14 17:48:18 UTC\n", + }, + { + name: "CLI build already in UTC", + built: time.Date(2026, 9, 14, 18, 10, 17, 0, time.UTC), + want: " Version: v1\n Built: 2026-09-14 18:10:17 UTC\n", + }, + { + name: "unknown build date", + want: " Version: v1\n", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var out bytes.Buffer + printBuildLines(&Context{Stdout: &out}, "v1", "", tt.built) + if got := out.String(); got != tt.want { + t.Fatalf("printBuildLines output = %q, want %q", got, tt.want) + } + }) + } +} From 4096053ed7976305d3c0de58c5eec290ec012a46 Mon Sep 17 00:00:00 2001 From: Amp Date: Fri, 25 Sep 2026 17:48:27 +0000 Subject: [PATCH 2/2] Normalize upgrade build dates before UTC display Co-authored-by: Evan Phoenix --- cli/commands/upgrade_helpers.go | 8 ++++---- cli/commands/upgrade_helpers_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/cli/commands/upgrade_helpers.go b/cli/commands/upgrade_helpers.go index f0b05eb5f..3f4eec4f0 100644 --- a/cli/commands/upgrade_helpers.go +++ b/cli/commands/upgrade_helpers.go @@ -131,7 +131,7 @@ func PrintVersionComparison(current, latest release.VersionInfo) { fmt.Printf("Current commit: %s\n", sc) } if !current.BuildDate.IsZero() { - fmt.Printf("Current build: %s\n", current.BuildDate.Format("2006-01-02 15:04:05 UTC")) + fmt.Printf("Current build: %s\n", current.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC")) } fmt.Printf("\nLatest version: %s\n", latest.Version) @@ -139,7 +139,7 @@ func PrintVersionComparison(current, latest release.VersionInfo) { fmt.Printf("Latest commit: %s\n", sc) } if !latest.BuildDate.IsZero() { - fmt.Printf("Latest build: %s\n", latest.BuildDate.Format("2006-01-02 15:04:05 UTC")) + fmt.Printf("Latest build: %s\n", latest.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC")) } } @@ -164,8 +164,8 @@ func CheckIfUpgradeNeeded(ctx context.Context, targetVersion string, force bool, } else { fmt.Printf("Current version %s is already up to date (target: %s)\n", current.Version, latest.Version) if !current.BuildDate.IsZero() && !latest.BuildDate.IsZero() { - fmt.Printf("Current build: %s\n", current.BuildDate.Format("2006-01-02 15:04:05 UTC")) - fmt.Printf("Target build: %s\n", latest.BuildDate.Format("2006-01-02 15:04:05 UTC")) + fmt.Printf("Current build: %s\n", current.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC")) + fmt.Printf("Target build: %s\n", latest.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC")) } } return false, nil diff --git a/cli/commands/upgrade_helpers_test.go b/cli/commands/upgrade_helpers_test.go index 036c21a03..574d0a049 100644 --- a/cli/commands/upgrade_helpers_test.go +++ b/cli/commands/upgrade_helpers_test.go @@ -1,10 +1,15 @@ package commands import ( + "io" + "os" "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "miren.dev/runtime/pkg/release" ) func TestResolveVersionChannel(t *testing.T) { @@ -60,3 +65,21 @@ func TestResolveVersionChannel(t *testing.T) { }) } } + +func TestPrintVersionComparisonBuildDatesUTC(t *testing.T) { + stdout := os.Stdout + r, w, err := os.Pipe() + require.NoError(t, err) + os.Stdout = w + defer func() { os.Stdout = stdout }() + defer r.Close() + + PrintVersionComparison( + release.VersionInfo{Version: "v1", BuildDate: time.Date(2026, 9, 14, 12, 48, 18, 0, time.FixedZone("CDT", -5*60*60))}, + release.VersionInfo{Version: "v2", BuildDate: time.Date(2026, 9, 15, 4, 10, 17, 0, time.FixedZone("JST", 9*60*60))}, + ) + require.NoError(t, w.Close()) + output, err := io.ReadAll(r) + require.NoError(t, err) + assert.Equal(t, "Current version: v1\nCurrent build: 2026-09-14 17:48:18 UTC\n\nLatest version: v2\nLatest build: 2026-09-14 19:10:17 UTC\n", string(output)) +}