-
Notifications
You must be signed in to change notification settings - Fork 503
/
Copy pathconfig.yml
232 lines (213 loc) · 7.18 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
version: 2.1
#----------------------------------------------------------------------------#
# Commands are used as building blocks for jobs, which run through workflows #
#----------------------------------------------------------------------------#
commands:
# gofmt performs checks on the entire codebase to ensure everything is formated
# with the gofmt tool.
gofmt:
steps:
- checkout
- run:
name: Run gofmt
command: ./gofmt.sh
# govet does govet checks in the entire codebase.
govet:
steps:
- checkout
- run:
name: Run govet
command: ./govet.sh
# staticcheck runs staticcheck in the entire codebase.
staticcheck:
steps:
- checkout
- run:
name: Run staticcheck
command: ./staticcheck.sh
# check_deprecations ensures a release is actually removing deprecated fields
# that were supposed to be discontinued in said release.
check_deprecations:
steps:
- run:
name: Run deprecation tests when on a tagged commit
command: |
if [ "$CIRCLE_TAG" != "" ]; then
# Negate the result so process exits with 1 if anything found
echo "Searching for \"action needed\" tags..."
! egrep -irn -A 1 --include=*.go "Action.+needed.+in.+release:.+$CIRCLE_TAG" ./
fi
# install_go_deps installs the go dependencies of the project.
install_go_deps:
steps:
- checkout
- run:
name: Install dep
command: curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- restore_cache:
keys:
- v1-pkg-cache
- run:
name: Install project dependencies using dep
command: dep ensure -v
- save_cache:
key: v1-pkg-cache
paths:
- "/go/src/github.com/stellar/go/vendor"
- "/go/src/pkg/dep"
# test_packages performs tests on all packages of the monorepo.
test_packages:
steps:
- run:
name: Install dependencies
command: sudo apt-get update && sudo apt-get install postgresql-client-9.6 mariadb-client-10.1
- run:
name: Install dockerize
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.3.0
- run:
name: Wait for mysql, postgres and redis
command: |
dockerize -wait tcp://localhost:5432 -timeout 1m
dockerize -wait tcp://localhost:3306 -timeout 1m
dockerize -wait tcp://localhost:6379 -timeout 1m
- run:
name: Run package tests
command: ./support/scripts/run_tests
# build_packages creates the project's artifacts.
build_packages:
steps:
- run:
name: Build release artifacts
command: go run ./support/scripts/build_release_artifacts/main.go
#-----------------------------------------------------------------------------#
# Jobs use the commands to accomplish a given task, and run through workflows #
#-----------------------------------------------------------------------------#
jobs:
# check_code_1_10 performs code checks using Go 1.10 (gofmt is only run for 1.12).
check_code_1_10:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.10
steps:
- govet
# check_code_1_11 performs code checks using Go 1.11 (gofmt is only run for 1.12).
check_code_1_11:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.11
steps:
- govet
# check_code_1_12 performs code checks using Go 1.12.
check_code_1_12:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.12
steps:
- install_go_deps
- gofmt
- govet
- staticcheck
# test_code_1_10 performs all package tests using Go 1.10.
test_code_1_10:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.10
environment:
PGHOST: localhost
PGPORT: 5432
PGUSER: circleci
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
- image: circleci/postgres:9.6.5-alpine-ram
environment:
POSTGRES_USER: circleci
- image: circleci/mysql:5.7
- image: circleci/redis:5.0-alpine
steps:
- install_go_deps
- test_packages
# test_code_1_11 performs all package tests using Go 1.11.
test_code_1_11:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.11
environment:
PGHOST: localhost
PGPORT: 5432
PGUSER: circleci
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
- image: circleci/postgres:9.6.5-alpine-ram
environment:
POSTGRES_USER: circleci
- image: circleci/mysql:5.7
- image: circleci/redis:5.0-alpine
steps:
- install_go_deps
- test_packages
# test_code_1_12 performs all package tests using Go 1.12.
test_code_1_12:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.12
environment:
PGHOST: localhost
PGPORT: 5432
PGUSER: circleci
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
- image: circleci/postgres:9.6.5-alpine-ram
environment:
POSTGRES_USER: circleci
- image: circleci/mysql:5.7
- image: circleci/redis:5.0-alpine
steps:
- install_go_deps
- test_packages
# publish_artifacts builds and uploads artifacts to any tagged commit.
#
# NOTE: this commands relies on an env var called GITHUB_TOKEN which is a
# GH OAUTH token with `repo` access.
publish_artifacts:
working_directory: /go/src/github.com/stellar/go
docker:
- image: circleci/golang:1.11
steps:
- check_deprecations
- install_go_deps
- build_packages
- attach_workspace:
at: ./dist
- run:
name: "Publish release on GitHub"
command: |
if [ -d "./dist" ]
then
go get github.com/tcnksm/ghr
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} ./dist/
else
echo "./dist does not exist. No binaries to publish for ${CIRCLE_TAG}."
fi
#-------------------------------------------------------------------------#
# Workflows orchestrate jobs and make sure they run in the right sequence #
#-------------------------------------------------------------------------#
workflows:
version: 2
check_code_and_test:
jobs:
- check_code_1_10
- check_code_1_11
- check_code_1_12
- test_code_1_10
- test_code_1_11
- test_code_1_12
build_and_deploy:
jobs:
- publish_artifacts:
filters:
tags:
ignore: snapshots
branches:
ignore: /.*/