Skip to content

Commit 3e03024

Browse files
authored
build: CircleCI 2.1 + build matrix (#199)
* build: CircleCI 2.1 + build matrix * Update config.yml
1 parent d453eff commit 3e03024

File tree

1 file changed

+62
-61
lines changed

1 file changed

+62
-61
lines changed

.circleci/config.yml

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +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/handlers
10-
steps: &steps
11-
- checkout
12-
- run: go version
13-
- run: go get -t -v ./...
14-
- run: >
15-
if [[ "$LATEST" = true ]]; then
16-
diff -u <(echo -n) <(gofmt -d .)
17-
fi
18-
- run: >
19-
if [[ "$LATEST" = true ]]; then
20-
go vet -v .
21-
fi
22-
- run: go test -v -race ./...
23-
24-
"latest":
25-
<<: *test
2621
environment:
27-
LATEST: true
28-
29-
"1.12":
30-
<<: *test
31-
docker:
32-
- image: circleci/golang:1.12
33-
34-
"1.11":
35-
<<: *test
36-
docker:
37-
- image: circleci/golang:1.11
38-
39-
"1.10":
40-
<<: *test
41-
docker:
42-
- image: circleci/golang:1.10
43-
44-
"1.9":
45-
<<: *test
46-
docker:
47-
- image: circleci/golang:1.9
48-
49-
"1.8":
50-
<<: *test
51-
docker:
52-
- image: circleci/golang:1.8
53-
54-
"1.7":
55-
<<: *test
56-
docker:
57-
- image: circleci/golang:1.7
22+
GO111MODULE: "on"
23+
GOPROXY: "<< parameters.goproxy >>"
24+
steps:
25+
- checkout
26+
- run:
27+
name: "Print the Go version"
28+
command: >
29+
go version
30+
- run:
31+
name: "Fetch dependencies"
32+
command: >
33+
if [[ << parameters.modules >> = true ]]; then
34+
go mod download
35+
export GO111MODULE=on
36+
else
37+
go get -v ./...
38+
fi
39+
# Only run gofmt, vet & lint against the latest Go version
40+
- run:
41+
name: "Run golint"
42+
command: >
43+
if [ << parameters.version >> = "latest" ] && [ << parameters.golint >> = true ]; then
44+
go get -u golang.org/x/lint/golint
45+
golint ./...
46+
fi
47+
- run:
48+
name: "Run gofmt"
49+
command: >
50+
if [[ << parameters.version >> = "latest" ]]; then
51+
diff -u <(echo -n) <(gofmt -d -e .)
52+
fi
53+
- run:
54+
name: "Run go vet"
55+
command: >
56+
if [[ << parameters.version >> = "latest" ]]; then
57+
go vet -v ./...
58+
fi
59+
- run:
60+
name: "Run go test (+ race detector)"
61+
command: >
62+
go test -v -race ./...
5863
5964
workflows:
60-
version: 2
61-
build:
65+
tests:
6266
jobs:
63-
- "latest"
64-
- "1.12"
65-
- "1.11"
66-
- "1.10"
67-
- "1.9"
68-
- "1.8"
69-
- "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)