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

Commit 15c38dd

Browse files
committed
show workspace setup error for pull requests
1 parent bb9358b commit 15c38dd

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

app/analyze/processors/github_go_pr.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/golangci/golangci-worker/app/lib/goutils/workspaces"
2626
"github.com/golangci/golangci-worker/app/lib/httputils"
2727
gh "github.com/google/go-github/github"
28-
"github.com/pkg/errors"
2928

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

386+
g.setCommitStatus(ctx, github.StatusPending, "GolangCI is reviewing your Pull Request...")
387+
386388
if g.newWorkspaceInstaller == nil {
387389
g.gw = workspaces.NewGo(g.exec, g.infoFetcher)
388390
if err = g.gw.Setup(ctx, g.getRepo(), "github.com", g.context.Repo.Owner, g.context.Repo.Name); err != nil {
391+
publicError := fmt.Sprintf("failed to setup workspace: %s", err)
392+
publicError = escapeErrorText(publicError, g.buildSecrets())
393+
g.updateAnalysisState(ctx, nil, github.StatusError, publicError)
394+
g.setCommitStatus(ctx, github.StatusError, "failed to setup")
395+
389396
return fmt.Errorf("can't setup go workspace: %s", err)
390397
}
391398
defer g.gw.Clean(ctx)
@@ -394,7 +401,12 @@ func (g githubGoPR) Process(ctx context.Context) error {
394401
startedAt := time.Now()
395402
exec, resLog, err := g.newWorkspaceInstaller.Setup(ctx, g.getRepo(), "github.com", g.context.Repo.Owner, g.context.Repo.Name) //nolint:govet
396403
if err != nil {
397-
return errors.Wrap(err, "can't setup workspace")
404+
publicError := fmt.Sprintf("failed to setup workspace: %s", err)
405+
publicError = escapeErrorText(publicError, g.buildSecrets())
406+
g.updateAnalysisState(ctx, nil, github.StatusError, publicError)
407+
g.setCommitStatus(ctx, github.StatusError, "failed to setup")
408+
409+
return nil
398410
}
399411
g.exec = exec
400412
g.resLog = resLog
@@ -413,7 +425,6 @@ func (g githubGoPR) Process(ctx context.Context) error {
413425
return fmt.Errorf("can't store patch: %s", err)
414426
}
415427

416-
g.setCommitStatus(ctx, github.StatusPending, "GolangCI is reviewing your Pull Request...")
417428
curState, err := g.state.GetState(ctx, g.context.Repo.Owner, g.context.Repo.Name, g.analysisGUID)
418429
if err != nil {
419430
analytics.Log(ctx).Warnf("Can't get current state: %s", err)

app/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.s
3030

3131
WORKDIR ${GOPATH}/src/github.com/golangci/golangci-api
3232
RUN git clone https://github.com/golangci/golangci-api.git . && \
33-
git checkout 7d0494722429c7b8ccc01f8f7e425be0fbd15586 && \
33+
git checkout 3329ce5d9c091cb335ea6aa5e24874f74d076df6 && \
3434
GO111MODULE=on go mod vendor && \
3535
go install ./cmd/ensuredeps && \
3636
go install ./cmd/buildrunner && \

0 commit comments

Comments
 (0)