Skip to content

Commit

Permalink
Updated linting checks in circleci config and fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnblad committed May 3, 2020
1 parent 521a968 commit 29866ae
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
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
15 changes: 15 additions & 0 deletions colors/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,49 @@ 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 a ColorFunc and return a new ColorFunc
// that will make the string green.
func Green(s interface{}) string {
return colorize(s, green)
}

// Red will accept a ColorFunc and return a new ColorFunc
// that will make the string red.
func Red(s interface{}) string {
return colorize(s, red)
}

// Cyan will accept a ColorFunc and return a new ColorFunc
// that will make the string cyan.
func Cyan(s interface{}) string {
return colorize(s, cyan)
}

// Black will accept a ColorFunc and return a new ColorFunc
// that will make the string black.
func Black(s interface{}) string {
return colorize(s, black)
}

// Yellow will accept a ColorFunc and return a new ColorFunc
// that will make the string yellow.
func Yellow(s interface{}) string {
return colorize(s, yellow)
}

// White will accept a ColorFunc and return a new ColorFunc
// that will make the string white.
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

0 comments on commit 29866ae

Please sign in to comment.