featurebase/.circleci/config.yml

238 lines
5.9 KiB
YAML

version: 2.1
executors:
golang:
parameters:
version:
type: string
default: "1.14"
docker:
- image: circleci/golang:<< parameters.version >>
working_directory: /go/src/github.com/pilosa/pilosa
environment:
GO111MODULE: "on" # TODO: Only needed for Go <1.13, remove when dropping support for 1.11/1.12.
commands:
add-github-auth:
steps:
- run: git config --global url."https://moleculacorp:${GITHUB_PERSONAL_ACCESS_TOKEN}@github.com".insteadOf "https://github.com"
jobs:
setup:
executor:
name: golang
steps:
- add-github-auth
- checkout
- restore_cache:
keys:
- mod-cache-{{ checksum "go.sum" }}
- run: "go mod download"
- save_cache:
key: mod-cache-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod/
- persist_to_workspace:
root: .
paths: "*"
check-license-headers:
executor:
name: golang
steps:
- attach_workspace:
at: .
- run: make check-license-headers
linter:
executor:
name: golang
steps:
- attach_workspace:
at: .
- add-github-auth
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/bin v1.23.8
- run: make golangci-lint
test-build-arm:
executor:
name: golang
steps:
- attach_workspace:
at: .
- add-github-auth
- run: make build GOOS=linux GOARCH=arm GOARM=5
- run: make build GOOS=linux GOARCH=arm GOARM=6
- run: make build GOOS=linux GOARCH=arm GOARM=7
- run: make build GOOS=linux GOARCH=arm64
test:
parameters:
golang_version:
type: string
default: "1.14"
shard_width:
type: string
default: "20"
test_flags:
type: string
default: ""
goarch:
type: string
default: amd64
executor:
name: golang
version: << parameters.golang_version >>
steps:
- attach_workspace:
at: .
- add-github-auth
- run: sudo apt-get install lsof
- run:
command: make test SHARD_WIDTH=<< parameters.shard_width >> TESTFLAGS="<< parameters.test_flags >>" GOARCH=<< parameters.goarch >>
no_output_timeout: 30m
cluster-tests:
executor:
name: golang
steps:
- attach_workspace:
at: .
- add-github-auth
- setup_remote_docker
- run: make clustertests-build
prerelease:
executor:
name: golang
steps:
- attach_workspace:
at: .
- add-github-auth
- run: make prerelease
- store_artifacts:
path: build
- persist_to_workspace:
root: .
paths: build
release:
executor:
name: golang
steps:
- attach_workspace:
at: .
- run: make release
- store_artifacts:
path: build
- persist_to_workspace:
root: .
paths: build
prerelease-upload:
docker:
- image: circleci/python:2.7-jessie
steps:
- attach_workspace:
at: .
- run: sudo pip install awscli
- run: make prerelease-upload
dockerhub-upload:
parameters:
tag_branch:
type: boolean
default: true
tag_tag:
type: boolean
default: false
tag_latest:
type: boolean
default: false
target_name:
type: string
default: moleculacorp/pilosa
executor:
name: golang
steps:
- attach_workspace:
at: .
- add-github-auth
- setup_remote_docker
- run: make docker
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- when:
condition: << parameters.tag_branch >>
steps:
- run: make docker-tag-push DOCKER_TARGET=<< parameters.target_name >>:<< pipeline.git.branch >>
- when:
condition: << parameters.tag_tag >>
steps:
- run: make docker-tag-push DOCKER_TARGET=<< parameters.target_name >>:$(git describe --tags)
- when:
condition: << parameters.tag_latest >>
steps:
- run: make docker-tag-push DOCKER_TARGET=<< parameters.target_name >>:latest
workflows:
build:
jobs:
- setup
- linter:
requires:
- setup
- check-license-headers:
requires:
- setup
- test-build-arm:
requires:
- setup
- test:
name: test-golang-<< matrix.golang_version >>
matrix:
parameters:
golang_version: ["1.14", "1.13", "1.12", "1.11"]
requires:
- setup
- test:
name: test-race
test_flags: -race -v -timeout=30m
requires:
- setup
- test:
name: test-386
goarch: "386"
requires:
- setup
- test:
name: test-shardwidth-22
shard_width: "22"
requires:
- setup
- cluster-tests:
requires:
- setup
- prerelease:
requires:
- linter
- check-license-headers
- test-golang-1.14
- dockerhub-upload:
name: dockerhub-upload-stable
tag_branch: true
tag_tag: true
tag_latest: true
requires:
- linter
- check-license-headers
- test-golang-1.14
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
- dockerhub-upload:
name: dockerhub-upload-unstable
tag_branch: true
tag_tag: false
tag_latest: false
requires:
- linter
- check-license-headers
- test-golang-1.14
filters:
branches:
only: enterprise
tags:
ignore: /^v.*/