From e1a5947706ebbc2e00614b0631ba90f5aa481b63 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 12 Nov 2024 14:42:30 -0500 Subject: [PATCH] Added dashboard build progress details URL. --- internal/constants/constants.go | 3 +++ internal/locale/locales/en-us.yaml | 4 +++- internal/runbits/runtime/progress/progress.go | 1 + internal/runbits/runtime/runtime.go | 19 +++++++++++++++++++ pkg/runtime/events/events.go | 1 + pkg/runtime/options.go | 4 ++++ pkg/runtime/setup.go | 2 ++ test/integration/runtime_int_test.go | 3 ++- 8 files changed, 35 insertions(+), 2 deletions(-) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index b8f054e96e..f64eb5650d 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -493,3 +493,6 @@ const OverrideShellEnvVarName = "ACTIVESTATE_CLI_SHELL_OVERRIDE" // IgnoreEnvEnvVarName is the environment variable to set for skipping specific environment variables during runtime setup. const IgnoreEnvEnvVarName = "ACTIVESTATE_CLI_IGNORE_ENV" + +// ProgressUrlPathName is the trailing path for a project's build progress. +const BuildProgressUrlPathName = "distributions" diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index 9a4deb3a3a..7030506100 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -1127,7 +1127,9 @@ progress_solve_preruntime: progress_pkg_nolang: other: "• Searching for [ACTIONABLE]{{.V0}}[/RESET] across all languages in the ActiveState Catalog" progress_build_log: - other: "Build Log [ACTIONABLE]{{.V0}}[/RESET]" + other: "Build Log: [ACTIONABLE]{{.V0}}[/RESET]" +progress_build_url: + other: "Detailed Progress: [ACTIONABLE]{{.V0}}[/RESET]" progress_completed: other: "[SUCCESS]✔ All dependencies have been installed and verified[/RESET]" progress_failed: diff --git a/internal/runbits/runtime/progress/progress.go b/internal/runbits/runtime/progress/progress.go index a071d5774e..2d902f0a42 100644 --- a/internal/runbits/runtime/progress/progress.go +++ b/internal/runbits/runtime/progress/progress.go @@ -147,6 +147,7 @@ func (p *ProgressDigester) Handle(ev events.Event) error { // already progressbars being displayed which won't play nice with newly printed output. if v.RequiresBuild { p.out.Notice(locale.Tr("progress_build_log", v.LogFilePath)) + p.out.Notice(locale.Tr("progress_build_url", v.ProgressUrl)) } p.recipeID = v.RecipeID diff --git a/internal/runbits/runtime/runtime.go b/internal/runbits/runtime/runtime.go index f4b72ba59b..5cd987d89d 100644 --- a/internal/runbits/runtime/runtime.go +++ b/internal/runbits/runtime/runtime.go @@ -1,6 +1,7 @@ package runtime_runbit import ( + "net/url" "os" anaConsts "github.com/ActiveState/cli/internal/analytics/constants" @@ -252,6 +253,24 @@ func Update( if opts.Archive != nil { rtOpts = append(rtOpts, runtime.WithArchive(opts.Archive.Dir, opts.Archive.PlatformID, checkout.ArtifactExt)) } + if commit.BuildPlan().IsBuildInProgress() { + // Build progress URL is of the form + // https://///distributions?branch=&commitID= + host := constants.DefaultAPIHost + if hostOverride := os.Getenv(constants.APIHostEnvVarName); hostOverride != "" { + host = hostOverride + } + path, err := url.JoinPath(proj.Owner(), proj.Name(), constants.BuildProgressUrlPathName) + if err != nil { + return nil, errs.Wrap(err, "Could not construct progress url path") + } + u := &url.URL{Scheme: "https", Host: host, Path: path} + q := u.Query() + q.Set("branch", proj.BranchName()) + q.Set("commitID", commitID.String()) + u.RawQuery = q.Encode() + rtOpts = append(rtOpts, runtime.WithBuildProgressUrl(u.String())) + } if err := rt.Update(buildPlan, rtHash, rtOpts...); err != nil { return nil, locale.WrapError(err, "err_packages_update_runtime_install") diff --git a/pkg/runtime/events/events.go b/pkg/runtime/events/events.go index 9585c182b3..1f9ffebfcf 100644 --- a/pkg/runtime/events/events.go +++ b/pkg/runtime/events/events.go @@ -37,6 +37,7 @@ type Start struct { RequiresBuild bool LogFilePath string + ProgressUrl string ArtifactsToBuild buildplan.ArtifactIDMap ArtifactsToDownload buildplan.ArtifactIDMap diff --git a/pkg/runtime/options.go b/pkg/runtime/options.go index dd150afaef..19492243cf 100644 --- a/pkg/runtime/options.go +++ b/pkg/runtime/options.go @@ -13,6 +13,10 @@ func WithBuildlogFilePath(path string) SetOpt { return func(opts *Opts) { opts.BuildlogFilePath = path } } +func WithBuildProgressUrl(url string) SetOpt { + return func(opts *Opts) { opts.BuildProgressUrl = url } +} + func WithPreferredLibcVersion(version string) SetOpt { return func(opts *Opts) { opts.PreferredLibcVersion = version } } diff --git a/pkg/runtime/setup.go b/pkg/runtime/setup.go index b59229af79..d35ca25805 100644 --- a/pkg/runtime/setup.go +++ b/pkg/runtime/setup.go @@ -46,6 +46,7 @@ type Opts struct { PreferredLibcVersion string EventHandlers []events.HandlerFunc BuildlogFilePath string + BuildProgressUrl string FromArchive *fromArchive @@ -200,6 +201,7 @@ func (s *setup) RunAndWait() (rerr error) { RecipeID: s.buildplan.LegacyRecipeID(), RequiresBuild: s.buildplan.IsBuildInProgress() && len(s.toDownload) > 0, LogFilePath: s.opts.BuildlogFilePath, + ProgressUrl: s.opts.BuildProgressUrl, ArtifactsToBuild: s.toBuild, ArtifactsToDownload: s.toDownload, ArtifactsToUnpack: s.toUnpack, diff --git a/test/integration/runtime_int_test.go b/test/integration/runtime_int_test.go index 55b440c199..cb22734c18 100644 --- a/test/integration/runtime_int_test.go +++ b/test/integration/runtime_int_test.go @@ -169,7 +169,8 @@ func (suite *RuntimeIntegrationTestSuite) TestBuildInProgress() { ts.PrepareEmptyProject() cp = ts.Spawn("install", "private/"+e2e.PersistentUsername+"/hello-world", "--ts", "now") - cp.Expect("Build Log") + cp.Expect("Build Log:") + cp.Expect("Detailed Progress:") cp.Expect("Building") cp.Expect("All dependencies have been installed and verified", e2e.RuntimeBuildSourcingTimeoutOpt) cp.Expect("Added: private/" + e2e.PersistentUsername + "/hello-world")