From e4181a7f1b9783c27cf2fc6a54a50da28a3b9e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 13 Jan 2017 10:53:43 +0200 Subject: [PATCH 1/4] travis, appveyor, build: add source spell checking --- .travis.yml | 2 +- appveyor.yml | 2 +- build/ci.go | 25 ++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d13b77c17..baa5db7ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,7 +90,7 @@ install: - go get golang.org/x/tools/cmd/cover script: - go run build/ci.go install - - go run build/ci.go test -coverage -vet + - go run build/ci.go test -coverage -vet -misspell notifications: webhooks: diff --git a/appveyor.yml b/appveyor.yml index f5115f6f9..4bc1a21f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,4 +36,4 @@ after_build: test_script: - set CGO_ENABLED=1 - - go run build\ci.go test -vet -coverage + - go run build\ci.go test -vet -coverage -misspell diff --git a/build/ci.go b/build/ci.go index d530c24ca..31c4885a3 100644 --- a/build/ci.go +++ b/build/ci.go @@ -24,7 +24,7 @@ Usage: go run ci.go Available commands are: install [-arch architecture] [ packages... ] -- builds packages and executables - test [ -coverage ] [ -vet ] [ packages... ] -- runs the tests + test [ -coverage ] [ -vet ] [ -misspell] [ packages... ] -- runs the tests 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 @@ -262,6 +262,7 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd { func doTest(cmdline []string) { var ( vet = flag.Bool("vet", false, "Whether to run go vet") + 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) @@ -287,7 +288,29 @@ func doTest(cmdline []string) { if *vet { build.MustRun(goTool("vet", packages...)) } + if *misspell { + // The spell checker doesn't work on packages, gather all .go files for it + sources := []string{} + for _, pkg := range packages { + // Gather all the source files of the package + 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] + for _, line := range lines[1:] { + if line = strings.TrimSpace(line); line != "" { + sources = append(sources, filepath.Join(root, line)) + } + } + } + // Download the spell checker tool and run on all source files + build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell")) + build.MustRunCommand(filepath.Join(GOBIN, "misspell"), append([]string{"-error"}, sources...)...) + } // Run the actual tests. gotest := goTool("test") // Test a single package at a time. CI builders are slow From c01f8c3d3c286244292718133544e17be32000cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 13 Jan 2017 11:14:47 +0200 Subject: [PATCH 2/4] accounts/abi: fix comment spelling error --- accounts/abi/type.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/abi/type.go b/accounts/abi/type.go index ed3e33f39..f2832aef5 100644 --- a/accounts/abi/type.go +++ b/accounts/abi/type.go @@ -91,7 +91,7 @@ func NewType(t string) (typ Type, err error) { } typ.Elem = &sliceType typ.stringKind = sliceType.stringKind + t[len(res[1]):] - // Altough we know that this is an array, we cannot return + // Although we know that this is an array, we cannot return // as we don't know the type of the element, however, if it // is still an array, then don't determine the type. if typ.Elem.IsArray || typ.Elem.IsSlice { From a2bc90d1d7ec796e51d8783a97558dfa4f2e7f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 13 Jan 2017 11:22:24 +0200 Subject: [PATCH 3/4] build: spellcheck individual packages (Windows path limits) --- build/ci.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/build/ci.go b/build/ci.go index 31c4885a3..152c86d1b 100644 --- a/build/ci.go +++ b/build/ci.go @@ -289,27 +289,29 @@ func doTest(cmdline []string) { build.MustRun(goTool("vet", packages...)) } if *misspell { - // The spell checker doesn't work on packages, gather all .go files for it - sources := []string{} + // Ensure the spellchecker is available + build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell")) + + // Windows (AppVeyor) chokes on long argument lists, check packages individualy for _, pkg := range packages { - // Gather all the source files of the package + // 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...)...) } - // Download the spell checker tool and run on all source files - build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell")) - build.MustRunCommand(filepath.Join(GOBIN, "misspell"), append([]string{"-error"}, sources...)...) } // Run the actual tests. gotest := goTool("test") From 54fcab20e30cdae23809deb371f120b5ba47d258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 13 Jan 2017 11:54:17 +0200 Subject: [PATCH 4/4] appveyor, build: fix review requests --- appveyor.yml | 2 +- build/ci.go | 54 +++++++++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4bc1a21f8..f5115f6f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,4 +36,4 @@ after_build: test_script: - set CGO_ENABLED=1 - - go run build\ci.go test -vet -coverage -misspell + - go run build\ci.go test -vet -coverage diff --git a/build/ci.go b/build/ci.go index 152c86d1b..a3213e7c9 100644 --- a/build/ci.go +++ b/build/ci.go @@ -24,7 +24,7 @@ Usage: go run ci.go Available commands are: install [-arch architecture] [ packages... ] -- builds packages and executables - test [ -coverage ] [ -vet ] [ -misspell] [ packages... ] -- runs the tests + test [ -coverage ] [ -vet ] [ -misspell ] [ packages... ] -- runs the tests 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 @@ -289,29 +289,7 @@ func doTest(cmdline []string) { build.MustRun(goTool("vet", packages...)) } if *misspell { - // Ensure the spellchecker is available - build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell")) - - // Windows (AppVeyor) chokes on long argument lists, check packages individualy - 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...)...) - } + spellcheck(packages) } // Run the actual tests. gotest := goTool("test") @@ -325,6 +303,34 @@ func doTest(cmdline []string) { 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")) + + // Windows chokes on long argument lists, check packages individualy + 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...)...) + } +} + // Release Packaging func doArchive(cmdline []string) {