Skip to content

Instantly share code, notes, and snippets.

@hrdtbs
Last active September 15, 2019 05:33
Show Gist options
  • Save hrdtbs/54dae9cbae6d8a357f8544cbe164eee8 to your computer and use it in GitHub Desktop.
Save hrdtbs/54dae9cbae6d8a357f8544cbe164eee8 to your computer and use it in GitHub Desktop.
Release & Lint & Test | Golang CircleCI
version: 2.1
executors:
golang:
docker:
- image: circleci/golang:latest
environment:
GO111MODULE: "on"
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:
release:
executor:
name: golang
steps:
- checkout
- go_mod_download
- run:
name: run goreleaser
command: curl -sL https://git.io/goreleaser | bash
test:
executor:
name: golang
steps:
- checkout
- go_mod_download
- run:
name: Run Tests
command: go test -race -v ./...
lint:
executor:
name: golang
steps:
- checkout
- go_mod_download
- run:
name: Install xtag
command: |-
# https://github.com/goreleaser/godownloader/issues/92
curl -sfL https://raw.githubusercontent.com/haya14busa/xtag/master/install.sh| sh -s
mv ./bin/xtag $(go env GOPATH)/bin
- run:
name: Install GolangCI-Lint
command: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s $(xtag golangci/golangci-lint v1.x)
- run:
name: Run GolangCI-Lint
command: ./bin/golangci-lint run --tests
workflows:
golang-workflow:
jobs:
- lint:
filters:
branch:
ignore: master
- test:
filters:
branch:
ignore: master
- release:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment