Updated linting checks in circleci config and fixed linting issues
Этот коммит содержится в:
родитель
521a9688b9
коммит
d0a28b5a94
6 изменённых файлов: 46 добавлений и 31 удалений
|
@ -15,57 +15,67 @@ executors:
|
||||||
- image: circleci/golang:1.14.0
|
- image: circleci/golang:1.14.0
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
install:
|
fmt:
|
||||||
description: "Install dependencies"
|
description: "Run gofmt"
|
||||||
steps:
|
steps:
|
||||||
- run: GO111MODULE=on go mod vendor -v
|
- run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
|
||||||
|
lint:
|
||||||
|
description: "Run golint"
|
||||||
|
steps:
|
||||||
|
- run: go get -u golang.org/x/lint/golint
|
||||||
|
- run: golint -set_exit_status ./...
|
||||||
|
- run: cd _examples && golint -set_exit_status ./... && cd ..
|
||||||
|
install:
|
||||||
|
description: "Install dependencies for go1.12"
|
||||||
|
steps:
|
||||||
|
- run: GO111MODULE=on go mod vendor
|
||||||
vet:
|
vet:
|
||||||
description: "Run go vet"
|
description: "Run go vet"
|
||||||
steps:
|
steps:
|
||||||
- run: go vet github.com/cucumber/godog
|
- run: go vet github.com/cucumber/godog
|
||||||
- run: go vet github.com/cucumber/godog/colors
|
- run: go vet github.com/cucumber/godog/colors
|
||||||
fmt:
|
go_test:
|
||||||
description: "Run go fmt"
|
description: "Run go test"
|
||||||
steps:
|
steps:
|
||||||
- run: test -z "$(go fmt ./...)"
|
- run: go test -v -race -coverprofile=coverage.txt -covermode=atomic
|
||||||
lint:
|
|
||||||
description: "Run golint"
|
|
||||||
steps:
|
|
||||||
- run: go get -u golang.org/x/lint/golint
|
|
||||||
- run: golint ./godog
|
|
||||||
- run: golint ./cmd/godog/main.go
|
|
||||||
godog:
|
godog:
|
||||||
description: "Run godog"
|
description: "Run godog"
|
||||||
steps:
|
steps:
|
||||||
- run: go install ./cmd/godog
|
- run: go install ./cmd/godog
|
||||||
- run: godog -f progress --strict
|
- run: godog -f progress --strict
|
||||||
go_test:
|
|
||||||
description: "Run go test"
|
|
||||||
steps:
|
|
||||||
- run: go test -v -race -coverprofile=coverage.txt -covermode=atomic
|
|
||||||
coverage:
|
coverage:
|
||||||
description: "Report on code coverage"
|
description: "Report on code coverage"
|
||||||
steps:
|
steps:
|
||||||
- codecov/upload:
|
- codecov/upload:
|
||||||
file: "coverage.txt"
|
file: "coverage.txt"
|
||||||
|
part1:
|
||||||
|
description: "Part1 include all commands that doesn't need dependencies installed"
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- fmt
|
||||||
|
- lint
|
||||||
|
part2:
|
||||||
|
description: "Part2 is the all other commands"
|
||||||
|
steps:
|
||||||
|
- vet
|
||||||
|
- go_test
|
||||||
|
- godog
|
||||||
|
- coverage
|
||||||
all:
|
all:
|
||||||
description: "Run all commands against godog code"
|
description: "Run all commands against godog code"
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- part1
|
||||||
- install
|
- part2
|
||||||
- vet
|
|
||||||
- fmt
|
|
||||||
- lint
|
|
||||||
- godog
|
|
||||||
- go_test
|
|
||||||
- coverage
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
go1_12:
|
go1_12:
|
||||||
working_directory: /go/src/github.com/cucumber/godog
|
working_directory: /go/src/github.com/cucumber/godog
|
||||||
executor: exec_go_1_12
|
executor: exec_go_1_12
|
||||||
steps:
|
steps:
|
||||||
- all
|
- part1
|
||||||
|
- install
|
||||||
|
- part2
|
||||||
go1_13:
|
go1_13:
|
||||||
working_directory: /go/src/github.com/cucumber/godog
|
working_directory: /go/src/github.com/cucumber/godog
|
||||||
executor: exec_go_1_13
|
executor: exec_go_1_13
|
||||||
|
|
|
@ -140,7 +140,6 @@ Since we need a working implementation, we may start by implementing only what i
|
||||||
We only need a number of **godogs** for now. Lets keep it simple.
|
We only need a number of **godogs** for now. Lets keep it simple.
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
/* file: $GOPATH/src/godogs/godogs.go */
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// Godogs available to eat
|
// Godogs available to eat
|
||||||
|
@ -155,7 +154,6 @@ Now lets implement our step definitions, which we can copy from generated
|
||||||
console output snippets in order to test our feature requirements:
|
console output snippets in order to test our feature requirements:
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
/* file: $GOPATH/src/godogs/godogs_test.go */
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -348,8 +346,6 @@ is one of the following:
|
||||||
A more extensive example can be [found here](/_examples/assert-godogs).
|
A more extensive example can be [found here](/_examples/assert-godogs).
|
||||||
|
|
||||||
``` go
|
``` go
|
||||||
/* file: $GOPATH/src/assert-godogs/godogs_test.go */
|
|
||||||
|
|
||||||
func thereShouldBeRemaining(remaining int) error {
|
func thereShouldBeRemaining(remaining int) error {
|
||||||
return assertExpectedAndActual(
|
return assertExpectedAndActual(
|
||||||
assert.Equal, Godogs, remaining,
|
assert.Equal, Godogs, remaining,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* file: $GOPATH/src/godogs/godogs.go */
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// Godogs available to eat
|
// Godogs available to eat
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* file: $GOPATH/src/godogs/godogs.go */
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// Godogs available to eat
|
// Godogs available to eat
|
||||||
|
|
|
@ -26,34 +26,43 @@ func colorize(s interface{}, c color) string {
|
||||||
return fmt.Sprintf("%s[%dm%v%s[0m", ansiEscape, c, s, ansiEscape)
|
return fmt.Sprintf("%s[%dm%v%s[0m", ansiEscape, c, s, ansiEscape)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ColorFunc is a helper type to create colorized strings.
|
||||||
type ColorFunc func(interface{}) string
|
type ColorFunc func(interface{}) string
|
||||||
|
|
||||||
|
// Bold will accept a ColorFunc and return a new ColorFunc
|
||||||
|
// that will make the string bold.
|
||||||
func Bold(fn ColorFunc) ColorFunc {
|
func Bold(fn ColorFunc) ColorFunc {
|
||||||
return ColorFunc(func(input interface{}) string {
|
return ColorFunc(func(input interface{}) string {
|
||||||
return strings.Replace(fn(input), ansiEscape+"[", ansiEscape+"[1;", 1)
|
return strings.Replace(fn(input), ansiEscape+"[", ansiEscape+"[1;", 1)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Green will accept an interface and return a colorized green string.
|
||||||
func Green(s interface{}) string {
|
func Green(s interface{}) string {
|
||||||
return colorize(s, green)
|
return colorize(s, green)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Red will accept an interface and return a colorized green string.
|
||||||
func Red(s interface{}) string {
|
func Red(s interface{}) string {
|
||||||
return colorize(s, red)
|
return colorize(s, red)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cyan will accept an interface and return a colorized green string.
|
||||||
func Cyan(s interface{}) string {
|
func Cyan(s interface{}) string {
|
||||||
return colorize(s, cyan)
|
return colorize(s, cyan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Black will accept an interface and return a colorized green string.
|
||||||
func Black(s interface{}) string {
|
func Black(s interface{}) string {
|
||||||
return colorize(s, black)
|
return colorize(s, black)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Yellow will accept an interface and return a colorized green string.
|
||||||
func Yellow(s interface{}) string {
|
func Yellow(s interface{}) string {
|
||||||
return colorize(s, yellow)
|
return colorize(s, yellow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// White will accept an interface and return a colorized green string.
|
||||||
func White(s interface{}) string {
|
func White(s interface{}) string {
|
||||||
return colorize(s, white)
|
return colorize(s, white)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ type noColors struct {
|
||||||
lastbuf bytes.Buffer
|
lastbuf bytes.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uncolored will accept and io.Writer and return a
|
||||||
|
// new io.Writer that won't include colors.
|
||||||
func Uncolored(w io.Writer) io.Writer {
|
func Uncolored(w io.Writer) io.Writer {
|
||||||
return &noColors{out: w}
|
return &noColors{out: w}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче