forked from trailheadapps/ebikes-communities-lwc
/
config.yml
254 lines (250 loc) · 9.39 KB
/
config.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
version: 2
# Defining default values for all jobs
defaults: &defaults
docker:
- image: circleci/node:lts-browsers
jobs:
setup_tooling:
<<: *defaults
steps:
- checkout
# - Install npm dependencies for LWC linting and testing
- run:
name: Install package dependencies
command: |
npm install
- persist_to_workspace:
# This is an important step. If we don't store the project data (cloned GitHub source and node_modules)
# we'd have to re-run installation for every workflow step.
root: ~/
paths:
- project/*
prettier_verify:
# This verifies Prettier formatting
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Verify Prettier formatting
command: |
npm run prettier:verify
lint_lwc:
# This lints Lightning Web Components.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Lint Lightning Web Components
command: |
npm run lint:lwc
unit_test_lwc:
# This unit tests Lightning Web Components.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Unit test Lightning Web Components
command: |
npm run test:unit -- -- --runInBand
install_cli:
# This installs Salesforce CLI.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Install Salesforce CLI
command: |
export SFDX_USE_GENERIC_UNIX_KEYCHAIN=true
export SFDX_DOMAIN_RETRY=300
npm install sfdx-cli
node_modules/sfdx-cli/bin/run --version
node_modules/sfdx-cli/bin/run plugins --core
- persist_to_workspace:
# This is an important step. If we don't store the project data (node_modules from the CLI installation)
# we'd have to re-run installation for every workflow step.
root: ~/
paths:
- project/*
lint_aura:
# This lints Aura components.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Lint Aura Components
command: |
npm run lint:aura
setup_dx_orgs:
# This authenticates the Dev Hub, packaging org, and creates a scratch org.
#
# While a scratch org isn't needed in all steps it's still part of the process. The reason for this is
# that we need to store the sfdx configuration files for it in the workspace, so that data can be shared
# across different workflow steps.
#
# Keep it simple!
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Decrypt certificate
command: |
openssl enc -nosalt -aes-256-cbc -d -in .circleci/server.key.enc -out .circleci/server.key -base64 -K $DECRYPTION_KEY -iv $DECRYPTION_IV
- run:
name: Authenticate DevHub
command: |
if [[ $CIRCLE_BRANCH == prerelease* ]]; then
node_modules/sfdx-cli/bin/run force:auth:jwt:grant --clientid $CONSUMERKEY_PRERELEASE --jwtkeyfile .circleci/server.key --username $USERNAME_PRERELEASE --setdefaultdevhubusername -a HubOrg
else
node_modules/sfdx-cli/bin/run force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile .circleci/server.key --username $USERNAME --setdefaultdevhubusername -a HubOrg
fi
- run:
name: Define CI Org
# We define the to be used CI org. Based on the branch we either create a new scratch org
# or we use a project variable to authenticate a UAT or full-copy sandbox as target org.
#
# You can get the sfdxurl via sfdx force:org:display -u yourOrg --json --verbose from your local machine.
command: |
echo $SFDX_AUTH_PACKAGING > ~/auth.url
node_modules/sfdx-cli/bin/run force:auth:sfdxurl:store -s -a packagingorg -f ~/auth.url
node_modules/sfdx-cli/bin/run force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg -d 1
- persist_to_workspace:
# This is an important step. If we don't store the project data (cloned GitHub source and node_modules from the CLI installation)
# we'd have to re-run installation for every workflow step.
#
# Also this step is crucial as we use it to share sfdx config parameters between steps.
root: ~/
paths:
- .sfdx/*
- project/*
deploy_source:
# This deploys the source to the ci scratch org.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Push Source
command: |
node_modules/sfdx-cli/bin/run force:source:push -u ciorg
deploy_community_metadata:
# This deploys the non-source metadata to the ci scratch org.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Push Source
command: |
node_modules/sfdx-cli/bin/run force:mdapi:deploy -u ciorg --deploydir mdapiDeploy/unpackaged -w 1
create_and_test_package:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
if [[ $SFDX_TEST_PACKAGING == "true" ]]; then
scripts/packagingDeployment.sh
fi
no_output_timeout: 15m
run_apex_tests:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Run Apex Tests
command: |
node_modules/sfdx-cli/bin/run force:apex:test:run -u ciorg -c -r human
cleanup_scratch_org:
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Clean Up
command: |
node_modules/sfdx-cli/bin/run force:org:delete -u ciorg -p
workflows:
version: 2
build_and_test:
jobs:
- setup_tooling:
filters:
branches:
ignore: master
- prettier_verify:
requires:
- setup_tooling
filters:
branches:
ignore: master
- lint_lwc:
requires:
- prettier_verify
filters:
branches:
ignore: master
- unit_test_lwc:
requires:
- lint_lwc
filters:
branches:
ignore: master
- install_cli:
requires:
- unit_test_lwc
filters:
branches:
ignore: master
- lint_aura:
requires:
- install_cli
filters:
branches:
ignore: master
- setup_dx_orgs:
context: trailhead-global
requires:
- lint_aura
filters:
branches:
ignore: master
- deploy_source:
requires:
- setup_dx_orgs
filters:
branches:
ignore: master
- deploy_community_metadata:
requires:
- deploy_source
filters:
branches:
ignore: master
- create_and_test_package:
requires:
- setup_dx_orgs
filters:
branches:
only: master
- run_apex_tests:
requires:
- deploy_source
filters:
branches:
ignore: master
- cleanup_scratch_org:
requires:
- setup_dx_orgs
- deploy_source
- deploy_community_metadata
- create_and_test_package
- run_apex_tests