Skip to content

Instantly share code, notes, and snippets.

@d-kuro
Last active October 9, 2019 05:27
Show Gist options
  • Save d-kuro/664bdc199ad8c95bbde8f9259e168f39 to your computer and use it in GitHub Desktop.
Save d-kuro/664bdc199ad8c95bbde8f9259e168f39 to your computer and use it in GitHub Desktop.
Golang CircieCI config
version: 2.1
executors:
build:
parameters:
go-version:
type: string
docker:
- image: circleci/golang:<< parameters.go-version >>
environment:
GO111MODULE: "on"
working_directory: /go/src/d-kuro/go-sandbox
commands:
go_mod_download:
steps:
- restore_cache:
name: Restore go modules cache
keys:
- go-modules-{{ checksum "go.sum" }}
- run: go mod download
- save_cache:
name: Save go modules cache
key: go-modules-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
jobs:
build:
parameters:
go-version:
type: string
golangci-lint-version:
type: string
executor:
name: build
go-version: << parameters.go-version >>
steps:
- checkout
- go_mod_download
- run:
name: Install GolangCI-Lint
command: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v<< parameters.golangci-lint-version >>
- run:
name: Run GolangCI-Lint
command: ./bin/golangci-lint run --tests --disable-all --enable=goimports --enable=golint --enable=govet --enable=errcheck --enable=staticcheck
- run:
name: Run Tests
command: go test -race -v ./...
workflows:
golang-workflow:
jobs:
- build:
go-version: "1.11.5"
golangci-lint-version: "1.15.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment