mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
mage: Init packages once
`go list ./...` fails when run in parallel on Windows. This also applies to running `go test ./...` and `go list/...` so we serialize tests.
This commit is contained in:
parent
293e12355d
commit
ea8ef573c6
1 changed files with 24 additions and 11 deletions
35
magefile.go
35
magefile.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/magefile/mage/mg"
|
"github.com/magefile/mage/mg"
|
||||||
|
@ -98,7 +99,11 @@ func Check() {
|
||||||
fmt.Printf("Skip Check on %s\n", runtime.Version())
|
fmt.Printf("Skip Check on %s\n", runtime.Version())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mg.Deps(Test386, Fmt, Vet)
|
|
||||||
|
mg.Deps(Test386)
|
||||||
|
|
||||||
|
mg.Deps(Fmt, Vet)
|
||||||
|
|
||||||
// don't run two tests in parallel, they saturate the CPUs anyway, and running two
|
// don't run two tests in parallel, they saturate the CPUs anyway, and running two
|
||||||
// causes memory issues in CI.
|
// causes memory issues in CI.
|
||||||
mg.Deps(TestRace)
|
mg.Deps(TestRace)
|
||||||
|
@ -161,18 +166,26 @@ func Fmt() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var pkgPrefixLen = len("github.com/gohugoio/hugo")
|
var (
|
||||||
|
pkgPrefixLen = len("github.com/gohugoio/hugo")
|
||||||
|
pkgs []string
|
||||||
|
pkgsInit sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
func hugoPackages() ([]string, error) {
|
func hugoPackages() ([]string, error) {
|
||||||
s, err := sh.Output(goexe, "list", "./...")
|
var err error
|
||||||
if err != nil {
|
pkgsInit.Do(func() {
|
||||||
return nil, err
|
var s string
|
||||||
}
|
s, err = sh.Output(goexe, "list", "./...")
|
||||||
pkgs := strings.Split(s, "\n")
|
if err != nil {
|
||||||
for i := range pkgs {
|
return
|
||||||
pkgs[i] = "." + pkgs[i][pkgPrefixLen:]
|
}
|
||||||
}
|
pkgs = strings.Split(s, "\n")
|
||||||
return pkgs, nil
|
for i := range pkgs {
|
||||||
|
pkgs[i] = "." + pkgs[i][pkgPrefixLen:]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return pkgs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run golint linter
|
// Run golint linter
|
||||||
|
|
Loading…
Reference in a new issue