2020-09-12 22:32:13 +03:00
|
|
|
version: 2.1
|
2019-06-29 21:55:28 +03:00
|
|
|
|
|
|
|
jobs:
|
2020-09-12 22:32:13 +03:00
|
|
|
"test":
|
|
|
|
parameters:
|
|
|
|
version:
|
|
|
|
type: string
|
|
|
|
default: "latest"
|
|
|
|
golint:
|
|
|
|
type: boolean
|
|
|
|
default: true
|
|
|
|
modules:
|
|
|
|
type: boolean
|
|
|
|
default: true
|
|
|
|
goproxy:
|
|
|
|
type: string
|
|
|
|
default: ""
|
2019-06-29 21:55:28 +03:00
|
|
|
docker:
|
2020-09-12 22:32:13 +03:00
|
|
|
- image: "circleci/golang:<< parameters.version >>"
|
2019-06-29 21:55:28 +03:00
|
|
|
working_directory: /go/src/github.com/gorilla/websocket
|
2020-09-12 22:32:13 +03:00
|
|
|
environment:
|
|
|
|
GO111MODULE: "on"
|
|
|
|
GOPROXY: "<< parameters.goproxy >>"
|
|
|
|
steps:
|
2019-06-29 21:55:28 +03:00
|
|
|
- checkout
|
2020-09-12 22:32:13 +03:00
|
|
|
- run:
|
|
|
|
name: "Print the Go version"
|
|
|
|
command: >
|
|
|
|
go version
|
|
|
|
- run:
|
|
|
|
name: "Fetch dependencies"
|
|
|
|
command: >
|
|
|
|
if [[ << parameters.modules >> = true ]]; then
|
|
|
|
go mod download
|
|
|
|
export GO111MODULE=on
|
|
|
|
else
|
|
|
|
go get -v ./...
|
|
|
|
fi
|
2019-06-29 21:55:28 +03:00
|
|
|
# Only run gofmt, vet & lint against the latest Go version
|
2020-09-12 22:32:13 +03:00
|
|
|
- run:
|
|
|
|
name: "Run golint"
|
|
|
|
command: >
|
|
|
|
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then
|
|
|
|
go get -u golang.org/x/lint/golint
|
|
|
|
golint ./...
|
|
|
|
fi
|
|
|
|
- run:
|
|
|
|
name: "Run gofmt"
|
|
|
|
command: >
|
|
|
|
if [[ << parameters.version >> = "latest" ]]; then
|
|
|
|
diff -u <(echo -n) <(gofmt -d -e .)
|
|
|
|
fi
|
|
|
|
- run:
|
|
|
|
name: "Run go vet"
|
|
|
|
command: >
|
|
|
|
if [[ << parameters.version >> = "latest" ]]; then
|
|
|
|
go vet -v ./...
|
|
|
|
fi
|
|
|
|
- run:
|
|
|
|
name: "Run go test (+ race detector)"
|
|
|
|
command: >
|
|
|
|
go test -v -race ./...
|
2019-06-29 21:55:28 +03:00
|
|
|
|
|
|
|
workflows:
|
2020-09-12 22:32:13 +03:00
|
|
|
tests:
|
2019-06-29 21:55:28 +03:00
|
|
|
jobs:
|
2020-09-12 22:32:13 +03:00
|
|
|
- test:
|
|
|
|
matrix:
|
|
|
|
parameters:
|
2022-01-01 19:43:22 +03:00
|
|
|
version: ["latest", "1.17", "1.16", "1.15", "1.14", "1.13", "1.12", "1.11"]
|