-
Notifications
You must be signed in to change notification settings - Fork 334
/
Copy pathconfig.yml
144 lines (137 loc) · 3.85 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
version: 2.1
executors:
golang:
docker:
- image: circleci/golang:1.16
commands:
make:
parameters:
description:
type: string
target:
type: string
steps:
- attach_workspace:
at: /tmp/workspace
- restore_cache:
name: "Restore source code cache"
keys:
- go-src-v1-{{ .Revision }}
- checkout
- restore_cache:
name: "Restore go modules cache"
keys:
- go-mod-v2-{{ checksum "go.sum" }}
- run:
name: << parameters.description >>
command: |
make << parameters.target >>
no_output_timeout: 60m
jobs:
setup-dependencies:
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"
test-cover:
executor: golang
parallelism: 4
steps:
- checkout
- restore_cache:
keys:
- go-mod-v2-{{ checksum "go.sum" }}
- run:
name: Run tests
no_output_timeout: 30m
command: |
export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
export GO111MODULE=on
mkdir -p /tmp/logs /tmp/workspace/profiles
for pkg in $(go list ./... | grep -v 'simulation\|migrate\|contrib' | circleci tests split); do
id=$(echo "$pkg" | sed 's|[/.]|_|g')
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"
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)"
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
- setup_remote_docker
- run:
name: Build Docker image
command: docker build -t $IMAGE_NAME:$CIRCLE_BRANCH .
- 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
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:
- setup-dependencies
# These filters ensure that the long sim only runs during release
filters:
branches:
only: "master"
upload-docker-images:
jobs:
- docker-build-and-push:
filters:
branches:
only: master