2019-10-15 17:03:14 +00:00
version : 2.1
2019-10-15 15:35:51 +00:00
executors :
golang :
docker :
2022-01-17 02:24:37 +00:00
- image : circleci/golang:1.17
2019-10-15 15:35:51 +00:00
commands :
make :
parameters :
description :
type : string
target :
type : string
steps :
- attach_workspace :
2019-10-15 17:03:14 +00:00
at : /tmp/workspace
2019-10-15 15:35:51 +00:00
- restore_cache :
2019-10-15 17:03:14 +00:00
name : "Restore source code cache"
keys :
- go-src-v1-{{ .Revision }}
2019-10-15 20:31:07 +00:00
- checkout
2019-10-15 15:35:51 +00:00
- restore_cache :
2019-10-15 17:03:14 +00:00
name : "Restore go modules cache"
keys :
- go-mod-v2-{{ checksum "go.sum" }}
2019-10-15 15:35:51 +00:00
- run :
2019-10-15 17:03:14 +00:00
name : << parameters.description >>
command : |
make << parameters.target >>
2019-10-15 21:33:50 +00:00
no_output_timeout : 60m
2019-10-15 15:35:51 +00:00
jobs :
setup-dependencies :
2019-10-15 20:06:12 +00:00
executor : golang
steps :
- checkout
- restore_cache :
name : "Restore go modules cache"
keys :
- go-mod-v2-{{ checksum "go.sum" }}
- run :
name : Cache go modules
command : make go-mod-cache
- run :
name : Build
command : make build
- run :
name : Git garbage collection
command : git gc
- save_cache :
name : "Save go modules cache"
key : go-mod-v2-{{ checksum "go.sum" }}
paths :
- "/go/pkg/mod"
- save_cache :
name : "Save source code cache"
key : go-src-v1-{{ .Revision }}
paths :
- ".git"
2019-10-15 15:35:51 +00:00
test-cover :
executor : golang
parallelism : 4
steps :
- checkout
- restore_cache :
keys :
- go-mod-v2-{{ checksum "go.sum" }}
- run :
name : Run tests
2021-08-19 05:10:58 +00:00
no_output_timeout : 30m
2019-10-15 15:35:51 +00:00
command : |
export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
export GO111MODULE=on
mkdir -p /tmp/logs /tmp/workspace/profiles
2022-01-08 00:39:27 +00:00
for pkg in $(go list ./... | grep -v 'simulation\|contrib' | circleci tests split); do
2019-10-15 15:35:51 +00:00
id=$(echo "$pkg" | sed 's|[/.]|_|g')
2021-08-19 05:10:58 +00:00
go test -mod=readonly -timeout 20m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
2019-10-15 15:35:51 +00:00
done
- persist_to_workspace :
root : /tmp/workspace
paths :
- "profiles/*"
- store_artifacts :
path : /tmp/logs
test-all :
executor : golang
steps :
- make :
target : test-all
description : "Run all tests and simulations"
start-remote-sims :
executor : golang
steps :
- make :
target : start-remote-sims
description : "Test multi-seed simulation (long)"
2020-10-30 17:38:30 +00:00
docker-build-and-push :
# adapted from: https://circleci.com/blog/using-circleci-workflows-to-replicate-docker-hub-automated-builds/
environment :
IMAGE_NAME : kava/kava
docker :
- image : circleci/buildpack-deps:stretch
steps :
- checkout
2022-01-08 01:34:11 +00:00
- setup_remote_docker :
version : 20.10 .11
2020-10-30 17:38:30 +00:00
- run :
name : Build Docker image
2022-01-08 01:41:56 +00:00
command : DOCKER_BUILDKIT=1 docker build -t $IMAGE_NAME:$CIRCLE_BRANCH .
2020-10-30 17:38:30 +00:00
- run :
name : Publish Docker Image to Docker Hub
command : |
echo "$DOCKERHUB_KEY" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push $IMAGE_NAME:$CIRCLE_BRANCH
2019-10-15 15:35:51 +00:00
workflows :
version : 2
test-suite :
jobs :
- setup-dependencies :
# This filter enables the job for tags
filters :
tags :
only :
- /^v.*/
- test-cover :
requires :
- setup-dependencies
- test-all :
requires :
2019-10-15 20:23:06 +00:00
- setup-dependencies
2019-10-15 15:35:51 +00:00
# These filters ensure that the long sim only runs during release
filters :
branches :
2020-01-23 19:09:36 +00:00
only : "master"
2020-10-30 17:38:30 +00:00
upload-docker-images :
jobs :
- docker-build-and-push :
filters :
branches :
2021-08-16 18:25:15 +00:00
only : master