1
- # Javascript Node CircleCI 2.0 configuration file
2
- #
3
- # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4
- #
1
+ # ## ------------------------------------------------------------------------------------------------
2
+ # ## To use this configuration, ensure that the following environment variables are configured in
3
+ # ## the CircleCI project settings:
4
+ # ##
5
+ # ## For all projects, set:
6
+ # ## - $DEV_API_BASE_URL (becomes $API_BASE_URL based on env)
7
+ # ## - $STAGING_API_BASE_URL (becomes $API_BASE_URL based on env)
8
+ # ## - $PROD_API_BASE_URL (becomes $API_BASE_URL based on env)
9
+ # ## - $SENTRY_AUTH_TOKEN
10
+ # ## - $SENTRY_DSN
11
+ # ## - $SENTRY_ENABLED
12
+ # ## - $SENTRY_ORG
13
+ # ## - $SENTRY_PROJECT
14
+ # ## - $CYPRESS_RECORD_KEY
15
+ # ## - $SLACK_HOOK, configure via https://cuttlesoft.slack.com/apps/A0F7XDUAZ-incoming-webhooks
16
+ # ##
17
+ # ## If deploying to Google Cloud Platform (GCP), create a token via `firebase login:ci` and set:
18
+ # ## - $FIREBASE_TOKEN
19
+ # ##
20
+ # ## If deploying to AWS, you must configure the built-in settings (only available on the old UI,
21
+ # ## this is being deprecated), set:
22
+ # ## - $DEV_S3_BUCKET_NAME (becomes $S3_BUCKET_NAME based on env)
23
+ # ## - $DEV_DISTRIBUTION_ID (becomes $DISTRIBUTION_ID based on env)
24
+ # ## - $STAGING_S3_BUCKET_NAME (becomes $S3_BUCKET_NAME based on env)
25
+ # ## - $STAGING_DISTRIBUTION_ID (becomes $DISTRIBUTION_ID based on env)
26
+ # ## - $PROD_S3_BUCKET_NAME (becomes $S3_BUCKET_NAME based on env)
27
+ # ## - $PROD_DISTRIBUTION_ID (becomes $DISTRIBUTION_ID based on env)
28
+ version : 2.1
5
29
6
- defaults : &defaults
7
- working_directory : ~/repo
8
- docker :
9
- - image : cypress/browsers:node12.18.0-chrome83-ff77
30
+ executors :
31
+ docker-executor :
32
+ working_directory : ~/repo
33
+ docker :
34
+ - image : cypress/browsers:node12.18.0-chrome83-ff77
10
35
11
- version : 2
12
36
jobs :
13
- build :
14
- << : *defaults
37
+ setup-lint :
38
+ executor : docker-executor
15
39
steps :
16
40
- checkout
17
41
18
42
# find compatible cache from previous build,
19
43
# it should have same dependencies installed from package.json checksum
20
44
- restore_cache :
21
45
keys :
22
- - cache-{{ .Branch }}-{{ checksum "package.json" }}
46
+ - cache-{{ checksum "package.json" }}
23
47
24
48
- run :
25
49
name : Install Dependencies
26
50
command : npm install
27
51
28
52
- save_cache :
29
- key : cache-{{ .Branch }}-{{ checksum "package.json" }}
53
+ key : cache-{{ checksum "package.json" }}
30
54
paths :
31
55
- ~/.npm
32
56
- ~/.cache
40
64
command : npm run format:test
41
65
42
66
# all other test jobs will run AFTER this build job finishes
43
- # to avoid reinstalling dependencies, we persist the source folder "app "
67
+ # to avoid reinstalling dependencies, we persist the source folder "repo "
44
68
# and the Cypress binary to workspace, which is the fastest way
45
69
# for Circle jobs to pass files
46
70
- persist_to_workspace :
@@ -50,45 +74,172 @@ jobs:
50
74
- .cache/Cypress
51
75
52
76
unittests :
53
- << : *defaults
77
+ executor : docker-executor
54
78
steps :
55
79
- attach_workspace :
56
80
at : ~/
57
81
- run : npm test -- --maxWorkers=4
58
82
59
83
integration-chrome :
60
- << : *defaults
84
+ executor : docker-executor
61
85
steps :
62
86
- attach_workspace :
63
87
at : ~/
88
+ - run :
89
+ name : Configure cypress variables
90
+ command : ./.circleci/configure-cypress-vars.sh
91
+ - run :
92
+ name : Configure build variables
93
+ command : ./.circleci/configure-build-vars.sh
64
94
- run :
65
95
command : npm start
66
96
background : true
67
97
- run : npm run e2e:record -- --group $CIRCLE_JOB --browser chrome
68
98
69
99
integration-firefox :
70
- << : *defaults
100
+ executor : docker-executor
71
101
steps :
72
102
- attach_workspace :
73
103
at : ~/
104
+ - run :
105
+ name : Configure cypress variables
106
+ command : ./.circleci/configure-cypress-vars.sh
107
+ - run :
108
+ name : Configure build variables
109
+ command : ./.circleci/configure-build-vars.sh
74
110
- run :
75
111
command : npm start
76
112
background : true
77
113
- run : npm run e2e:record -- --group $CIRCLE_JOB --browser firefox
78
114
115
+ build :
116
+ executor : docker-executor
117
+ steps :
118
+ - attach_workspace :
119
+ at : ~/
120
+ - run :
121
+ name : Configure build variables
122
+ command : ./.circleci/configure-build-vars.sh
123
+ # Ensure that the build completes before considering the build as 'Passed'
124
+ - run :
125
+ name : Run build
126
+ command : npm run build
127
+ - persist_to_workspace :
128
+ root : ~/
129
+ paths :
130
+ - repo
131
+ - .cache/Cypress
132
+ - build
133
+
134
+ deploy-s3 :
135
+ executor : docker-executor
136
+ steps :
137
+ - checkout
138
+ - attach_workspace :
139
+ at : ~/
140
+ - run :
141
+ name : Configure deploy variables
142
+ command : ./.circleci/configure-deploy-vars.sh
143
+ - run :
144
+ name : Install AWS CLI
145
+ command : sudo apt-get -y -qq install awscli
146
+ - run :
147
+ name : Enable CloudFront
148
+ command : aws configure set preview.cloudfront true
149
+ - run :
150
+ name : Upload to S3
151
+ command : aws s3 sync ./build s3://${S3_BUCKET_NAME} --delete --cache-control max-age=31536000,public
152
+
153
+ - run :
154
+ name : Update file cache headers
155
+ command : aws s3 cp s3://${S3_BUCKET_NAME}/index.html s3://${S3_BUCKET_NAME}/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html --acl public-read
156
+ - run :
157
+ name : Invalidate CloudFront distribution
158
+ command : aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths "/index.html"
159
+
160
+ deploy-gcp :
161
+ executor : docker-executor
162
+ steps :
163
+ - checkout
164
+ - attach_workspace :
165
+ at : ~/
166
+ - run :
167
+ name : Notify via Slack
168
+ command : curl -X POST -H 'Content-type:\ application/json' --data "{'text':'📦 Build successful. Deploying!'}" $SLACK_HOOK
169
+ - run :
170
+ name : Configure deploy variables
171
+ command : ./.circleci/configure-deploy-vars.sh
172
+ - run :
173
+ name : Firebase Deploy
174
+ command : ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
175
+ - run :
176
+ name : Notify via Slack
177
+ command : curl -X POST -H 'Content-type:\ application/json' --data "{'text':'🍰 Deploy successful.'}" $SLACK_HOOK
178
+
179
+
180
+ notify-sentry-deploy :
181
+ executor : docker-executor
182
+ steps :
183
+ - checkout
184
+ - attach_workspace :
185
+ at : ~/
186
+ - run :
187
+ name : Create release and notify Sentry of deploy
188
+ command : |
189
+ curl -sL https://sentry.io/get-cli/ | bash
190
+ export SENTRY_RELEASE=$(sentry-cli releases propose-version)
191
+ sentry-cli releases new -p $SENTRY_PROJECT $SENTRY_RELEASE
192
+ sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps ./build
193
+ sentry-cli releases finalize $SENTRY_RELEASE
194
+ sentry-cli releases deploys $SENTRY_RELEASE new -e $CIRCLE_BRANCH
195
+ - run :
196
+ name : Notify via Slack
197
+ command : curl -X POST -H 'Content-type:\ application/json' --data "{'text':'🦾 Sentry Release successful.'}" $SLACK_HOOK
198
+
199
+
79
200
workflows :
80
201
version : 2
81
202
build_and_test :
82
203
jobs :
83
- - build
84
- # after installing dependencies in the "build" job
85
- # run all tests in several groups
204
+ - setup-lint
86
205
- unittests :
87
206
requires :
88
- - build
207
+ - setup-lint
89
208
- integration-chrome :
90
209
requires :
91
- - build
210
+ - setup-lint
92
211
- integration-firefox :
212
+ requires :
213
+ - setup-lint
214
+ - build :
215
+ requires :
216
+ - unittests
217
+ - integration-chrome
218
+ - integration-firefox
219
+ # Enable this and configure branches as needed if deploying to AWS S3
220
+ # - deploy-s3:
221
+ # requires:
222
+ # - build
223
+ # filters:
224
+ # branches:
225
+ # only:
226
+ # - master
227
+ # - staging
228
+ - deploy-gcp :
93
229
requires :
94
230
- build
231
+ filters :
232
+ branches :
233
+ only :
234
+ - master
235
+ - staging
236
+ - prod
237
+ - notify-sentry-deploy :
238
+ requires :
239
+ - deploy-gcp
240
+ filters :
241
+ branches :
242
+ only :
243
+ - master
244
+ - staging
245
+ - prod
0 commit comments