Skip to content

Commit

Permalink
DRY the CI config (#6)
Browse files Browse the repository at this point in the history
* DRY the CI config
* Update config.yml
* Update config.yml
  • Loading branch information
elithrar authored Jul 11, 2019
1 parent 346b9fc commit ab0fe2a
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
version: 2.0
version: 2.1

jobs:
# Base test configuration for Go library tests Each distinct version should
# inherit this base, and override (at least) the container image used.
"test-and-build": &test-and-build
"test": &test
parameters:
v:
type: string
default: "latest"
latest:
type: boolean
default: false
docker:
- image: circleci/golang:latest
- image: "circleci/golang:<< parameters.v >>"
working_directory: /go/src/github.com/elithrar/admission-control
environment:
GO111MODULE: "on"
LATEST: "<< parameters.latest >>"
steps:
- checkout
- run: go version
- run:
name: "Print the Go version"
command: >
go version
- run:
name: "Fetch dependencies"
command: go mod download
Expand All @@ -35,19 +46,10 @@ jobs:
if [[ "${LATEST}" = true ]]; then
go vet -v ./...
fi
- run: go test -v -race ./...
- run: go build -v

"latest":
<<: *test-and-build
environment:
LATEST: "true"
GO111MODULE: "on"

"1.12":
<<: *test-and-build
docker:
- image: circleci/golang:1.12
- run:
name: "Run go test (+ race detector)"
command: >
go test -v -race ./...
"build-container": &build-container
docker:
Expand All @@ -56,15 +58,25 @@ jobs:
steps:
- checkout
- setup_remote_docker
- run: docker version
- run: docker build -t elithrar/admissiond .
- run:
name: "Print the Docker version"
command: >
docker version
- run:
name: "Build the container image"
command: >
docker build -t elithrar/admissiond-example .
workflows:
version: 2
build:
jobs:
- "latest"
- "1.12"
- test:
name: "latest"
v: "latest"
latest: true
- test:
name: "Go 1.12"
v: "1.12"
- "build-container":
requires:
- "latest"

0 comments on commit ab0fe2a

Please sign in to comment.