|
|
@ -24,7 +24,8 @@ Usage: go run ci.go <command> <command flags/arguments> |
|
|
|
Available commands are: |
|
|
|
Available commands are: |
|
|
|
|
|
|
|
|
|
|
|
install [ -arch architecture ] [ packages... ] -- builds packages and executables |
|
|
|
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 |
|
|
|
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts |
|
|
|
importkeys -- imports signing keys from env |
|
|
|
importkeys -- imports signing keys from env |
|
|
|
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package |
|
|
|
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package |
|
|
@ -146,6 +147,8 @@ func main() { |
|
|
|
doInstall(os.Args[2:]) |
|
|
|
doInstall(os.Args[2:]) |
|
|
|
case "test": |
|
|
|
case "test": |
|
|
|
doTest(os.Args[2:]) |
|
|
|
doTest(os.Args[2:]) |
|
|
|
|
|
|
|
case "lint": |
|
|
|
|
|
|
|
doLint(os.Args[2:]) |
|
|
|
case "archive": |
|
|
|
case "archive": |
|
|
|
doArchive(os.Args[2:]) |
|
|
|
doArchive(os.Args[2:]) |
|
|
|
case "debsrc": |
|
|
|
case "debsrc": |
|
|
@ -280,7 +283,6 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd { |
|
|
|
|
|
|
|
|
|
|
|
func doTest(cmdline []string) { |
|
|
|
func doTest(cmdline []string) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
misspell = flag.Bool("misspell", false, "Whether to run the spell checker") |
|
|
|
|
|
|
|
coverage = flag.Bool("coverage", false, "Whether to record code coverage") |
|
|
|
coverage = flag.Bool("coverage", false, "Whether to record code coverage") |
|
|
|
) |
|
|
|
) |
|
|
|
flag.CommandLine.Parse(cmdline) |
|
|
|
flag.CommandLine.Parse(cmdline) |
|
|
@ -294,10 +296,7 @@ func doTest(cmdline []string) { |
|
|
|
|
|
|
|
|
|
|
|
// Run analysis tools before the tests.
|
|
|
|
// Run analysis tools before the tests.
|
|
|
|
build.MustRun(goTool("vet", packages...)) |
|
|
|
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.
|
|
|
|
// Run the actual tests.
|
|
|
|
gotest := goTool("test", buildFlags(env)...) |
|
|
|
gotest := goTool("test", buildFlags(env)...) |
|
|
|
// Test a single package at a time. CI builders are slow
|
|
|
|
// Test a single package at a time. CI builders are slow
|
|
|
@ -306,36 +305,26 @@ func doTest(cmdline []string) { |
|
|
|
if *coverage { |
|
|
|
if *coverage { |
|
|
|
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover") |
|
|
|
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gotest.Args = append(gotest.Args, packages...) |
|
|
|
gotest.Args = append(gotest.Args, packages...) |
|
|
|
build.MustRun(gotest) |
|
|
|
build.MustRun(gotest) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// spellcheck runs the client9/misspell spellchecker package on all Go, Cgo and
|
|
|
|
// runs gometalinter on requested packages
|
|
|
|
// test files in the requested packages.
|
|
|
|
func doLint(cmdline []string) { |
|
|
|
func spellcheck(packages []string) { |
|
|
|
flag.CommandLine.Parse(cmdline) |
|
|
|
// Ensure the spellchecker is available
|
|
|
|
|
|
|
|
build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Windows chokes on long argument lists, check packages individually
|
|
|
|
packages := []string{"./..."} |
|
|
|
for _, pkg := range packages { |
|
|
|
if len(flag.CommandLine.Args()) > 0 { |
|
|
|
// The spell checker doesn't work on packages, gather all .go files for it
|
|
|
|
packages = flag.CommandLine.Args() |
|
|
|
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...)...) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Get metalinter and install all supported linters
|
|
|
|
|
|
|
|
build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v1")) |
|
|
|
|
|
|
|
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configs := []string{"--vendor", "--disable-all", "--enable=vet"} // Add additional linters to the slice with "--enable=linter-name"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Release Packaging
|
|
|
|
// Release Packaging
|
|
|
|