mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
Remove dummy mod dir (#1121)
This commit is contained in:
+2
-3
@@ -7,7 +7,7 @@ pool:
|
|||||||
vmImage: 'vs2017-win2016'
|
vmImage: 'vs2017-win2016'
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GOBIN: '$(GOPATH)\bin' # Go binaries path
|
GOBIN: 'C:\Go\bin' # Go binaries path
|
||||||
GOPATH: '$(system.defaultWorkingDirectory)\gopath' # Go workspace path
|
GOPATH: '$(system.defaultWorkingDirectory)\gopath' # Go workspace path
|
||||||
GO111MODULE: 'on'
|
GO111MODULE: 'on'
|
||||||
modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code
|
modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code
|
||||||
@@ -15,7 +15,6 @@ variables:
|
|||||||
steps:
|
steps:
|
||||||
- powershell: |
|
- powershell: |
|
||||||
choco upgrade golang
|
choco upgrade golang
|
||||||
mkdir "$env:GOBIN" | out-null
|
|
||||||
mkdir "$env:GOPATH\pkg" | out-null
|
mkdir "$env:GOPATH\pkg" | out-null
|
||||||
mkdir "$env:modulePath" | 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"
|
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'
|
displayName: 'set up the Go workspace'
|
||||||
|
|
||||||
- powershell: |
|
- powershell: |
|
||||||
go test -mod=vendor -race ./...
|
& "C:\\Go\\bin\\go.exe" test -mod=vendor -race ./...
|
||||||
workingDirectory: '$(modulePath)'
|
workingDirectory: '$(modulePath)'
|
||||||
displayName: 'run tests'
|
displayName: 'run tests'
|
||||||
|
|||||||
@@ -39,22 +39,18 @@ func (l *vcsLister) List(ctx context.Context, mod string) (*storage.RevInfo, []s
|
|||||||
ctx, span := observ.StartSpan(ctx, op.String())
|
ctx, span := observ.StartSpan(ctx, op.String())
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
hackyPath, err := afero.TempDir(l.fs, "", "hackymod")
|
tmpDir, err := afero.TempDir(l.fs, "", "go-list")
|
||||||
if err != nil {
|
|
||||||
return nil, nil, errors.E(op, err)
|
|
||||||
}
|
|
||||||
defer l.fs.RemoveAll(hackyPath)
|
|
||||||
err = module.Dummy(l.fs, hackyPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.E(op, err)
|
return nil, nil, errors.E(op, err)
|
||||||
}
|
}
|
||||||
|
defer l.fs.RemoveAll(tmpDir)
|
||||||
|
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
l.goBinPath,
|
l.goBinPath,
|
||||||
"list", "-m", "-versions", "-json",
|
"list", "-m", "-versions", "-json",
|
||||||
config.FmtModVer(mod, "latest"),
|
config.FmtModVer(mod, "latest"),
|
||||||
)
|
)
|
||||||
cmd.Dir = hackyPath
|
cmd.Dir = tmpDir
|
||||||
stdout := &bytes.Buffer{}
|
stdout := &bytes.Buffer{}
|
||||||
stderr := &bytes.Buffer{}
|
stderr := &bytes.Buffer{}
|
||||||
cmd.Stdout = stdout
|
cmd.Stdout = stdout
|
||||||
|
|||||||
@@ -65,12 +65,6 @@ func (g *goGetFetcher) Fetch(ctx context.Context, mod, ver string) (*storage.Ver
|
|||||||
return nil, errors.E(op, err)
|
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)
|
m, err := downloadModule(g.goBinaryName, g.fs, goPathRoot, modPath, mod, ver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ClearFiles(g.fs, goPathRoot)
|
ClearFiles(g.fs, goPathRoot)
|
||||||
@@ -104,23 +98,6 @@ func (g *goGetFetcher) Fetch(ctx context.Context, mod, ver string) (*storage.Ver
|
|||||||
return &storageVer, nil
|
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'
|
// 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.
|
// 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) {
|
func downloadModule(goBinaryName string, fs afero.Fs, gopath, repoRoot, module, version string) (goModule, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user