build: use build matrix; drop Go <= 1.10 (#629)

This commit is contained in:
Matt Silverlock 2020-09-12 12:32:13 -07:00 committed by GitHub
parent 78ab81e242
commit c3dd95aea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 62 additions and 68 deletions

View File

@ -1,76 +1,70 @@
version: 2.0 version: 2.1
jobs: jobs:
# Base test configuration for Go library tests Each distinct version should "test":
# inherit this base, and override (at least) the container image used. parameters:
"test": &test version:
type: string
default: "latest"
golint:
type: boolean
default: true
modules:
type: boolean
default: true
goproxy:
type: string
default: ""
docker: docker:
- image: circleci/golang:latest - image: "circleci/golang:<< parameters.version >>"
working_directory: /go/src/github.com/gorilla/websocket working_directory: /go/src/github.com/gorilla/websocket
steps: &steps environment:
GO111MODULE: "on"
GOPROXY: "<< parameters.goproxy >>"
steps:
- checkout - checkout
- run: go version - run:
- run: go get -t -v ./... 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
# Only run gofmt, vet & lint against the latest Go version # Only run gofmt, vet & lint against the latest Go version
- run: > - run:
if [[ "$LATEST" = true ]]; then name: "Run golint"
command: >
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then
go get -u golang.org/x/lint/golint go get -u golang.org/x/lint/golint
golint ./... golint ./...
fi fi
- run: > - run:
if [[ "$LATEST" = true ]]; then name: "Run gofmt"
diff -u <(echo -n) <(gofmt -d .) command: >
if [[ << parameters.version >> = "latest" ]]; then
diff -u <(echo -n) <(gofmt -d -e .)
fi fi
- run: > - run:
if [[ "$LATEST" = true ]]; then name: "Run go vet"
go vet -v . command: >
if [[ << parameters.version >> = "latest" ]]; then
go vet -v ./...
fi fi
- run: if [[ "$LATEST" = true ]]; then go vet -v .; fi - run:
- run: go test -v -race ./... name: "Run go test (+ race detector)"
command: >
"latest": go test -v -race ./...
<<: *test
environment:
LATEST: true
"1.12":
<<: *test
docker:
- image: circleci/golang:1.12
"1.11":
<<: *test
docker:
- image: circleci/golang:1.11
"1.10":
<<: *test
docker:
- image: circleci/golang:1.10
"1.9":
<<: *test
docker:
- image: circleci/golang:1.9
"1.8":
<<: *test
docker:
- image: circleci/golang:1.8
"1.7":
<<: *test
docker:
- image: circleci/golang:1.7
workflows: workflows:
version: 2 tests:
build:
jobs: jobs:
- "latest" - test:
- "1.12" matrix:
- "1.11" parameters:
- "1.10" version: ["latest", "1.15", "1.14", "1.13", "1.12", "1.11"]
- "1.9"
- "1.8"
- "1.7"