diff options
author | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
---|---|---|
committer | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
commit | 3857cdc267e3192697f561df0a0f827f65dfb6b5 (patch) | |
tree | 401c52c4972a68229ea283a394a0b0a5f3cfdc8e /build | |
parent | a5330fe0c569b75cb8a524f60f7e8dc06498262b (diff) | |
parent | fe070ab5c32702033489f1b9d1655ea1b894c29e (diff) | |
download | dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.gz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.bz2 dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.lz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.xz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.zst dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.zip |
Merge branch 'master' into abi-offset-fixed-arrays
Diffstat (limited to 'build')
-rw-r--r-- | build/ci.go | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/build/ci.go b/build/ci.go index 6fe03db71..987f0bb18 100644 --- a/build/ci.go +++ b/build/ci.go @@ -19,12 +19,13 @@ /* The ci command is called from Continuous Integration scripts. -Usage: go run ci.go <command> <command flags/arguments> +Usage: go run build/ci.go <command> <command flags/arguments> Available commands are: install [ -arch architecture ] [ packages... ] -- builds packages and executables - test [ -coverage ] [ -misspell ] [ packages... ] -- runs the tests + test [ -coverage ] [ packages... ] -- runs the tests + lint -- runs certain pre-selected linters archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts importkeys -- imports signing keys from env debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package @@ -120,7 +121,7 @@ var ( // Note: vivid is unsupported because there is no golang-1.6 package for it. // Note: wily is unsupported because it was officially deprecated on lanchpad. // Note: yakkety is unsupported because it was officially deprecated on lanchpad. - debDistros = []string{"trusty", "xenial", "zesty"} + debDistros = []string{"trusty", "xenial", "zesty", "artful"} ) var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin")) @@ -146,6 +147,8 @@ func main() { doInstall(os.Args[2:]) case "test": doTest(os.Args[2:]) + case "lint": + doLint(os.Args[2:]) case "archive": doArchive(os.Args[2:]) case "debsrc": @@ -196,7 +199,7 @@ func doInstall(cmdline []string) { build.MustRun(goinstall) return } - // If we are cross compiling to ARMv5 ARMv6 or ARMv7, clean any prvious builds + // If we are cross compiling to ARMv5 ARMv6 or ARMv7, clean any previous builds if *arch == "arm" { os.RemoveAll(filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_arm")) for _, path := range filepath.SplitList(build.GOPATH()) { @@ -280,7 +283,6 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd { func doTest(cmdline []string) { var ( - misspell = flag.Bool("misspell", false, "Whether to run the spell checker") coverage = flag.Bool("coverage", false, "Whether to record code coverage") ) flag.CommandLine.Parse(cmdline) @@ -294,10 +296,7 @@ func doTest(cmdline []string) { // Run analysis tools before the tests. build.MustRun(goTool("vet", packages...)) - if *misspell { - // TODO(karalabe): Reenable after false detection is fixed: https://github.com/client9/misspell/issues/105 - // spellcheck(packages) - } + // Run the actual tests. gotest := goTool("test", buildFlags(env)...) // Test a single package at a time. CI builders are slow @@ -306,35 +305,39 @@ func doTest(cmdline []string) { if *coverage { gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover") } + gotest.Args = append(gotest.Args, packages...) build.MustRun(gotest) } -// spellcheck runs the client9/misspell spellchecker package on all Go, Cgo and -// test files in the requested packages. -func spellcheck(packages []string) { - // Ensure the spellchecker is available - build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell")) +// runs gometalinter on requested packages +func doLint(cmdline []string) { + flag.CommandLine.Parse(cmdline) - // Windows chokes on long argument lists, check packages individually - for _, pkg := range packages { - // The spell checker doesn't work on packages, gather all .go files for it - out, err := goTool("list", "-f", "{{.Dir}}{{range .GoFiles}}\n{{.}}{{end}}{{range .CgoFiles}}\n{{.}}{{end}}{{range .TestGoFiles}}\n{{.}}{{end}}", pkg).CombinedOutput() - if err != nil { - log.Fatalf("source file listing failed: %v\n%s", err, string(out)) - } - // Retrieve the folder and assemble the source list - lines := strings.Split(string(out), "\n") - root := lines[0] - - sources := make([]string, 0, len(lines)-1) - for _, line := range lines[1:] { - if line = strings.TrimSpace(line); line != "" { - sources = append(sources, filepath.Join(root, line)) - } - } - // Run the spell checker for this particular package - build.MustRunCommand(filepath.Join(GOBIN, "misspell"), append([]string{"-error"}, sources...)...) + packages := []string{"./..."} + if len(flag.CommandLine.Args()) > 0 { + packages = flag.CommandLine.Args() + } + // Get metalinter and install all supported linters + build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v2")) + build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), "--install") + + // Run fast linters batched together + configs := []string{ + "--vendor", + "--disable-all", + "--enable=vet", + "--enable=gofmt", + "--enable=misspell", + "--enable=goconst", + "--min-occurrences=6", // for goconst + } + build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...) + + // Run slow linters one by one + for _, linter := range []string{"unconvert", "gosimple"} { + configs = []string{"--vendor", "--deadline=10m", "--disable-all", "--enable=" + linter} + build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...) } } |