-
Notifications
You must be signed in to change notification settings - Fork 2
/
circle.yml
255 lines (236 loc) · 6.21 KB
/
circle.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
---
version: 2
templates:
# Cache Keys:
#############################################################################
cache: &cache
key: v3-{{arch}}-{{ checksum "yarn.lock" }}-{{ checksum "circle.yml" }}
cache_deploy: &cache_deploy
key: v2-deploy-{{ checksum "circle.yml" }}
cache_modernizr: &cache_modernizr
key: v2-modernizr-{{ .Revision }}
# Environments:
#############################################################################
demo: &demo
environment:
ENV: DEMO
LONG_ENV: demo
prod: &prod
environment:
ENV: PROD
LONG_ENV: production
qa: &qa
environment:
ENV: DEMO
# Executors:
#############################################################################
executor_node: &executor_node
docker:
- image: circleci/node:10-browsers
environment:
TERM: xterm
JOBS: 2
executor_python: &executor_python
docker:
- image: circleci/python:3.6
# Filters:
#############################################################################
filter_all: &filter_all
filters:
tags:
only: /.*/
filter_demo: &filter_demo
filters:
branches:
only: main
tags:
only: demo
filter_prod: &filter_prod
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+/
branches:
ignore: /.*/
filter_qa: &filter_qa
filters:
tags:
ignore: /.*/
branches:
only: /[\w-]+/[\w-]+/
# Job Templates:
#############################################################################
deploy_ecs: &deploy_ecs
<<: *executor_python
steps:
- checkout
- setup_remote_docker
- restore_cache:
<<: *cache_deploy
- run:
name: Deploy Fastboot
command: |
if [[ ! -d ~/.venv ]]; then
python -m venv ~/.venv
. ~/.venv/bin/activate
pip install -U git+https://github.com/nypublicradio/nyprsetuptools.git
fi
. ~/.venv/bin/activate
TAG="${CIRCLE_TAG:-demo}"
ENV="${ENV,,}"
export "${ENV}_SENTRY_RELEASE"="${TAG}"
nyprsetuptools DockerDeploy \
--cpu=512 \
--ecr-repository=wqxr-web-client \
--ecs-cluster=fastboot \
--environment=$ENV \
--execution-role=wqxr-web-client-$ENV \
--fargate \
--memory-reservation=1024 \
--ports=3000 \
--tag=$TAG \
--task-role=wqxr-web-client-$ENV \
--wait=300
- save_cache:
<<: *cache_deploy
paths:
- ~/.venv
deploy_static: &deploy_static
<<: *executor_node
steps:
- checkout
- restore_cache:
<<: *cache
- restore_cache:
<<: *cache_modernizr
- run:
name: Deploy to S3
command: |
env | sed -n 's/^DEPLOY_//p' > .env
env | sed -n "s/^${ENV}_//p" >> .env
export QA_BUILD="$QA_PREFIX/$CIRCLE_BRANCH"
export QA_URL="$DEMO_WQXR_URL?build=$QA_BUILD"
npx ember deploy ${LONG_ENV:-qa:$QA_BUILD} --verbose --activate
mkdir -p /tmp/qa-builds
if [[ -z "$LONG_ENV" ]]; then
echo "<a href=\"$QA_URL\">$QA_URL</a>" \
>> /tmp/qa-builds/$CIRCLE_SHA1.html
fi
- store_artifacts:
path: /tmp/qa-builds
jobs:
build:
<<: *executor_node
steps:
- checkout
- restore_cache:
<<: *cache
- run:
name: Install Node Dependencies
command: |
[ -d ./node_modules ] || yarn --pure-lockfile
- save_cache:
<<: *cache
paths:
- node_modules
- /home/circleci/.cache/Cypress
- restore_cache:
<<: *cache_modernizr
- run:
name: Build Modernizr
command: |
[ -f vendor/modernizr/modernizr-build.js ] || npx grunt modernizr:dist
- save_cache:
<<: *cache_modernizr
paths:
- vendor/modernizr/modernizr-build.js
test_ember:
<<: *executor_node
steps:
- checkout
- restore_cache:
<<: *cache
- restore_cache:
<<: *cache_modernizr
- run:
name: Test Ember
command: |
cp .env.sample .env
npx ember test -r xunit
environment:
CIRCLE_TEST_REPORTS: test-results
- store_test_results:
path: test-results/
test_cypress:
<<: *executor_node
steps:
- checkout
- restore_cache:
<<: *cache
- restore_cache:
<<: *cache_modernizr
- run: sudo apt-get install libgconf-2-4
- run: cp .env.sample .env
- run:
name: Run Cypress tests in parallel
command: yarn run cy:ci:test
- store_test_results:
path: test-results/
deploy_static_demo:
<<: *deploy_static
<<: *demo
deploy_ecs_demo:
<<: *deploy_ecs
<<: *demo
deploy_static_prod:
<<: *deploy_static
<<: *prod
deploy_ecs_prod:
<<: *deploy_ecs
<<: *prod
deploy_static_qa:
<<: *deploy_static
<<: *qa
workflows:
version: 2
build-test-deploy:
jobs:
- build:
<<: *filter_all
- test_ember:
<<: *filter_all
requires:
- build
- test_cypress:
<<: *filter_all
requires:
- build
- deploy_static_demo:
<<: *filter_demo
requires:
- test_ember
- test_cypress
context: "AWS Deploy"
- deploy_ecs_demo:
<<: *filter_demo
requires:
- test_ember
- test_cypress
context: "AWS Deploy"
- deploy_static_prod:
<<: *filter_prod
requires:
- test_ember
- test_cypress
context: "AWS Deploy"
- deploy_ecs_prod:
<<: *filter_prod
requires:
- test_ember
- test_cypress
context: "AWS Deploy"
- deploy_static_qa:
<<: *filter_qa
requires:
- test_ember
- test_cypress
context: "AWS Deploy"