diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-01-13 16:53:43 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-01-13 17:14:13 +0800 |
commit | e4181a7f1b9783c27cf2fc6a54a50da28a3b9e0b (patch) | |
tree | d07486743c2a43cd2a7ba5bd1ac310141ae57a5f | |
parent | c5df37c1119107ddcc517127b3bd7c2ab4e3649f (diff) | |
download | go-tangerine-e4181a7f1b9783c27cf2fc6a54a50da28a3b9e0b.tar.gz go-tangerine-e4181a7f1b9783c27cf2fc6a54a50da28a3b9e0b.tar.zst go-tangerine-e4181a7f1b9783c27cf2fc6a54a50da28a3b9e0b.zip |
travis, appveyor, build: add source spell checking
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | appveyor.yml | 2 | ||||
-rw-r--r-- | 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 <command> <command flags/arguments> 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 |