Merge pull request #1113 from samalba/fix-race-ci

Fix race ci
This commit is contained in:
Andrea Luzzardi 2021-11-08 17:51:32 -08:00 committed by GitHub
commit 2d371ca32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -41,6 +41,8 @@ func Install(ctx context.Context, workspace, repoName, versionConstraint string)
return nil, err
}
defer fileLock.Unlock()
err = modfile.install(ctx, require)
if err != nil {
return nil, err
@ -50,10 +52,6 @@ func Install(ctx context.Context, workspace, repoName, versionConstraint string)
return nil, err
}
if err := fileLock.Unlock(); err != nil {
return nil, err
}
return require, nil
}
@ -98,6 +96,8 @@ func Update(ctx context.Context, workspace, repoName, versionConstraint string)
return nil, err
}
defer fileLock.Unlock()
updatedRequire, err := modfile.updateToLatest(ctx, require)
if err != nil {
return nil, err
@ -107,10 +107,6 @@ func Update(ctx context.Context, workspace, repoName, versionConstraint string)
return nil, err
}
if err := fileLock.Unlock(); err != nil {
return nil, err
}
return updatedRequire, nil
}

View File

@ -8,6 +8,8 @@ import (
"os"
"path"
"path/filepath"
"github.com/gofrs/flock"
)
var (
@ -15,11 +17,19 @@ var (
//go:embed **/*.cue **/*/*.cue
FS embed.FS
PackageName = "alpha.dagger.io"
Path = path.Join("cue.mod", "pkg", PackageName)
PackageName = "alpha.dagger.io"
Path = path.Join("cue.mod", "pkg", PackageName)
lockFilePath = path.Join("cue.mod", "dagger.lock")
)
func Vendor(ctx context.Context, mod string) error {
fileLock := flock.New(path.Join(mod, lockFilePath))
if err := fileLock.Lock(); err != nil {
return err
}
defer fileLock.Unlock()
// Remove any existing copy of the universe
if err := os.RemoveAll(path.Join(mod, Path)); err != nil {
return err