Skip to content

Commit e8ed930

Browse files
mircea-cAlessio Treglia
authored andcommitted
CI configuration refactor (#4776)
* added back the tools targets * removed ci target
1 parent 243e876 commit e8ed930

File tree

6 files changed

+166
-269
lines changed

6 files changed

+166
-269
lines changed

.circleci/config.yml

Lines changed: 92 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,108 @@
1-
version: 2
2-
3-
defaults: &linux_defaults
4-
working_directory: /go/src/github.com/cosmos/cosmos-sdk
5-
docker:
6-
- image: circleci/golang:1.12.5
7-
8-
############
9-
#
10-
# Configure docs deployment
11-
12-
docs_update: &docs_deploy
13-
working_directory: ~/repo
14-
docker:
15-
- image: tendermintdev/jq_curl
16-
environment:
17-
AWS_REGION: us-east-1
1+
version: 2.1
2+
3+
executors:
4+
golang:
5+
docker:
6+
- image: circleci/golang:1.12.7
7+
docs:
8+
docker:
9+
- image: tendermintdev/docker-website-deployment
10+
environment:
11+
AWS_REGION: us-east-1
12+
13+
commands:
14+
make:
15+
parameters:
16+
description:
17+
type: string
18+
target:
19+
type: string
20+
steps:
21+
- attach_workspace:
22+
at: /tmp/workspace
23+
- restore_cache:
24+
name: "Restore source code cache"
25+
keys:
26+
- go-src-v1-{{ .Revision }}
27+
- checkout
28+
- restore_cache:
29+
name: "Restore go modules cache"
30+
keys:
31+
- go-mod-v1-{{ checksum "go.sum" }}
32+
- run:
33+
name: << parameters.description >>
34+
command: |
35+
make << parameters.target >>
1836
1937
jobs:
2038
setup_dependencies:
21-
<<: *linux_defaults
39+
executor: golang
2240
steps:
23-
- run: mkdir -p /tmp/workspace/bin
24-
- run: mkdir -p /tmp/workspace/profiles
2541
- checkout
2642
- restore_cache:
43+
name: "Restore go modules cache"
2744
keys:
2845
- go-mod-v1-{{ checksum "go.sum" }}
2946
- run:
30-
name: tools
31-
command: |
32-
make runsim tools TOOLS_DESTDIR=/tmp/workspace/bin
33-
cp $GOPATH/bin/runsim /tmp/workspace/bin
34-
cp $GOPATH/bin/statik /tmp/workspace/bin
47+
name: Cache go modules
48+
command: make go-mod-cache
3549
- run:
36-
name: cache go modules
37-
command: |
38-
make go-mod-cache
50+
name: Build
51+
command: make build
52+
- run:
53+
name: Git garbage collection
54+
command: git gc
3955
- save_cache:
56+
name: "Save go modules cache"
4057
key: go-mod-v1-{{ checksum "go.sum" }}
4158
paths:
4259
- "/go/pkg/mod"
43-
- run:
44-
name: build
45-
command: |
46-
make build
47-
- persist_to_workspace:
48-
root: /tmp/workspace
60+
- save_cache:
61+
name: "Save source code cache"
62+
key: go-src-v1-{{ .Revision }}
4963
paths:
50-
- bin
51-
- profiles
52-
53-
test_sim_app_nondeterminism:
54-
<<: *linux_defaults
55-
parallelism: 1
56-
steps:
57-
- attach_workspace:
58-
at: /tmp/workspace
59-
- checkout
60-
- restore_cache:
61-
keys:
62-
- go-mod-v1-{{ checksum "go.sum" }}
63-
- run:
64-
name: Test individual module simulations
65-
command: |
66-
make test_sim_app_nondeterminism
64+
- ".git"
6765

68-
test_sim_app_fast:
69-
<<: *linux_defaults
70-
parallelism: 1
66+
test_sim_nondeterminism:
67+
executor: golang
7168
steps:
72-
- attach_workspace:
73-
at: /tmp/workspace
74-
- checkout
75-
- restore_cache:
76-
keys:
77-
- go-mod-v1-{{ checksum "go.sum" }}
78-
- run:
79-
name: Test full application simulation
80-
command: |
81-
make test_sim_app_fast
69+
- make:
70+
target: test_sim_nondeterminism
71+
description: "Test individual module simulations"
8272

83-
test_sim_app_import_export:
84-
<<: *linux_defaults
85-
parallelism: 1
73+
test_sim_import_export:
74+
executor: golang
8675
steps:
87-
- attach_workspace:
88-
at: /tmp/workspace
89-
- checkout
90-
- restore_cache:
91-
keys:
92-
- go-mod-v1-{{ checksum "go.sum" }}
93-
- run:
94-
name: Test application import/export simulation
95-
command: |
96-
export GO111MODULE=on
97-
/tmp/workspace/bin/runsim -j 4 github.com/cosmos/cosmos-sdk/simapp 50 5 TestAppImportExport
76+
- make:
77+
target: test_sim_import_export
78+
description: "Test application import/export simulation"
9879

99-
test_sim_app_simulation_after_import:
100-
<<: *linux_defaults
101-
parallelism: 1
80+
test_sim_after_import:
81+
executor: golang
10282
steps:
103-
- attach_workspace:
104-
at: /tmp/workspace
105-
- checkout
106-
- restore_cache:
107-
keys:
108-
- go-mod-v1-{{ checksum "go.sum" }}
109-
- run:
110-
name: Test application import/export simulation
111-
command: |
112-
export GO111MODULE=on
113-
/tmp/workspace/bin/runsim -j 4 github.com/cosmos/cosmos-sdk/simapp 50 5 TestAppSimulationAfterImport
83+
- make:
84+
target: test_sim_after_import
85+
description: "Test simulation after import"
11486

115-
test_sim_app_multi_seed_long:
116-
<<: *linux_defaults
117-
parallelism: 1
87+
test_sim_multi_seed_long:
88+
executor: golang
11889
steps:
119-
- attach_workspace:
120-
at: /tmp/workspace
121-
- checkout
122-
- restore_cache:
123-
keys:
124-
- go-mod-v1-{{ checksum "go.sum" }}
125-
- run:
126-
name: Test multi-seed application simulation long
127-
command: |
128-
export GO111MODULE=on
129-
/tmp/workspace/bin/runsim -j 4 github.com/cosmos/cosmos-sdk/simapp 500 50 TestFullAppSimulation
90+
- make:
91+
target: test_sim_multi_seed_long
92+
description: "Test multi-seed simulation (long)"
13093

131-
test_sim_app_multi_seed:
132-
<<: *linux_defaults
133-
parallelism: 1
94+
test_sim_multi_seed_short:
95+
executor: golang
13496
steps:
135-
- attach_workspace:
136-
at: /tmp/workspace
137-
- checkout
138-
- restore_cache:
139-
keys:
140-
- go-mod-v1-{{ checksum "go.sum" }}
141-
- run:
142-
name: Test multi-seed application simulation short
143-
command: |
144-
export GO111MODULE=on
145-
/tmp/workspace/bin/runsim -j 4 github.com/cosmos/cosmos-sdk/simapp 50 10 TestFullAppSimulation
97+
- make:
98+
target: test_sim_multi_seed_short
99+
description: "Test multi-seed simulation (short)"
146100

147101
test_cover:
148-
<<: *linux_defaults
102+
executor: golang
149103
parallelism: 4
150104
steps:
151-
- attach_workspace:
152-
at: /tmp/workspace
153105
- checkout
154-
- run: mkdir -p /tmp/logs
155106
- restore_cache:
156107
keys:
157108
- go-mod-v1-{{ checksum "go.sum" }}
@@ -160,7 +111,8 @@ jobs:
160111
command: |
161112
export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
162113
export GO111MODULE=on
163-
for pkg in $(go list ./... | grep -v '/simulation' | circleci tests split --split-by=timings); do
114+
mkdir -p /tmp/logs /tmp/workspace/profiles
115+
for pkg in $(go list ./... | grep -v '/simulation' | circleci tests split); do
164116
id=$(echo "$pkg" | sed 's|[/.]|_|g')
165117
go test -mod=readonly -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
166118
done
@@ -172,17 +124,14 @@ jobs:
172124
path: /tmp/logs
173125

174126
upload_coverage:
175-
<<: *linux_defaults
176-
parallelism: 1
127+
executor: golang
177128
steps:
178129
- attach_workspace:
179130
at: /tmp/workspace
180131
- checkout
181132
- run:
182133
name: gather
183134
command: |
184-
set -ex
185-
186135
echo "--> Concatenating profiles:"
187136
ls /tmp/workspace/profiles/
188137
echo "mode: atomic" > coverage.txt
@@ -201,53 +150,12 @@ jobs:
201150
name: upload
202151
command: bash <(curl -s https://codecov.io/bash) -f coverage.txt
203152

204-
deploy_docs:
205-
<<: *docs_deploy
206-
steps:
207-
- checkout
208-
- run:
209-
name: Trigger website build
210-
command: |
211-
curl --silent \
212-
--show-error \
213-
-X POST \
214-
--header "Content-Type: application/json" \
215-
-d "{\"branch\": \"$CIRCLE_BRANCH\"}" \
216-
"https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$WEBSITE_REPO_NAME/build?circle-token=$TENDERBOT_API_TOKEN" > response.json
217-
218-
RESULT=`jq -r '.status' response.json`
219-
MESSAGE=`jq -r '.message' response.json`
220-
221-
if [[ ${RESULT} == "null" ]] || [[ ${RESULT} -ne "200" ]]; then
222-
echo "CircleCI API call failed: $MESSAGE"
223-
exit 1
224-
else
225-
echo "Website build started"
226-
fi
227-
228153
check_statik:
229-
<<: *linux_defaults
230-
parallelism: 1
154+
executor: golang
231155
steps:
232-
- attach_workspace:
233-
at: /tmp/workspace
234-
- checkout
235-
- restore_cache:
236-
keys:
237-
- go-mod-v1-{{ checksum "go.sum" }}
238-
- run:
239-
name: check if statik.go is up-to-date
240-
command: |
241-
set -ex
242-
export PATH=/tmp/workspace/bin:$PATH
243-
244-
make update-swagger-docs
245-
if [ -n "$(git status --porcelain)" ]; then
246-
echo "swagger docs out of sync";
247-
exit 1
248-
else
249-
echo "swagger docs are in sync";
250-
fi
156+
- make:
157+
target: update-swagger-docs
158+
description: "Check if statik.go is up-to-date"
251159

252160
workflows:
253161
version: 2
@@ -256,41 +164,34 @@ workflows:
256164
- check_statik:
257165
requires:
258166
- setup_dependencies
259-
- deploy_docs:
260-
filters:
261-
branches:
262-
only:
263-
- master
264-
- develop
265167
- setup_dependencies:
266-
# filters here are needed to enable this job also for tags
168+
# This filter enables the job for tags
267169
filters:
268170
tags:
269171
only:
270172
- /^v.*/
271-
- test_sim_app_nondeterminism:
272-
requires:
273-
- setup_dependencies
274-
- test_sim_app_fast:
173+
- test_sim_nondeterminism:
275174
requires:
276175
- setup_dependencies
277-
- test_sim_app_import_export:
176+
- test_sim_import_export:
278177
requires:
279178
- setup_dependencies
280-
- test_sim_app_simulation_after_import:
179+
- test_sim_after_import:
281180
requires:
282181
- setup_dependencies
283-
- test_sim_app_multi_seed:
182+
- test_sim_multi_seed_short:
284183
requires:
285184
- setup_dependencies
286-
- test_sim_app_multi_seed_long:
185+
- test_sim_multi_seed_long:
287186
requires:
288187
- setup_dependencies
188+
# These filters ensure that the long sim only runs during release
289189
filters:
290190
branches:
191+
ignore: /.*/
192+
tags:
291193
only:
292-
- master
293-
- develop
194+
- /^v.*/
294195
- test_cover:
295196
requires:
296197
- setup_dependencies
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#4775 Refactor CI config

0 commit comments

Comments
 (0)