Skip to content

Commit

Permalink
Merge pull request #48 from dnephin/use-orbs
Browse files Browse the repository at this point in the history
Use orbs in CI config
  • Loading branch information
dnephin committed Mar 12, 2019
2 parents c800bc8 + 2259c56 commit 4caef0e
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 201 deletions.
188 changes: 100 additions & 88 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,123 @@
version: 2
version: 2.1

jobs:
orbs:
go: gotest/tools@0.0.8

workflows:
version: 2
ci:
jobs:
- test-go-1-10:
name: test-go-1.10

- go/test:
name: test-go-1.11
gotestsum-format: short-verbose
executor:
name: go/golang
tag: 1.11-alpine

- go/test:
name: test-go-1.12
gotestsum-format: short-verbose
executor:
name: go/golang
tag: 1.12-alpine

- go/lint
- build
- run

lint:
working_directory: /work
docker: [{image: 'docker:18.03-git'}]
- build:
name: release
publish: true
filters:
tags: {only: '/v[0-9]+(\.[0-9]+)*/'}
branches: {ignore: '/.*/'}

commands:
install-deps:
description: Install dep and dependencies
steps:
- checkout
- setup_remote_docker
- run:
command: docker version
- run:
name: "Install Dependencies"
name: Install dep
command: |
docker build -f dobifiles/Dockerfile \
--target dev-with-source \
--tag testsum-builder:$CIRCLE_BUILD_NUM .
docker run --name \
deps-$CIRCLE_BUILD_NUM testsum-builder:$CIRCLE_BUILD_NUM \
dep ensure
docker cp \
deps-$CIRCLE_BUILD_NUM:/go/src/gotest.tools/gotestsum/vendor \
.
command -v dep && exit
wget -O- -q https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- run:
name: "Lint"
command: |
docker build -f dobifiles/Dockerfile \
--target linter-with-source \
--tag testsum-linter:$CIRCLE_BUILD_NUM .
docker run --rm testsum-linter:$CIRCLE_BUILD_NUM
name: Install dependencies
command: dep ensure

test-golang-1.10:
working_directory: /work
docker: [{image: 'docker:17.06-git'}]
install-goreleaser:
description: Install goreleaser
steps:
- checkout
- setup_remote_docker
- run:
name: "Unit Test GO 1.10"
name: Install goreleaser
command: |
scripts/ci/test 1.10.3-alpine
mkdir -p junit/gotest
docker cp \
test-$CIRCLE_BUILD_NUM:/go/src/gotest.tools/gotestsum/junit.xml \
junit/gotest/junit.xml
command -v goreleaser && exit
wget -O- -q https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
- store_test_results:
path: junit/
jobs:

test-golang-1.11:
working_directory: /work
docker: [{image: 'docker:17.06-git'}]
build:
parameters:
publish:
type: boolean
default: false
executor: go/golang
steps:
- go/install-git
- go/install-ssh
- checkout
- setup_remote_docker
- run:
name: "Unit Test GO 1.11"
command: |
scripts/ci/test 1.11-alpine
mkdir -p junit/gotest
docker cp \
test-$CIRCLE_BUILD_NUM:/go/src/gotest.tools/gotestsum/junit.xml \
junit/gotest/junit.xml
- store_test_results:
path: junit/
- go/mod-download
- go/mod-tidy-check
- install-goreleaser
- unless:
condition: << parameters.publish >>
steps:
run:
name: build binaries
command: bin/goreleaser --rm-dist --snapshot
- when:
condition: << parameters.publish >>
steps:
run:
name: build and publish binaries
command: bin/goreleaser --rm-dist --skip-validate
- store_artifacts:
path: ./dist
destination: dist

test-golang-1.12:
working_directory: /work
docker: [{image: 'docker:17.06-git'}]
test-go-1-10:
executor:
name: go/golang
tag: 1.10-alpine
working_directory: /go/src/gotest.tools/gotestsum
steps:
- go/install-git
- go/install-ssh
- checkout
- setup_remote_docker
- go/install-gotestsum
- install-deps
- run:
name: "Unit Test GO 1.12"
name: go test
environment:
GOTESTSUM_JUNITFILE: /tmp/test-reports/unit/junit.xml
GOTESTSUM_FORMAT: short-verbose
command: |
scripts/ci/test 1.12rc1-alpine
mkdir -p junit/gotest
docker cp \
test-$CIRCLE_BUILD_NUM:/go/src/gotest.tools/gotestsum/junit.xml \
junit/gotest/junit.xml
mkdir -p /tmp/test-reports/unit
gotestsum
- store_test_results:
path: junit/
path: /tmp/test-reports

release:
docker: [{image: 'circleci/golang:1.11'}]
working_directory: /go/src/gotest.tools/gotestsum
run:
executor: go/golang
steps:
- go/install-git
- go/install-ssh
- checkout
- deploy:
name: "release"
command: |
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
go get github.com/goreleaser/goreleaser
goreleaser --rm-dist --skip-validate
workflows:
version: 2
ci:
jobs:
- lint
- test-golang-1.10
- test-golang-1.11
- test-golang-1.12
- release:
filters:
tags: {only: '/v[0-9]+(\.[0-9]+)*/'}
branches: {ignore: '/.*/'}
- go/mod-download
- run: |
mkdir -p dist
go build -o dist/gotestsum .
- run: dist/gotestsum
39 changes: 39 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
linters-settings:
gocyclo:
min-complexity: 10
goconst:
min-len: 2
min-occurrences: 4
lll:
line-length: 100
gocritic:
enabled-tags:
- diagnostic
- performance
- style
- experimental
disabled-checks:
- importShadow
- paramTypeCombine
- commentFormatting # https://github.com/go-critic/go-critic/issues/755
- unnamedResult
settings:
hugeParam:
sizeThreshold: 256

issues:
exclude-use-default: false
exclude:
# unparam
- 'result .* is always'
- 'always receives'

linters:
enable-all: true
disable:
- dupl
- gochecknoglobals
- gochecknoinits
- gosec
- scopelint
- maligned
31 changes: 0 additions & 31 deletions .gometalinter.json

This file was deleted.

37 changes: 16 additions & 21 deletions dobi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ mount=source:
bind: .
path: /go/src/gotest.tools/gotestsum

mount=depsources:
bind: ./.depsources
path: /go/pkg/dep/sources
mount=buildcache:
bind: ~/.cache/go-build
path: /root/.cache/go-build

mount=modcache:
bind: ~/go/pkg/mod
path: /go/pkg/mod

image=builder:
image: gotestsum-dev
Expand All @@ -17,45 +21,36 @@ image=builder:
args:
GOLANG_VERSION: '{env.GOLANG_VERSION:}'

image=linter:
image: gotestsum-lint
context: dobifiles/
dockerfile: Dockerfile
target: linter

job=shell:
use: builder
mounts: [source, depsources]
mounts: [source, buildcache, modcache]
interactive: true
command: sh

job=watch:
use: builder
mounts: [source]
mounts: [source, buildcache, modcache]
interactive: true
command: |
filewatcher -x vendor ./dist/gotestsum -- -test.timeout 10s
env: ['GOTESTSUM_FORMAT=short-verbose']
depends: [binary]

job=test-unit:
use: builder
mounts: [source]
mounts: [source, buildcache, modcache]
interactive: true
command: scripts/test-unit

job=deps:
use: builder
mounts: [source, depsources]
command: dep ensure

job=lint:
use: linter
mounts: [source]
use: builder
mounts: [source, buildcache, modcache]
command: golangci-lint run

job=binary:
use: builder
mounts: [source]
command: scripts/build
mounts: [source, buildcache, modcache]
command: bash -c 'mkdir -p dist; go build -o dist/gotestsum .'

alias=test:
tasks: [test-unit]
Loading

0 comments on commit 4caef0e

Please sign in to comment.