This repository was archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathconfig.yml
More file actions
253 lines (227 loc) · 7.49 KB
/
Copy pathconfig.yml
File metadata and controls
253 lines (227 loc) · 7.49 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
version: 2.1
executors:
builder:
docker:
- image: omisegoimages/ewallet-builder:v1.2
working_directory: ~/src
builder_pg:
docker:
- image: omisegoimages/ewallet-builder:v1.2
- image: postgres:9.6-alpine
working_directory: ~/src
deploy:
docker:
- image: omisegoimages/ewallet-deploy:stable
working_directory: ~/src
metal:
machine: true
environment:
IMAGE_NAME: "omisego/ewallet"
commands:
notify_slack_failure:
description: "Notify Slack only on failure"
steps:
- run:
name: Notify Slack on failure
command: |
if [ -z "$SLACK_WEBHOOK" ]; then
printf "\\033[0;33mSkipping Slack notification (SLACK_WEBHOOK missing)\\033[0;0m\\n"
exit 0
fi
GH_URL="https://github.com/omisego/ewallet/tree/${CIRCLE_BRANCH}"
CIRCLE_URL="https://circleci.com/gh/omisego/ewallet/${CIRCLE_BUILD_NUM}"
WORKFLOW_URL="https://circleci.com/workflow-run/${CIRCLE_WORKFLOW_ID}"
MESSAGE="omisego/ewallet branch ${CIRCLE_BRANCH} has failed during ${CIRCLE_JOB}"
RICH_MESSAGE="*omisego/ewallet* branch *${CIRCLE_BRANCH}* has failed during ${CIRCLE_JOB}"
curl -X POST -H 'Content-Type: application/json' --data "{ \
\"attachments\": [ \
{ \
\"fallback\": \"${MESSAGE}\", \
\"text\": \":no_good: ${RICH_MESSAGE}\", \
\"mrkdwn\": true, \
\"color\": \"#ed2c5c\", \
\"fields\": [ \
{ \
\"title\": \"Branch\", \
\"value\": \"<$GH_URL|$CIRCLE_BRANCH>\", \
\"short\": true \
}, { \
\"title\": \"Build\", \
\"value\": \"<$CIRCLE_URL|$CIRCLE_BUILD_NUM>\", \
\"short\": true \
} \
] \
} \
] \
}" ${SLACK_WEBHOOK}
when: on_fail
notify_slack:
description: "Notify Slack"
steps:
- run:
name: Notify Slack
command: |
if [ -z "$SLACK_WEBHOOK" ]; then
printf "\\033[0;33mSkipping Slack notification (SLACK_WEBHOOK missing)\\033[0;0m\\n"
exit 0
fi
GH_URL="https://github.com/omisego/ewallet/tree/${CIRCLE_BRANCH}"
CIRCLE_URL="https://circleci.com/gh/omisego/ewallet/${CIRCLE_BUILD_NUM}"
WORKFLOW_URL="https://circleci.com/workflow-run/${CIRCLE_WORKFLOW_ID}"
MESSAGE="omisego/ewallet branch ${CIRCLE_BRANCH} has been successfully built"
RICH_MESSAGE="*omisego/ewallet* branch *${CIRCLE_BRANCH}* has been successfully built"
curl -X POST -H 'Content-Type: application/json' --data "{ \
\"attachments\": [ \
{ \
\"fallback\": \"${MESSAGE}\", \
\"text\": \":white_check_mark: ${RICH_MESSAGE}\", \
\"mrkdwn\": true, \
\"color\": \"#1cbf43\", \
\"fields\": [ \
{ \
\"title\": \"Branch\", \
\"value\": \"<$GH_URL|$CIRCLE_BRANCH>\", \
\"short\": true \
}, { \
\"title\": \"Build\", \
\"value\": \"<$CIRCLE_URL|$CIRCLE_BUILD_NUM>\", \
\"short\": true \
} \
] \
} \
] \
}" ${SLACK_WEBHOOK}
notify_slack_deploy:
description: "Notify Slack Deploy"
steps:
- run:
name: Notify Slack
command: |
if [ -z "$SLACK_WEBHOOK" ]; then
printf "\\033[0;33mSkipping Slack notification (SLACK_WEBHOOK missing)\\033[0;0m\\n"
exit 0
fi
TAG="$(printf "%s" "$CIRCLE_SHA1" | head -c 8)"
MESSAGE="ewallet.staging.omisego.io has been deployed with omisego/ewallet:${TAG}"
RICH_MESSAGE="*ewallet.staging.omisego.io* has been deployed with *omisego/ewallet:${TAG}*"
curl -X POST -H 'Content-Type: application/json' --data "{ \
\"attachments\": [ \
{ \
\"fallback\": \"${MESSAGE}\", \
\"text\": \":rocket: ${RICH_MESSAGE}\", \
\"mrkdwn\": true, \
\"color\": \"#5f31d9\" \
} \
] \
}" ${SLACK_WEBHOOK}
setup_ewallet_workspace:
description: "Setup eWallet workspace"
steps:
- attach_workspace:
name: Attach workspace
at: ~/
jobs:
build:
executor: builder
steps:
- checkout
- run: |
mkdir -p ~/var
elixir --version | tee ~/var/elixir-version
node --version | tee ~/var/node-version
- run: make build-test
- run: make deps-assets
- persist_to_workspace:
name: Persist workspace
root: ~/
paths:
- var/
- src/deps
- src/_build
- src/apps/admin_panel/assets/node_modules
- notify_slack_failure
lint:
executor: builder
steps:
- checkout
- setup_ewallet_workspace
- run: make check-format
- run: make check-credo
- notify_slack_failure
dialyze:
executor: builder
steps:
- checkout
- setup_ewallet_workspace
- restore_cache:
name: Restore runtime PLT from cache
keys:
- v2-ewallet-plt-{{ checksum "~/var/elixir-version" }}-{{ checksum "mix.lock" }}
- v2-ewallet-plt-{{ checksum "~/var/elixir-version" }}-
- v2-ewallet-plt-
- run: |
export PLT_CORE_PATH=$HOME/var/dialyzer
mkdir -p $PLT_CORE_PATH
make check-dialyzer
- save_cache:
name: Cache runtime PLT
key: v2-ewallet-plt-{{ checksum "~/var/elixir-version" }}-{{ checksum "mix.lock" }}
paths:
- ~/var/dialyzer
when: always
- notify_slack_failure
test:
executor: builder_pg
environment:
DATABASE_URL: postgresql://postgres:@localhost:5432/ewallet
LOCAL_LEDGER_DATABASE_URL: postgresql://postgres:@localhost:5432/ledger
steps:
- checkout
- setup_ewallet_workspace
- run: make test-ewallet
- run: make test-assets
- notify_slack_failure
publish:
executor: metal
steps:
- checkout
- run: make docker IMAGE_NAME=$IMAGE_NAME
- run: sh .circleci/ci_e2e.sh
- run: sh .circleci/ci_publish.sh
- notify_slack_failure
- notify_slack
deploy:
executor: deploy
steps:
- checkout
- run: sh .circleci/ci_deploy.sh
- notify_slack_failure
- notify_slack_deploy
workflows:
test_build:
jobs:
- build:
filters: &all_branches
branches:
only: /.*/
tags:
only: /.*/
- lint:
requires: [build]
filters: *all_branches
- test:
requires: [build]
filters: *all_branches
- dialyze:
requires: [build]
filters: *all_branches
- publish:
requires: [lint, test, dialyze]
filters: *all_branches
# Deploy to staging in case of master branch.
- deploy:
requires: [publish]
filters:
branches:
only:
- master