1
1
version : 2.1
2
+
3
+ restore_npm_cache : &restore_npm_cache
4
+ restore_cache :
5
+ keys :
6
+ - v1-dependencies-{{ checksum "package.json" }}
7
+ - v1-dependencies-
8
+
9
+ install_npm_packages : &install_npm_packages
10
+ run :
11
+ name : install dependencies
12
+ command : npm install
13
+
14
+ save_npm_cache : &save_npm_cache
15
+ save_cache :
16
+ paths :
17
+ - ./node_modules
18
+ key : v1-dependencies-{{ checksum "package.json" }}
19
+
20
+ fix_file_suffixes_for_cloud_gov : &fix_file_suffixes_for_cloud_gov
21
+ run :
22
+ name : Delete Config.js and drop sufffix on Config.js.cloudgov
23
+ command : |
24
+ rm ./src/config.js
25
+ mv ./src/config.js.cloudgov ./src/config.js
26
+ rm knexfile.js
27
+ mv knexfile.js.cloudgov knexfile.js
28
+
29
+ install_cf_cli : &install_cf_cli
30
+ run :
31
+ name : Install CF CLI
32
+ command : |
33
+ sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
34
+ sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
35
+
2
36
jobs :
3
- develop_deploy :
37
+ lint_js :
4
38
docker :
5
- - image : cimg/node:16.19.1-browsers
39
+ - image : cimg/node:20.11.0-browsers
40
+ steps :
41
+ - checkout
42
+ - *restore_npm_cache
43
+ - *install_npm_packages
44
+ - *save_npm_cache
45
+ - run :
46
+ name : lint javascript
47
+ command : npm run lint
48
+ test :
49
+ docker :
50
+ - image : cimg/node:20.11.0-browsers
6
51
environment :
7
52
POSTGRES_USER : postgres
8
53
NODE_ENV : test
@@ -11,25 +56,20 @@ jobs:
11
56
POSTGRES_DB : analytics-api-test
12
57
steps :
13
58
- checkout
14
-
15
- - restore_cache :
16
- keys :
17
- - v1-dependencies-{{ checksum "package.json" }}
18
- - v1-dependencies-
19
-
20
- - run :
21
- name : install dependencies
22
- command : npm install
23
-
24
- - save_cache :
25
- paths :
26
- - ./node_modules
27
- key : v1-dependencies-{{ checksum "package.json" }}
28
-
59
+ - *restore_npm_cache
60
+ - *install_npm_packages
61
+ - *save_npm_cache
29
62
- run :
30
- name : run tests
31
- command : npm test
32
-
63
+ name : unit test javascript
64
+ command : npm test
65
+ development_env_deploy :
66
+ docker :
67
+ - image : cimg/node:20.11.0-browsers
68
+ steps :
69
+ - checkout
70
+ - *restore_npm_cache
71
+ - *install_npm_packages
72
+ - *save_npm_cache
33
73
- run :
34
74
name : Replace Data URL in manifest.yml file when deploying to develop
35
75
command : |
@@ -39,26 +79,12 @@ jobs:
39
79
sed -i 's@- analytics-reporter-database@- analytics-reporter-database-develop@g' manifest.yml
40
80
mv manifest.yml manifest.yml.src
41
81
envsubst < manifest.yml.src > manifest.yml
42
-
43
82
- run :
44
83
name : Run sed on entrypoint.sh when deploying to develop
45
84
command : |
46
85
sed -i 's@NEW_RELIC_APP_NAME="analytics-reporter-api"@NEW_RELIC_APP_NAME="analytics-reporter-api-develop"@g' entrypoint.sh
47
-
48
- - run :
49
- name : Delete Config.js and drop sufffix on Config.js.cloudgov
50
- command : |
51
- rm ./src/config.js
52
- mv ./src/config.js.cloudgov ./src/config.js
53
- rm knexfile.js
54
- mv knexfile.js.cloudgov knexfile.js
55
-
56
- - run :
57
- name : Install CF CLI
58
- command : |
59
- sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
60
- sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
61
-
86
+ - *fix_file_suffixes_for_cloud_gov
87
+ - *install_cf_cli
62
88
- run :
63
89
name : deploy
64
90
command : |
@@ -71,37 +97,14 @@ jobs:
71
97
cf set-env analytics-reporter-api-develop API_DATA_GOV_SECRET "$API_SECRET_LOWER"
72
98
cf restage analytics-reporter-api-develop
73
99
cf logout
74
-
75
- staging_deploy :
100
+ staging_env_deploy :
76
101
docker :
77
- - image : cimg/node:16.19.1-browsers
78
- environment :
79
- POSTGRES_USER : postgres
80
- NODE_ENV : test
81
- - image : circleci/postgres:9.5-alpine
82
- environment :
83
- POSTGRES_DB : analytics-api-test
102
+ - image : cimg/node:20.11.0-browsers
84
103
steps :
85
104
- checkout
86
-
87
- - restore_cache :
88
- keys :
89
- - v1-dependencies-{{ checksum "package.json" }}
90
- - v1-dependencies-
91
-
92
- - run :
93
- name : install dependencies
94
- command : npm install
95
-
96
- - save_cache :
97
- paths :
98
- - ./node_modules
99
- key : v1-dependencies-{{ checksum "package.json" }}
100
-
101
- - run :
102
- name : run tests
103
- command : npm test
104
-
105
+ - *restore_npm_cache
106
+ - *install_npm_packages
107
+ - *save_npm_cache
105
108
- run :
106
109
name : Replace Data URL in manifest.yml file when deploying to staging
107
110
command : |
@@ -111,26 +114,12 @@ jobs:
111
114
sed -i 's@- analytics-reporter-database@- analytics-reporter-database-staging@g' manifest.yml
112
115
mv manifest.yml manifest.yml.src
113
116
envsubst < manifest.yml.src > manifest.yml
114
-
115
117
- run :
116
118
name : Run sed on entrypoint.sh when deploying to staging
117
119
command : |
118
120
sed -i 's@NEW_RELIC_APP_NAME="analytics-reporter-api"@NEW_RELIC_APP_NAME="analytics-reporter-api-staging"@g' entrypoint.sh
119
-
120
- - run :
121
- name : Delete Knexfile.js and drop sufffix on Knexfile.js.cloudgov
122
- command : |
123
- rm knexfile.js
124
- mv knexfile.js.cloudgov knexfile.js
125
- rm ./src/config.js
126
- mv ./src/config.js.cloudgov ./src/config.js
127
-
128
- - run :
129
- name : Install CF CLI
130
- command : |
131
- sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
132
- sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
133
-
121
+ - *fix_file_suffixes_for_cloud_gov
122
+ - *install_cf_cli
134
123
- run :
135
124
name : deploy
136
125
command : |
@@ -143,37 +132,14 @@ jobs:
143
132
cf set-env analytics-reporter-api-staging API_DATA_GOV_SECRET "$API_SECRET_LOWER"
144
133
cf restage analytics-reporter-api-staging
145
134
cf logout
146
-
147
- main_deploy :
135
+ production_env_deploy :
148
136
docker :
149
- - image : cimg/node:16.19.1-browsers
150
- environment :
151
- POSTGRES_USER : postgres
152
- NODE_ENV : test
153
- - image : circleci/postgres:9.5-alpine
154
- environment :
155
- POSTGRES_DB : analytics-api-test
137
+ - image : cimg/node:20.11.0-browsers
156
138
steps :
157
139
- checkout
158
-
159
- - restore_cache :
160
- keys :
161
- - v1-dependencies-{{ checksum "package.json" }}
162
- - v1-dependencies-
163
-
164
- - run :
165
- name : install dependencies
166
- command : npm install
167
-
168
- - save_cache :
169
- paths :
170
- - ./node_modules
171
- key : v1-dependencies-{{ checksum "package.json" }}
172
-
173
- - run :
174
- name : run tests
175
- command : npm test
176
-
140
+ - *restore_npm_cache
141
+ - *install_npm_packages
142
+ - *save_npm_cache
177
143
- run :
178
144
name : Replace Data URL in manifest.yml file when deploying to production
179
145
command : |
@@ -183,26 +149,12 @@ jobs:
183
149
sed -i 's@- analytics-reporter-database@- analytics-reporter-database-production@g' manifest.yml
184
150
mv manifest.yml manifest.yml.src
185
151
envsubst < manifest.yml.src > manifest.yml
186
-
187
152
- run :
188
153
name : Run sed on entrypoint.sh when deploying to main
189
154
command : |
190
155
sed -i 's@NEW_RELIC_APP_NAME="analytics-reporter-api"@NEW_RELIC_APP_NAME="analytics-reporter-api-production"@g' entrypoint.sh
191
-
192
- - run :
193
- name : Delete Knexfile.js and drop sufffix on Knexfile.js.cloudgov
194
- command : |
195
- rm knexfile.js
196
- mv knexfile.js.cloudgov knexfile.js
197
- rm ./src/config.js
198
- mv ./src/config.js.cloudgov ./src/config.js
199
-
200
- - run :
201
- name : Install CF CLI
202
- command : |
203
- sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
204
- sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
205
-
156
+ - *fix_file_suffixes_for_cloud_gov
157
+ - *install_cf_cli
206
158
- run :
207
159
name : deploy
208
160
command : |
@@ -216,28 +168,30 @@ jobs:
216
168
cf restage analytics-reporter-api-production
217
169
cf logout
218
170
219
- workflows :
220
- develop_workflow :
221
- jobs :
222
- - develop_deploy :
223
- filters :
224
- branches :
225
- only :
171
+ ci :
172
+ jobs :
173
+ - lint
174
+ - test :
175
+ requires :
176
+ - lint
177
+ - development_env_deploy :
178
+ requires :
179
+ - test
180
+ filters :
181
+ branches :
182
+ only :
226
183
- develop
227
-
228
- staging :
229
- jobs :
230
- - staging_deploy :
231
- filters :
232
- branches :
233
- only :
234
- - stage
235
-
236
- main_workflow :
237
- jobs :
238
- - main_deploy :
239
- filters :
240
- branches :
241
- only :
184
+ - staging_env_deploy :
185
+ requires :
186
+ - test
187
+ filters :
188
+ branches :
189
+ only :
190
+ - staging
191
+ - production_env_deploy :
192
+ requires :
193
+ - test
194
+ filters :
195
+ branches :
196
+ only :
242
197
- master
243
-
0 commit comments