aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDan Melton <melton.dan@gmail.com>2017-11-09 18:46:03 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-11-09 18:46:03 +0800
commitd7f2462e8f242887846cbff760790fa42c28de65 (patch)
treea8a8e4748f2bac17ca36f66f1cbb2198103742d0 /build
parent4fe30bf5ade8849bb3971a0edad95d17d99e8778 (diff)
downloadgo-tangerine-d7f2462e8f242887846cbff760790fa42c28de65.tar.gz
go-tangerine-d7f2462e8f242887846cbff760790fa42c28de65.tar.zst
go-tangerine-d7f2462e8f242887846cbff760790fa42c28de65.zip
build: add Travis job to lint Go code #15372 (#15416)
* build: [finishes #15372] implements generalized linter and travis job * .travis, build: minor polishes, disable deadcode
Diffstat (limited to 'build')
-rw-r--r--build/ci.go49
1 files changed, 19 insertions, 30 deletions
diff --git a/build/ci.go b/build/ci.go
index a4f5616bc..5d52fad87 100644
--- a/build/ci.go
+++ b/build/ci.go
@@ -24,7 +24,8 @@ Usage: go run 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
@@ -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":
@@ -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,36 +305,26 @@ 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.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
s'>+4 * Cleanup plistantoine2014-11-122-5/+0 * Update to 4.3.3.jkim2014-11-011-4/+4 * Update to 1.8.0bapt2014-10-312-3/+3 * Update to 1.8.0bapt2014-10-312-3/+6 * KDE/FreeBSD team presents KDE SC 4.14.2 and KDE Workspace 4.11.13!makc2014-10-193-304/+86 * Update to 4.3.2.jkim2014-10-172-5/+4 * Update the default version of GCC in the Ports Collection from GCC 4.7.4gerald2014-09-113-2/+3 * Upgrade OpenEXR and ilmbase to 2.2.0.mandree2014-08-162-1/+2 * Remove indefinite articles and trailing periods from COMMENT, plusolgeni2014-08-033-3/+3 * Convert a bunch of EXTRACT_SUFX=... into USES=tar:...adamw2014-07-302-4/+2 * Modernize LIB_DEPENDSbapt2014-07-151-1/+1 * Stagify.vanilla2014-07-021-8/+4 * Update to 4.2.5.jkim2014-06-241-4/+4 * Update to libreoffice 4.2.4bapt2014-06-111-4/+4 * Support staging.mi2014-06-102-3/+2