@@ -24,7 +24,8 @@ Usage: go run ci.go <command> <command flags/arguments>
2424Available commands are:
2525
2626 install [ -arch architecture ] [ packages... ] -- builds packages and executables
27- test [ -coverage ] [ -misspell ] [ packages... ] -- runs the tests
27+ test [ -coverage ] [ packages... ] -- runs the tests
28+ lint -- runs certain pre-selected linters
2829 archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
2930 importkeys -- imports signing keys from env
3031 debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
@@ -146,6 +147,8 @@ func main() {
146147 doInstall (os .Args [2 :])
147148 case "test" :
148149 doTest (os .Args [2 :])
150+ case "lint" :
151+ doLint (os .Args [2 :])
149152 case "archive" :
150153 doArchive (os .Args [2 :])
151154 case "debsrc" :
@@ -280,7 +283,6 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {
280283
281284func doTest (cmdline []string ) {
282285 var (
283- misspell = flag .Bool ("misspell" , false , "Whether to run the spell checker" )
284286 coverage = flag .Bool ("coverage" , false , "Whether to record code coverage" )
285287 )
286288 flag .CommandLine .Parse (cmdline )
@@ -294,10 +296,7 @@ func doTest(cmdline []string) {
294296
295297 // Run analysis tools before the tests.
296298 build .MustRun (goTool ("vet" , packages ... ))
297- if * misspell {
298- // TODO(karalabe): Reenable after false detection is fixed: https://github.com/client9/misspell/issues/105
299- // spellcheck(packages)
300- }
299+
301300 // Run the actual tests.
302301 gotest := goTool ("test" , buildFlags (env )... )
303302 // Test a single package at a time. CI builders are slow
@@ -306,36 +305,26 @@ func doTest(cmdline []string) {
306305 if * coverage {
307306 gotest .Args = append (gotest .Args , "-covermode=atomic" , "-cover" )
308307 }
308+
309309 gotest .Args = append (gotest .Args , packages ... )
310310 build .MustRun (gotest )
311311}
312312
313- // spellcheck runs the client9/misspell spellchecker package on all Go, Cgo and
314- // test files in the requested packages.
315- func spellcheck (packages []string ) {
316- // Ensure the spellchecker is available
317- build .MustRun (goTool ("get" , "github.com/client9/misspell/cmd/misspell" ))
313+ // runs gometalinter on requested packages
314+ func doLint (cmdline []string ) {
315+ flag .CommandLine .Parse (cmdline )
318316
319- // Windows chokes on long argument lists, check packages individually
320- for _ , pkg := range packages {
321- // The spell checker doesn't work on packages, gather all .go files for it
322- out , err := goTool ("list" , "-f" , "{{.Dir}}{{range .GoFiles}}\n {{.}}{{end}}{{range .CgoFiles}}\n {{.}}{{end}}{{range .TestGoFiles}}\n {{.}}{{end}}" , pkg ).CombinedOutput ()
323- if err != nil {
324- log .Fatalf ("source file listing failed: %v\n %s" , err , string (out ))
325- }
326- // Retrieve the folder and assemble the source list
327- lines := strings .Split (string (out ), "\n " )
328- root := lines [0 ]
329-
330- sources := make ([]string , 0 , len (lines )- 1 )
331- for _ , line := range lines [1 :] {
332- if line = strings .TrimSpace (line ); line != "" {
333- sources = append (sources , filepath .Join (root , line ))
334- }
335- }
336- // Run the spell checker for this particular package
337- build .MustRunCommand (filepath .Join (GOBIN , "misspell" ), append ([]string {"-error" }, sources ... )... )
317+ packages := []string {"./..." }
318+ if len (flag .CommandLine .Args ()) > 0 {
319+ packages = flag .CommandLine .Args ()
338320 }
321+ // Get metalinter and install all supported linters
322+ build .MustRun (goTool ("get" , "gopkg.in/alecthomas/gometalinter.v1" ))
323+ build .MustRunCommand (filepath .Join (GOBIN , "gometalinter.v1" ), "--install" )
324+
325+ configs := []string {"--vendor" , "--disable-all" , "--enable=vet" } // Add additional linters to the slice with "--enable=linter-name"
326+
327+ build .MustRunCommand (filepath .Join (GOBIN , "gometalinter.v1" ), append (configs , packages ... )... )
339328}
340329
341330// Release Packaging
0 commit comments