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

Commit 9d4340e

Browse files
committed
show workspace setup error for pull requests
1 parent bb9358b commit 9d4340e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

app/analyze/processors/github_go_pr.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func (g githubGoPR) buildSecrets() map[string]string {
240240
const hidden = "{hidden}"
241241
ret := map[string]string{
242242
g.context.GithubAccessToken: hidden,
243+
g.analysisGUID: hidden,
243244
}
244245
if g.newWorkspaceInstaller == nil {
245246
ret[g.gw.Gopath()] = "$GOPATH"
@@ -383,9 +384,16 @@ func (g githubGoPR) Process(ctx context.Context) error {
383384
return fmt.Errorf("can't get pull request: %s", err)
384385
}
385386

387+
g.setCommitStatus(ctx, github.StatusPending, "GolangCI is reviewing your Pull Request...")
388+
386389
if g.newWorkspaceInstaller == nil {
387390
g.gw = workspaces.NewGo(g.exec, g.infoFetcher)
388391
if err = g.gw.Setup(ctx, g.getRepo(), "github.com", g.context.Repo.Owner, g.context.Repo.Name); err != nil {
392+
publicError := fmt.Sprintf("failed to setup workspace: %s", err)
393+
publicError = escapeErrorText(publicError, g.buildSecrets())
394+
g.updateAnalysisState(ctx, nil, github.StatusError, publicError)
395+
g.setCommitStatus(ctx, github.StatusError, "failed to setup")
396+
389397
return fmt.Errorf("can't setup go workspace: %s", err)
390398
}
391399
defer g.gw.Clean(ctx)
@@ -394,7 +402,12 @@ func (g githubGoPR) Process(ctx context.Context) error {
394402
startedAt := time.Now()
395403
exec, resLog, err := g.newWorkspaceInstaller.Setup(ctx, g.getRepo(), "github.com", g.context.Repo.Owner, g.context.Repo.Name) //nolint:govet
396404
if err != nil {
397-
return errors.Wrap(err, "can't setup workspace")
405+
publicError := fmt.Sprintf("failed to setup workspace: %s", err)
406+
publicError = escapeErrorText(publicError, g.buildSecrets())
407+
g.updateAnalysisState(ctx, nil, github.StatusError, publicError)
408+
g.setCommitStatus(ctx, github.StatusError, "failed to setup")
409+
410+
return errors.Wrap(err, "failed to setup setup workspace")
398411
}
399412
g.exec = exec
400413
g.resLog = resLog
@@ -413,7 +426,6 @@ func (g githubGoPR) Process(ctx context.Context) error {
413426
return fmt.Errorf("can't store patch: %s", err)
414427
}
415428

416-
g.setCommitStatus(ctx, github.StatusPending, "GolangCI is reviewing your Pull Request...")
417429
curState, err := g.state.GetState(ctx, g.context.Repo.Owner, g.context.Repo.Name, g.analysisGUID)
418430
if err != nil {
419431
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)