diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1c98048b..814a2608 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,7 +7,7 @@ pool: vmImage: 'vs2017-win2016' variables: - GOBIN: '$(GOPATH)\bin' # Go binaries path + GOBIN: 'C:\Go\bin' # Go binaries path GOPATH: '$(system.defaultWorkingDirectory)\gopath' # Go workspace path GO111MODULE: 'on' modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code @@ -15,7 +15,6 @@ variables: steps: - powershell: | choco upgrade golang - mkdir "$env:GOBIN" | out-null mkdir "$env:GOPATH\pkg" | out-null mkdir "$env:modulePath" | out-null robocopy "$env:system_defaultWorkingDirectory\" "$env:modulePath\" /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD "$env:GOPATH" @@ -23,6 +22,6 @@ steps: displayName: 'set up the Go workspace' - powershell: | - go test -mod=vendor -race ./... + & "C:\\Go\\bin\\go.exe" test -mod=vendor -race ./... workingDirectory: '$(modulePath)' displayName: 'run tests' diff --git a/pkg/download/upstream_lister.go b/pkg/download/upstream_lister.go index 571338ac..cb85ded1 100644 --- a/pkg/download/upstream_lister.go +++ b/pkg/download/upstream_lister.go @@ -39,22 +39,18 @@ func (l *vcsLister) List(ctx context.Context, mod string) (*storage.RevInfo, []s ctx, span := observ.StartSpan(ctx, op.String()) defer span.End() - hackyPath, err := afero.TempDir(l.fs, "", "hackymod") - if err != nil { - return nil, nil, errors.E(op, err) - } - defer l.fs.RemoveAll(hackyPath) - err = module.Dummy(l.fs, hackyPath) + tmpDir, err := afero.TempDir(l.fs, "", "go-list") if err != nil { return nil, nil, errors.E(op, err) } + defer l.fs.RemoveAll(tmpDir) cmd := exec.Command( l.goBinPath, "list", "-m", "-versions", "-json", config.FmtModVer(mod, "latest"), ) - cmd.Dir = hackyPath + cmd.Dir = tmpDir stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} cmd.Stdout = stdout diff --git a/pkg/module/go_get_fetcher.go b/pkg/module/go_get_fetcher.go index 0c5ca368..08f28a8f 100644 --- a/pkg/module/go_get_fetcher.go +++ b/pkg/module/go_get_fetcher.go @@ -65,12 +65,6 @@ func (g *goGetFetcher) Fetch(ctx context.Context, mod, ver string) (*storage.Ver return nil, errors.E(op, err) } - // setup the module with barebones stuff - if err := Dummy(g.fs, modPath); err != nil { - ClearFiles(g.fs, goPathRoot) - return nil, errors.E(op, err) - } - m, err := downloadModule(g.goBinaryName, g.fs, goPathRoot, modPath, mod, ver) if err != nil { ClearFiles(g.fs, goPathRoot) @@ -104,23 +98,6 @@ func (g *goGetFetcher) Fetch(ctx context.Context, mod, ver string) (*storage.Ver return &storageVer, nil } -// Dummy Hacky thing makes vgo not to complain -func Dummy(fs afero.Fs, repoRoot string) error { - const op errors.Op = "module.Dummy" - // vgo expects go.mod file present with module statement or .go file with import comment - gomodPath := filepath.Join(repoRoot, "go.mod") - gomodContent := []byte("module mod") - if err := afero.WriteFile(fs, gomodPath, gomodContent, 0666); err != nil { - return errors.E(op, err) - } - sourcePath := filepath.Join(repoRoot, "mod.go") - sourceContent := []byte("package mod") - if err := afero.WriteFile(fs, sourcePath, sourceContent, 0666); err != nil { - return errors.E(op, err) - } - return nil -} - // given a filesystem, gopath, repository root, module and version, runs 'go mod download -json' // on module@version from the repoRoot with GOPATH=gopath, and returns a non-nil error if anything went wrong. func downloadModule(goBinaryName string, fs afero.Fs, gopath, repoRoot, module, version string) (goModule, error) {