@@ -20,6 +20,7 @@ import (
20
20
"github.com/golangci/golangci-api/pkg/worker/lib/github"
21
21
"github.com/golangci/golangci-api/pkg/worker/lib/goutils/workspaces"
22
22
"github.com/pkg/errors"
23
+ redsync "gopkg.in/redsync.v1"
23
24
24
25
"github.com/golangci/golangci-api/internal/shared/config"
25
26
envbuildresult "github.com/golangci/golangci-api/pkg/goenvbuild/result"
@@ -31,12 +32,13 @@ const (
31
32
)
32
33
33
34
type StaticBasicPullConfig struct {
34
- RepoFetcher fetchers.Fetcher
35
- Linters []linters.Linter
36
- Runner linters.Runner
37
- ProviderClient github.Client
38
- State prstate.Storage
39
- Cfg config.Config
35
+ RepoFetcher fetchers.Fetcher
36
+ Linters []linters.Linter
37
+ Runner linters.Runner
38
+ ProviderClient github.Client
39
+ State prstate.Storage
40
+ Cfg config.Config
41
+ DistLockFactory * redsync.Redsync
40
42
}
41
43
42
44
type BasicPullConfig struct {
@@ -177,6 +179,12 @@ func (p *BasicPull) analyze(ctx *PullContext) (*result.Result, error) {
177
179
issues := res .Issues
178
180
ctx .LogCtx ["reportedIssues" ] = len (issues )
179
181
182
+ lock := p .DistLockFactory .NewMutex (ctx .ProviderCtx .Repo .FullName ())
183
+ if err = lock .Lock (); err != nil {
184
+ return nil , errors .Wrapf (err , "failed to acquire lock %s" , ctx .ProviderCtx .Repo .FullName ())
185
+ }
186
+ defer lock .Unlock ()
187
+
180
188
if err = p .Reporter .Report (ctx .Ctx , ctx .buildConfig , ctx .res .buildLog , ctx .pull .GetHead ().GetSHA (), issues ); err != nil {
181
189
if errors .Cause (err ) == github .ErrUserIsBlocked {
182
190
return nil , & errorutils.InternalError {
0 commit comments