Skip to content

Commit

Permalink
Merge pull request #3590 from ActiveState/mitchell/dx-3155
Browse files Browse the repository at this point in the history
Added dashboard build progress details URL.
  • Loading branch information
mitchell-as authored Nov 14, 2024
2 parents 8e47470 + e1a5947 commit 72c594e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 3 additions & 1 deletion internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions internal/runbits/runtime/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions internal/runbits/runtime/runtime.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package runtime_runbit

import (
"net/url"
"os"

anaConsts "github.com/ActiveState/cli/internal/analytics/constants"
Expand Down Expand Up @@ -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://<host>/<owner>/<project>/distributions?branch=<branch>&commitID=<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")
Expand Down
1 change: 1 addition & 0 deletions pkg/runtime/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Start struct {

RequiresBuild bool
LogFilePath string
ProgressUrl string

ArtifactsToBuild buildplan.ArtifactIDMap
ArtifactsToDownload buildplan.ArtifactIDMap
Expand Down
4 changes: 4 additions & 0 deletions pkg/runtime/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/runtime/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Opts struct {
PreferredLibcVersion string
EventHandlers []events.HandlerFunc
BuildlogFilePath string
BuildProgressUrl string

FromArchive *fromArchive

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion test/integration/runtime_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 72c594e

Please sign in to comment.