1
1
version : 2.1
2
2
3
3
executors :
4
+ default :
5
+ docker :
6
+ - image : cimg/base:stable
7
+ resource_class : medium
4
8
node :
5
9
docker :
6
10
- image : mcr.microsoft.com/playwright:v1.44.0
7
11
resource_class : xlarge
8
12
environment :
9
13
NODE_ENV : development
14
+ AZCOPY_AUTO_LOGIN_TYPE : SPN
15
+ AZCOPY_SPA_APPLICATION_ID : $AZURE_CLIENT_ID
16
+ AZCOPY_SPA_CLIENT_SECRET : $AZURE_CLIENT_SECRET
17
+ AZCOPY_TENANT_ID : $AZURE_TENANT_ID
10
18
parameters :
11
19
# In order to update the VRT baseline images:
12
20
# 1. Copy the hash of the latest golden images cache from the left sidebar in the VRT preview link (not to be confused with the arbitrary hash in the URL).
@@ -19,6 +27,27 @@ parameters:
19
27
type : string
20
28
default : wireit
21
29
commands :
30
+ install-azcopy :
31
+ description : ' Install AzCopy and set up authentication'
32
+ steps :
33
+ - run :
34
+ when : always
35
+ name : Install AzCopy
36
+ command : |
37
+ # Create a bin directory in the home folder
38
+ mkdir -p ~/bin
39
+ cd ~/bin
40
+ wget -O azcopy.tar.gz https://github.com/Azure/azure-storage-azcopy/releases/download/v10.29.1/azcopy_linux_amd64_10.29.1.tar.gz
41
+ tar -xf azcopy.tar.gz --strip-components=1
42
+ chmod +x azcopy
43
+ # Add to PATH and set environment variables
44
+ echo 'export PATH=~/bin:$PATH' >> $BASH_ENV
45
+ echo 'export AZCOPY_AUTO_LOGIN_TYPE="SPN"' >> $BASH_ENV
46
+ echo 'export AZCOPY_SPA_APPLICATION_ID="$AZURE_CLIENT_ID"' >> $BASH_ENV
47
+ echo 'export AZCOPY_SPA_CLIENT_SECRET="$AZURE_CLIENT_SECRET"' >> $BASH_ENV
48
+ echo 'export AZCOPY_TENANT_ID="$AZURE_TENANT_ID"' >> $BASH_ENV
49
+ source $BASH_ENV
50
+ azcopy --version
22
51
downstream :
23
52
steps :
24
53
- checkout
@@ -97,32 +126,66 @@ commands:
97
126
branch=$(git symbolic-ref --short HEAD)
98
127
node test/visual/review.js --branch=$branch --commit=<< pipeline.git.revision >> --system="<< parameters.regression_system >> << parameters.regression_color >> << parameters.regression_scale >> << parameters.regression_dir >>"
99
128
yarn rollup -c test/visual/rollup.config.js
129
+ - install-azcopy
100
130
- run :
101
131
when : always
102
- name : Publish review site
132
+ name : Deploy VRT Results to Azure Blob Storage
103
133
command : |
104
- cp projects/documentation/content/favicon.ico test/visual
105
- branch=$(git symbolic-ref --short HEAD)
106
- hash=$(echo -n $branch-<< parameters.regression_system >>-<< parameters.regression_color >>-<< parameters.regression_scale >>-<< parameters.regression_dir >> | md5sum | cut -c 1-32)
107
- echo "Netlify alias hash: $hash"
108
- echo "Deploying from test/visual directory..."
109
-
110
- max_attempts=3
111
- attempt=0
112
-
113
- while [ $attempt -lt $max_attempts ]; do
114
- if yarn netlify deploy --alias=$hash --cwd test/visual; then
115
- echo "Deployment successful!"
116
- exit 0
134
+ # Get PR number from CircleCI environment
135
+ PR_NUMBER=""
136
+ if [ -n "$CIRCLE_PULL_REQUEST" ]; then
137
+ PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed 's/.*\/pull\///')
138
+ echo "Deploying VRT for PR #$PR_NUMBER"
139
+ elif [ -n "$CIRCLE_PR_NUMBER" ]; then
140
+ PR_NUMBER="$CIRCLE_PR_NUMBER"
141
+ echo "Deploying VRT for PR #$PR_NUMBER"
142
+ elif [[ "$CIRCLE_BRANCH" =~ ^pull/[0-9]+$ ]]; then
143
+ PR_NUMBER=$(echo $CIRCLE_BRANCH | sed 's/pull\///')
144
+ echo "Deploying VRT for forked PR #$PR_NUMBER"
145
+ elif [ -n "$GITHUB_TOKEN" ]; then
146
+ # GitHub API fallback
147
+ PR_NUMBER=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
148
+ -H "Accept: application/vnd.github+json" \
149
+ "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \
150
+ | grep -o '"number":[0-9]*' | head -1 | sed 's/"number"://')
151
+
152
+ if [ -n "$PR_NUMBER" ]; then
153
+ echo "Deploying VRT for PR #$PR_NUMBER (via GitHub API)"
117
154
else
118
- attempt=$((attempt + 1))
119
- echo "Deploy failed, retrying ($attempt/$max_attempts)..."
120
- sleep 10 # Adjust delay if needed
155
+ echo "⏭️ No PR found - skipping VRT deployment"
156
+ exit 0
121
157
fi
122
- done
158
+ else
159
+ echo "⏭️ No PR detected - skipping VRT deployment"
160
+ exit 0
161
+ fi
162
+
163
+ # Only proceed if we have a valid PR number
164
+ if [ -z "$PR_NUMBER" ]; then
165
+ echo "⏭️ No PR number available - skipping VRT deployment"
166
+ exit 0
167
+ fi
123
168
124
- echo "Deployment failed after $max_attempts attempts."
125
- exit 1
169
+ # Create PR hash using just PR number for overwriting deployments
170
+ PR_HASH="pr-${PR_NUMBER}"
171
+
172
+ # VRT combination for subdirectory
173
+ combination="<< parameters.regression_system >>-<< parameters.regression_color >>-<< parameters.regression_scale >>-<< parameters.regression_dir >>"
174
+
175
+ # Prepare files for deployment
176
+ cp projects/documentation/content/favicon.ico test/visual/ || echo "Failed to copy favicon"
177
+
178
+ # Upload VRT results to Azure Blob Storage
179
+ echo "Uploading VRT results to ${PR_HASH}/${combination}/"
180
+ azcopy copy "test/visual/*" \
181
+ "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/${combination}/" \
182
+ --recursive \
183
+ --from-to LocalBlob
184
+
185
+ # Generate the deployment URL
186
+ VRT_URL="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/${combination}/"
187
+ echo "$VRT_URL" > vrt_url.txt
188
+ echo "VRT URL for ${combination}: $VRT_URL"
126
189
127
190
# move "updated" screenshot into the baseline directory before making the new cache
128
191
- run :
@@ -195,27 +258,17 @@ jobs:
195
258
- store_test_results :
196
259
path : /root/project/results/
197
260
198
- preview-docs :
261
+ lint :
199
262
executor : node
263
+
200
264
steps :
201
265
- downstream
202
266
- run :
203
- name : Generate Custom Elements Manifest
204
- command : yarn docs:analyze
267
+ name : Lint
268
+ command : yarn lint
205
269
- run :
206
- name : Move CEM to Storybook directory
207
- command : cp projects/documentation/custom-elements.json storybook/
208
- - run :
209
- name : Build documentation
210
- command : yarn docs:build
211
- - run :
212
- name : Build Storybook
213
- command : yarn storybook:build
214
- - run : echo '/* /index.html 200' > projects/documentation/dist/_redirects
215
- - run : |
216
- branch=$(git symbolic-ref --short HEAD)
217
- branch=$(npx slugify-cli $branch)
218
- yarn netlify deploy --alias=$branch --cwd projects/documentation
270
+ name : Are there changes?
271
+ command : git diff-files --exit-code
219
272
220
273
beta-docs :
221
274
executor : node
@@ -234,11 +287,29 @@ jobs:
234
287
- run :
235
288
name : Build Storybook
236
289
command : yarn storybook:build
237
- - run : echo '/* /index.html 200' > projects/documentation/dist/_redirects
238
- - run : |
239
- branch=$(git symbolic-ref --short HEAD)
240
- branch=$(npx slugify-cli $branch)
241
- yarn netlify deploy --alias=beta --cwd projects/documentation
290
+ - install-azcopy
291
+ - run :
292
+ name : Deploy Beta Documentation to Azure Blob Storage
293
+ command : |
294
+ # Upload documentation to beta path
295
+ echo "Uploading documentation to beta/docs/"
296
+ azcopy copy "projects/documentation/dist/*" \
297
+ "https://swcpreviews.blob.core.windows.net/\$web/beta/docs/" \
298
+ --recursive \
299
+ --from-to LocalBlob
300
+
301
+ # Upload Storybook to beta path
302
+ echo "Uploading Storybook to beta/docs/storybook/"
303
+ azcopy copy "storybook-static/*" \
304
+ "https://swcpreviews.blob.core.windows.net/\$web/beta/docs/storybook/" \
305
+ --recursive \
306
+ --from-to LocalBlob
307
+
308
+ # Generate the deployment URLs
309
+ DOCS_URL="https://swcpreviews.z13.web.core.windows.net/beta/docs/"
310
+ STORYBOOK_URL="https://swcpreviews.z13.web.core.windows.net/beta/docs/storybook/"
311
+ echo "Beta Documentation URL: $DOCS_URL"
312
+ echo "Beta Storybook URL: $STORYBOOK_URL"
242
313
243
314
hcm-visual :
244
315
executor : node
@@ -281,32 +352,64 @@ jobs:
281
352
branch=$(git symbolic-ref --short HEAD)
282
353
node test/visual/review.js --branch=$branch --commit=<< pipeline.git.revision >> --system="hcm"
283
354
yarn rollup -c test/visual/rollup.config.js
355
+ - install-azcopy
284
356
- run :
285
357
when : always
286
- name : Publish review site
358
+ name : Deploy Visual Tests to Azure Blob Storage
287
359
command : |
288
- cp projects/documentation/content/favicon.ico test/visual
289
- branch=$(git symbolic-ref --short HEAD)
290
- hash=$(echo -n $branch-hcm | md5sum | cut -c 1-32)
291
- echo "Netlify alias hash: $hash"
292
- echo "Deploying from test/visual directory..."
293
-
294
- max_attempts=3
295
- attempt=0
296
-
297
- while [ $attempt -lt $max_attempts ]; do
298
- if yarn netlify deploy --alias=$hash --cwd test/visual; then
299
- echo "Deployment successful!"
300
- exit 0
360
+ # Get PR number from CircleCI environment
361
+ set +x
362
+ PR_NUMBER=""
363
+ if [ -n "$CIRCLE_PULL_REQUEST" ]; then
364
+ PR_NUMBER=$(echo $CIRCLE_PULL_REQUEST | sed 's/.*\/pull\///')
365
+ echo "Deploying HCM VRT for PR #$PR_NUMBER"
366
+ elif [ -n "$CIRCLE_PR_NUMBER" ]; then
367
+ PR_NUMBER="$CIRCLE_PR_NUMBER"
368
+ echo "Deploying HCM VRT for PR #$PR_NUMBER"
369
+ elif [[ "$CIRCLE_BRANCH" =~ ^pull/[0-9]+$ ]]; then
370
+ PR_NUMBER=$(echo $CIRCLE_BRANCH | sed 's/pull\///')
371
+ echo "Deploying HCM VRT for forked PR #$PR_NUMBER"
372
+ elif [ -n "$GITHUB_TOKEN" ]; then
373
+ # GitHub API fallback
374
+ PR_NUMBER=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
375
+ -H "Accept: application/vnd.github+json" \
376
+ "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \
377
+ | grep -o '"number":[0-9]*' | head -1 | sed 's/"number"://')
378
+
379
+ if [ -n "$PR_NUMBER" ]; then
380
+ echo "Deploying HCM VRT for PR #$PR_NUMBER (via GitHub API)"
301
381
else
302
- attempt=$((attempt + 1))
303
- echo "Deploy failed, retrying ($attempt/$max_attempts)..."
304
- sleep 10 # Adjust delay if needed
382
+ echo "⏭️ No PR found - skipping HCM VRT deployment"
383
+ exit 0
305
384
fi
306
- done
385
+ else
386
+ echo "⏭️ No PR detected - skipping HCM VRT deployment"
387
+ exit 0
388
+ fi
389
+
390
+ # Only proceed if we have a valid PR number
391
+ if [ -z "$PR_NUMBER" ]; then
392
+ echo "⏭️ No PR number available - skipping HCM VRT deployment"
393
+ exit 0
394
+ fi
395
+
396
+ # Create PR hash using just PR number for overwriting deployments
397
+ PR_HASH="pr-${PR_NUMBER}"
398
+
399
+ # Prepare files for deployment
400
+ cp projects/documentation/content/favicon.ico test/visual/
307
401
308
- echo "Deployment failed after $max_attempts attempts."
309
- exit 1
402
+ # Upload HCM VRT results to Azure Blob Storage
403
+ echo "Uploading HCM VRT to ${PR_HASH}/hcm/"
404
+ azcopy copy "test/visual/*" \
405
+ "https://swcpreviews.blob.core.windows.net/\$web/${PR_HASH}/hcm/" \
406
+ --recursive \
407
+ --from-to LocalBlob
408
+
409
+ # Generate the deployment URL
410
+ VRT_URL="https://swcpreviews.z13.web.core.windows.net/${PR_HASH}/hcm/"
411
+ echo "$VRT_URL" > vrt_url.txt
412
+ echo "HCM Visual Test URL: $VRT_URL"
310
413
311
414
# move "updated" screenshot into the baseline directory before making the new cache
312
415
- run :
@@ -357,11 +460,6 @@ workflows:
357
460
branches :
358
461
# Forked pull requests have CIRCLE_BRANCH set to pull/XXX
359
462
ignore : /pull\/[0-9]+/
360
- - preview-docs :
361
- filters :
362
- branches :
363
- # Forked pull requests have CIRCLE_BRANCH set to pull/XXX
364
- ignore : /pull\/[0-9]+/
365
463
- beta-docs :
366
464
filters :
367
465
branches :
0 commit comments