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
- checkout
- run: go version
- run: go get -t -v ./...
# Only run gofmt, vet & lint against the latest Go version
- run: >
if [[ "$LATEST" = true ]]; then
go get -u golang.org/x/lint/golint
golint ./...
fi
- run: >
if [[ "$LATEST" = true ]]; then
diff -u <(echo -n) <(gofmt -d .)
fi
- run: >
if [[ "$LATEST" = true ]]; then
go vet -v .
fi
- run: if [[ "$LATEST" = true ]]; then go vet -v .; fi
- run: go test -v -race ./...
"latest":
<<: *test
environment: environment:
LATEST: true GO111MODULE: "on"
GOPROXY: "<< parameters.goproxy >>"
"1.12": steps:
<<: *test - checkout
docker: - run:
- image: circleci/golang:1.12 name: "Print the Go version"
command: >
"1.11": go version
<<: *test - run:
docker: name: "Fetch dependencies"
- image: circleci/golang:1.11 command: >
if [[ << parameters.modules >> = true ]]; then
"1.10": go mod download
<<: *test export GO111MODULE=on
docker: else
- image: circleci/golang:1.10 go get -v ./...
fi
"1.9": # Only run gofmt, vet & lint against the latest Go version
<<: *test - run:
docker: name: "Run golint"
- image: circleci/golang:1.9 command: >
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then
"1.8": go get -u golang.org/x/lint/golint
<<: *test golint ./...
docker: fi
- image: circleci/golang:1.8 - run:
name: "Run gofmt"
"1.7": command: >
<<: *test if [[ << parameters.version >> = "latest" ]]; then
docker: diff -u <(echo -n) <(gofmt -d -e .)
- image: circleci/golang:1.7 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 ./...
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"