Skip to content

Commit d07530f

Browse files
authored
build: CircleCI 2.1 + build matrix (gorilla#595)
* build: CircleCI 2.1 + build matrix * build: drop Go 1.9 & Go 1.10 * build: remove erroneous version
1 parent 98cb6bf commit d07530f

File tree

1 file changed

+43
-60
lines changed

1 file changed

+43
-60
lines changed

.circleci/config.yml

+43-60
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,70 @@
1-
version: 2.0
1+
version: 2.1
22

33
jobs:
4-
# Base test configuration for Go library tests Each distinct version should
5-
# inherit this base, and override (at least) the container image used.
6-
"test": &test
4+
"test":
5+
parameters:
6+
version:
7+
type: string
8+
default: "latest"
9+
golint:
10+
type: boolean
11+
default: true
12+
modules:
13+
type: boolean
14+
default: true
15+
goproxy:
16+
type: string
17+
default: ""
718
docker:
8-
- image: circleci/golang:latest
19+
- image: "circleci/golang:<< parameters.version >>"
920
working_directory: /go/src/github.com/gorilla/mux
10-
steps: &steps
11-
# Our build steps: we checkout the repo, fetch our deps, lint, and finally
12-
# run "go test" on the package.
21+
environment:
22+
GO111MODULE: "on"
23+
GOPROXY: "<< parameters.goproxy >>"
24+
steps:
1325
- checkout
14-
# Logs the version in our build logs, for posterity
15-
- run: go version
26+
- run:
27+
name: "Print the Go version"
28+
command: >
29+
go version
1630
- run:
1731
name: "Fetch dependencies"
1832
command: >
19-
go get -t -v ./...
33+
if [[ << parameters.modules >> = true ]]; then
34+
go mod download
35+
export GO111MODULE=on
36+
else
37+
go get -v ./...
38+
fi
2039
# Only run gofmt, vet & lint against the latest Go version
2140
- run:
2241
name: "Run golint"
2342
command: >
24-
if [ "${LATEST}" = true ] && [ -z "${SKIP_GOLINT}" ]; then
43+
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then
2544
go get -u golang.org/x/lint/golint
2645
golint ./...
2746
fi
2847
- run:
2948
name: "Run gofmt"
3049
command: >
31-
if [[ "${LATEST}" = true ]]; then
50+
if [[ << parameters.version >> = "latest" ]]; then
3251
diff -u <(echo -n) <(gofmt -d -e .)
3352
fi
3453
- run:
3554
name: "Run go vet"
36-
command: >
37-
if [[ "${LATEST}" = true ]]; then
55+
command: >
56+
if [[ << parameters.version >> = "latest" ]]; then
3857
go vet -v ./...
3958
fi
40-
- run: go test -v -race ./...
41-
42-
"latest":
43-
<<: *test
44-
environment:
45-
LATEST: true
46-
47-
"1.12":
48-
<<: *test
49-
docker:
50-
- image: circleci/golang:1.12
51-
52-
"1.11":
53-
<<: *test
54-
docker:
55-
- image: circleci/golang:1.11
56-
57-
"1.10":
58-
<<: *test
59-
docker:
60-
- image: circleci/golang:1.10
61-
62-
"1.9":
63-
<<: *test
64-
docker:
65-
- image: circleci/golang:1.9
66-
67-
"1.8":
68-
<<: *test
69-
docker:
70-
- image: circleci/golang:1.8
71-
72-
"1.7":
73-
<<: *test
74-
docker:
75-
- image: circleci/golang:1.7
59+
- run:
60+
name: "Run go test (+ race detector)"
61+
command: >
62+
go test -v -race ./...
7663
7764
workflows:
78-
version: 2
79-
build:
65+
tests:
8066
jobs:
81-
- "latest"
82-
- "1.12"
83-
- "1.11"
84-
- "1.10"
85-
- "1.9"
86-
- "1.8"
87-
- "1.7"
67+
- test:
68+
matrix:
69+
parameters:
70+
version: ["latest", "1.15", "1.14", "1.13", "1.12", "1.11"]

0 commit comments

Comments
 (0)