Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated linting checks in circleci config and fixed linting issues #290

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,67 @@ executors:
- image: circleci/golang:1.14.0

commands:
fmt:
description: "Run gofmt"
steps:
- 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"
description: "Install dependencies for go1.12"
steps:
- run: GO111MODULE=on go mod vendor -v
- run: GO111MODULE=on go mod vendor
vet:
description: "Run go vet"
steps:
- run: go vet github.com/cucumber/godog
- run: go vet github.com/cucumber/godog/colors
fmt:
description: "Run go fmt"
steps:
- run: test -z "$(go fmt ./...)"
lint:
description: "Run golint"
go_test:
description: "Run go test"
steps:
- run: go get -u golang.org/x/lint/golint
- run: golint ./godog
- run: golint ./cmd/godog/main.go
- run: go test -v -race -coverprofile=coverage.txt -covermode=atomic
godog:
description: "Run godog"
steps:
- run: go install ./cmd/godog
- run: godog -f progress --strict
go_test:
description: "Run go test"
steps:
- run: go test -v -race -coverprofile=coverage.txt -covermode=atomic
coverage:
description: "Report on code coverage"
steps:
- codecov/upload:
file: "coverage.txt"
all:
description: "Run all commands against godog code"
part1:
description: "Part1 include all commands that doesn't need dependencies installed"
steps:
- checkout
- install
- vet
- fmt
- lint
- godog
part2:
description: "Part2 is the all other commands"
steps:
- vet
- go_test
- godog
- coverage
all:
description: "Run all commands against godog code"
steps:
- part1
- part2


jobs:
go1_12:
working_directory: /go/src/github.com/cucumber/godog
executor: exec_go_1_12
steps:
- all
- part1
- install
- part2
go1_13:
working_directory: /go/src/github.com/cucumber/godog
executor: exec_go_1_13
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

``` go
/* file: $GOPATH/src/godogs/godogs.go */
package main

// Godogs available to eat
Expand All @@ -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:

``` go
/* file: $GOPATH/src/godogs/godogs_test.go */
package main

import (
Expand Down Expand Up @@ -348,8 +346,6 @@ is one of the following:
A more extensive example can be [found here](/_examples/assert-godogs).

``` go
/* file: $GOPATH/src/assert-godogs/godogs_test.go */

func thereShouldBeRemaining(remaining int) error {
return assertExpectedAndActual(
assert.Equal, Godogs, remaining,
Expand Down
1 change: 0 additions & 1 deletion _examples/assert-godogs/godogs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* file: $GOPATH/src/godogs/godogs.go */
package main

// Godogs available to eat
Expand Down
1 change: 0 additions & 1 deletion _examples/godogs/godogs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* file: $GOPATH/src/godogs/godogs.go */
package main

// Godogs available to eat
Expand Down
9 changes: 9 additions & 0 deletions colors/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,43 @@ func colorize(s interface{}, c color) string {
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

// Bold will accept a ColorFunc and return a new ColorFunc
// that will make the string bold.
func Bold(fn ColorFunc) ColorFunc {
return ColorFunc(func(input interface{}) string {
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 {
return colorize(s, green)
}

// Red will accept an interface and return a colorized green string.
func Red(s interface{}) string {
return colorize(s, red)
}

// Cyan will accept an interface and return a colorized green string.
func Cyan(s interface{}) string {
return colorize(s, cyan)
}

// Black will accept an interface and return a colorized green string.
func Black(s interface{}) string {
return colorize(s, black)
}

// Yellow will accept an interface and return a colorized green string.
func Yellow(s interface{}) string {
return colorize(s, yellow)
}

// White will accept an interface and return a colorized green string.
func White(s interface{}) string {
return colorize(s, white)
}
2 changes: 2 additions & 0 deletions colors/no_colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type noColors struct {
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 {
return &noColors{out: w}
}
Expand Down