This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
config.yml
233 lines (230 loc) · 7.56 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
version: 2
# Defining default values for all jobs
defaults: &defaults
docker:
- image: circleci/node:latest
jobs:
setup_dx:
# This command runs the preparation steps needed for the CI workflow:
#
# - Installation of the Salesforce CLI using npm
# - Authentication of the DevHub
# - Creation of 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:
- checkout
- run:
name: Install Salesforce DX
command: |
openssl aes-256-cbc -k $KEY -in .circleci/server.key.enc -out .circleci/server.key -d
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
- run:
name: Authenticate DevHub
command: |
node_modules/sfdx-cli/bin/run force:auth:jwt:grant --clientid $CONSUMERKEY --jwtkeyfile .circleci/server.key --username $USERNAME --setdefaultdevhubusername -a HubOrg
- 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: |
if [[ "${CIRCLE_BRANCH}" = "develop" ]]; then
echo $SFDX_AUTH_URL_FULL_COPY > ~/auth.url
node_modules/sfdx-cli/bin/run force:auth:sfdxurl:store -s -a ciorg -f ~/auth.url
elif [[ "${CIRCLE_BRANCH}" = "packaging" ]]; then
echo $SFDX_AUTH_URL_UAT > ~/auth.url
node_modules/sfdx-cli/bin/run force:auth:sfdxurl:store -s -a ciorg -f ~/auth.url
elif [[ "${CIRCLE_BRANCH}" = *"feature/"* ]]; then
node_modules/sfdx-cli/bin/run force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg -d 1
elif [[ "${CIRCLE_BRANCH}" = *"packaging/"* ]]; then
node_modules/sfdx-cli/bin/run force:org:create -v HubOrg -s -f config/project-scratch-def.json -a ciorg -d 1
fi
- 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
create_package_es-base-objects:
# Creating a package for es-base-objects, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
create_package_es-base-code:
# Creating a package for es-base-code, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
create_package_es-base-styles:
# Creating a package for es-base-styles, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
create_package_es-space-mgmt:
# Creating a package for es-space-mgmt, based on the GitHub branch name.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Create and install package
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
install_packages_uat:
# Deploys packages to UAT sandbox.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Deploy UAT
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
install_packages_full-copy-sandbox:
# Deploys packages to full copy sandbox.
<<: *defaults
steps:
- attach_workspace:
at: ~/
- run:
name: Deploy full-copy
command: |
scripts/packagingDeployment.sh $CIRCLE_BRANCH
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_dx:
filters:
branches:
only:
- /feature/.*/
- /packaging/.*/
- packaging
- develop
- deploy_source:
requires:
- setup_dx
filters:
branches:
only: /feature/.*/
- create_package_es-base-objects:
requires:
- setup_dx
filters:
branches:
only: packaging/es-base-objects
- create_package_es-base-code:
requires:
- setup_dx
filters:
branches:
only: packaging/es-base-code
- create_package_es-base-styles:
requires:
- setup_dx
filters:
branches:
only: packaging/es-base-styles
- create_package_es-space-mgmt:
requires:
- setup_dx
filters:
branches:
only: packaging/es-space-mgmt
- install_packages_uat:
requires:
- setup_dx
filters:
branches:
only: packaging
- install_packages_full-copy-sandbox:
requires:
- setup_dx
filters:
branches:
only: develop
- run_apex_tests:
requires:
- deploy_source
- create_package_es-base-objects
- create_package_es-base-code
- create_package_es-base-styles
- create_package_es-space-mgmt
- install_packages_uat
- install_packages_full-copy-sandbox
filters:
branches:
ignore: master
- cleanup_scratch_org:
requires:
- setup_dx
- deploy_source
- create_package_es-base-objects
- create_package_es-base-code
- create_package_es-base-styles
- create_package_es-space-mgmt
- run_apex_tests
filters:
branches:
ignore:
- master
- develop
- packaging