Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote reporting of package build times and success #156

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Add remote reporting CLI
  • Loading branch information
csweichel committed Jul 1, 2023
commit f93936256fdc7d77d9e330f6f91ca5fe0b1284b0
7 changes: 7 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import (
"time"

"github.com/gitpod-io/leeway/pkg/leeway"
"github.com/gitpod-io/leeway/pkg/remotereporter"
"github.com/gookit/color"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -173,6 +174,7 @@ func addBuildFlags(cmd *cobra.Command) {
cmd.Flags().String("coverage-output-path", "", "Output path where test coverage file will be copied after running tests")
cmd.Flags().StringToString("docker-build-options", nil, "Options passed to all 'docker build' commands")
cmd.Flags().String("report", "", "Generate a HTML report after the build has finished. (e.g. --report myreport.html)")
cmd.Flags().String("remote-report", "", "Report the build progress to a remote endoint")
}

func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, *leeway.FilesystemCache) {
@@ -249,6 +251,11 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, *leeway.FilesystemC
} else if report != "" {
reporter = append(reporter, leeway.NewHTMLReporter(report))
}
if ep, err := cmd.Flags().GetString("remote-report"); err != nil {
log.Fatal(err)
} else if ep != "" {
reporter = append(reporter, remotereporter.NewReporter(ep))
}

dontTest, err := cmd.Flags().GetBool("dont-test")
if err != nil {
10 changes: 10 additions & 0 deletions pkg/remotereporter/reporter.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package remotereporter

import (
"context"
"net/http"
"time"

connect_go "github.com/bufbuild/connect-go"
@@ -11,6 +12,15 @@ import (
"github.com/sirupsen/logrus"
)

func NewReporter(endpoint string) *Reporter {
httpclient := &http.Client{Timeout: 2 * time.Second}
client := v1connect.NewReporterServiceClient(httpclient, endpoint)
return &Reporter{
sessionID: time.Now().Format(time.RFC3339Nano),
Client: client,
}
}

type Reporter struct {
Client v1connect.ReporterServiceClient