1
+ version : 2.1
2
+ machine :
3
+ environment :
4
+ PATH : ' ${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin'
5
+ executors :
6
+ linux_node12 : &linux_node12
7
+ docker :
8
+ - image : circleci/node:12
9
+ resource_class : large
10
+ linux_node15 : &linux_node15
11
+ docker :
12
+ - image : circleci/node:15
13
+ resource_class : large
14
+ windows_node12 : &windows_node12
15
+ machine :
16
+ image : ' windows-server-2019-vs2019:stable'
17
+ resource_class : windows.large
18
+ shell : bash.exe
19
+ macos_node12 : &macos_node12
20
+ macos :
21
+ xcode : " 11.2.1"
22
+ resource_class : large
23
+
24
+ defaults : &defaults
25
+ working_directory : ~/repo
26
+ parameters :
27
+ os :
28
+ type : executor
29
+
30
+ install_cli_with_local_codegen : &install_cli
31
+ name : install Amplify CLI and amplify-app with local Amplify Codegen
32
+ command : |
33
+ source .circleci/local_publish_helpers.sh
34
+ startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
35
+ setNpmRegistryUrlToLocal
36
+ sudo npm install -g @aws-amplify/cli
37
+ sudo npm install -g amplify-app
38
+ amplify -v
39
+ amplify-app --version
40
+ unsetNpmRegistryUrl
41
+ working_directory : ~/repo
42
+
43
+ clean_up_e2e_resources : &cleanup_e2e
44
+ name : Clean up e2e resources
45
+ command : |
46
+ cd packages/amplify-codegen-e2e-tests
47
+ yarn clean-e2e-resources job ${CIRCLE_BUILD_NUM}
48
+ working_directory : ~/repo
49
+
50
+ jobs :
51
+ build :
52
+ << : *defaults
53
+ executor : << parameters.os >>
54
+ steps :
55
+ - checkout
56
+ - run : yarn config set workspaces-experimental true
57
+ - run : yarn cache clean --force
58
+ - run : yarn run production-build
59
+ - save_cache :
60
+ key : amplify-codegen-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
61
+ paths :
62
+ - ~/.cache
63
+ - save_cache :
64
+ key : amplify-codegen-ssh-deps-{{ .Branch }}
65
+ paths :
66
+ - ~/.ssh
67
+ - persist_to_workspace :
68
+ root : .
69
+ paths : .
70
+
71
+ test :
72
+ << : *defaults
73
+ executor : << parameters.os >>
74
+ steps :
75
+ - when :
76
+ condition :
77
+ or :
78
+ - equal : [ *macos_node12, << parameters.os >> ]
79
+ - equal : [ *windows_node12, << parameters.os >> ]
80
+ steps :
81
+ - checkout
82
+ - run : yarn config set workspaces-experimental true
83
+ - run : yarn cache clean --force
84
+ - run : yarn run production-build
85
+ - when :
86
+ condition :
87
+ or :
88
+ - equal : [ *linux_node12, << parameters.os >> ]
89
+ - equal : [ *linux_node15, << parameters.os >> ]
90
+ steps :
91
+ - attach_workspace :
92
+ at : ./
93
+ - restore_cache :
94
+ key : amplify-codegen-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
95
+ - run :
96
+ name : Lint
97
+ command : yarn lint
98
+ - run :
99
+ name : Run tests
100
+ command : yarn test-ci
101
+ - run :
102
+ name : Collect code coverage
103
+ command : yarn coverage
104
+
105
+ deploy :
106
+ << : *defaults
107
+ executor : << parameters.os >>
108
+ steps :
109
+ - attach_workspace :
110
+ at : ./
111
+ - restore_cache :
112
+ keys :
113
+ - amplify-codegen-ssh-deps-{{ .Branch }}
114
+ - amplify-codegen-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
115
+ - run :
116
+ name : Authenticate with npm
117
+ command : echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
118
+ - run :
119
+ name : Publish Amplify Codegen
120
+ command : |
121
+ if [ -z "$CIRCLE_PULL_REQUEST" ]; then
122
+ git config --global user.email $GITHUB_EMAIL
123
+ git config --global user.name $GITHUB_USER
124
+ npm run publish:$CIRCLE_BRANCH
125
+ else
126
+ echo "Skipping deploy."
127
+ fi
128
+
129
+ publish_to_local_registry :
130
+ << : *defaults
131
+ executor : << parameters.os >>
132
+ steps :
133
+ - attach_workspace :
134
+ at : ./
135
+ - restore_cache :
136
+ key : amplify-codegen-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}
137
+ - run :
138
+ name : Publish to verdaccio
139
+ command : |
140
+ source .circleci/local_publish_helpers.sh
141
+ startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
142
+ setNpmRegistryUrlToLocal
143
+ loginToLocalRegistry
144
+ git config user.email [email protected]
145
+ git config user.name "Doesnt Matter"
146
+ yarn publish-to-verdaccio
147
+ unsetNpmRegistryUrl
148
+ - save_cache :
149
+ key : amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}
150
+ paths :
151
+ - ~/verdaccio-cache/
152
+
153
+ e2e-test :
154
+ << : *defaults
155
+ executor : << parameters.os >>
156
+ steps :
157
+ - attach_workspace :
158
+ at : ./
159
+ - restore_cache :
160
+ key : amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}
161
+ - run : *install_cli
162
+ - run :
163
+ name : Run e2e tests
164
+ command : |
165
+ cd packages/amplify-codegen-e2e-tests
166
+ yarn e2e --maxWorkers=3 $TEST_SUITE
167
+ no_output_timeout : 20m
168
+ - store_test_results :
169
+ path : packages/amplify-codegen-e2e-tests/
170
+ - store_artifacts :
171
+ path : ~/repo/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
172
+
173
+ done_with_node_e2e_tests :
174
+ << : *defaults
175
+ executor : << parameters.os >>
176
+ steps :
177
+ - run : echo 'Done with Node CLI E2E Tests'
178
+ workflows :
179
+ version : 2
180
+ build_test_deploy :
181
+ jobs :
182
+ - build :
183
+ os : linux_node12
184
+ - test :
185
+ name : test-<< matrix.os >>
186
+ matrix :
187
+ parameters :
188
+ os : [linux_node15, linux_node12, windows_node12, macos_node12]
189
+ requires :
190
+ - build
191
+ - publish_to_local_registry :
192
+ os : linux_node12
193
+ requires :
194
+ - build
195
+ filters :
196
+ branches :
197
+ only :
198
+ - master
199
+ - e2e-testing
200
+ - approval_for_e2e_test :
201
+ type : approval
202
+ requires :
203
+ - publish_to_local_registry
204
+ - e2e-test :
205
+ context :
206
+ - cleanup-resources
207
+ os : linux_node12
208
+ requires :
209
+ - approval_for_e2e_test
210
+ post-steps :
211
+ - run : *cleanup_e2e
212
+ filters :
213
+ branches :
214
+ only :
215
+ - master
216
+ - e2e-testing
217
+ - deploy :
218
+ os : linux_node12
219
+ requires :
220
+ - build
221
+ - test
222
+ - done_with_node_e2e_tests
223
+ filters :
224
+ branches :
225
+ only :
226
+ - release
227
+ - master
228
+ - done_with_node_e2e_tests :
229
+ os : linux_node12
230
+ requires :
231
+ - e2e-test
0 commit comments