Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
show workspace setup error for pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jirfag committed Nov 25, 2018
1 parent bb9358b commit 15c38dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions app/analyze/processors/github_go_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/golangci/golangci-worker/app/lib/goutils/workspaces"
"github.com/golangci/golangci-worker/app/lib/httputils"
gh "github.com/google/go-github/github"
"github.com/pkg/errors"

"github.com/golangci/golangci-shared/pkg/config"
"github.com/golangci/golangci-shared/pkg/logutil"
Expand Down Expand Up @@ -240,6 +239,7 @@ func (g githubGoPR) buildSecrets() map[string]string {
const hidden = "{hidden}"
ret := map[string]string{
g.context.GithubAccessToken: hidden,
g.analysisGUID: hidden,
}
if g.newWorkspaceInstaller == nil {
ret[g.gw.Gopath()] = "$GOPATH"
Expand Down Expand Up @@ -383,9 +383,16 @@ func (g githubGoPR) Process(ctx context.Context) error {
return fmt.Errorf("can't get pull request: %s", err)
}

g.setCommitStatus(ctx, github.StatusPending, "GolangCI is reviewing your Pull Request...")

if g.newWorkspaceInstaller == nil {
g.gw = workspaces.NewGo(g.exec, g.infoFetcher)
if err = g.gw.Setup(ctx, g.getRepo(), "github.com", g.context.Repo.Owner, g.context.Repo.Name); err != nil {
publicError := fmt.Sprintf("failed to setup workspace: %s", err)
publicError = escapeErrorText(publicError, g.buildSecrets())
g.updateAnalysisState(ctx, nil, github.StatusError, publicError)
g.setCommitStatus(ctx, github.StatusError, "failed to setup")

return fmt.Errorf("can't setup go workspace: %s", err)
}
defer g.gw.Clean(ctx)
Expand All @@ -394,7 +401,12 @@ func (g githubGoPR) Process(ctx context.Context) error {
startedAt := time.Now()
exec, resLog, err := g.newWorkspaceInstaller.Setup(ctx, g.getRepo(), "github.com", g.context.Repo.Owner, g.context.Repo.Name) //nolint:govet
if err != nil {
return errors.Wrap(err, "can't setup workspace")
publicError := fmt.Sprintf("failed to setup workspace: %s", err)
publicError = escapeErrorText(publicError, g.buildSecrets())
g.updateAnalysisState(ctx, nil, github.StatusError, publicError)
g.setCommitStatus(ctx, github.StatusError, "failed to setup")

return nil
}
g.exec = exec
g.resLog = resLog
Expand All @@ -413,7 +425,6 @@ func (g githubGoPR) Process(ctx context.Context) error {
return fmt.Errorf("can't store patch: %s", err)
}

g.setCommitStatus(ctx, github.StatusPending, "GolangCI is reviewing your Pull Request...")
curState, err := g.state.GetState(ctx, g.context.Repo.Owner, g.context.Repo.Name, g.analysisGUID)
if err != nil {
analytics.Log(ctx).Warnf("Can't get current state: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion app/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.s

WORKDIR ${GOPATH}/src/github.com/golangci/golangci-api
RUN git clone https://github.com/golangci/golangci-api.git . && \
git checkout 7d0494722429c7b8ccc01f8f7e425be0fbd15586 && \
git checkout 3329ce5d9c091cb335ea6aa5e24874f74d076df6 && \
GO111MODULE=on go mod vendor && \
go install ./cmd/ensuredeps && \
go install ./cmd/buildrunner && \
Expand Down

0 comments on commit 15c38dd

Please sign in to comment.