-
Notifications
You must be signed in to change notification settings - Fork 196
681 lines (583 loc) · 27.9 KB
/
ui-test.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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
name: uitest
on:
workflow_dispatch:
inputs:
target-vsix-run-id:
description: "target vsix github action run id"
required: true
type: string
target-cli-version:
description: "target cli version or tag, like latest, beta or alpha"
required: true
type: string
target-sample-ref:
description: "target sample ref, like v1.1.0, v2.0.0 or dev"
required: false
type: string
default: dev
test-case:
description: 'test case, e.g. ["localdebug-tab", "localdebug-bot"], Set empty to run all predefined cases'
required: false
type: string
os:
default: '["macos-latest", "ubuntu-latest", "windows-latest"]'
description: 'os, e.g. ["macos-latest", "ubuntu-latest", "windows-latest"]'
required: false
type: string
node-version:
default: "[18]"
description: "node version, e.g. [18]"
required: false
type: string
email-receiver:
description: "email notification receiver"
required: false
type: string
source-testplan-id:
description: "source testplan id: 24569079."
required: false
type: string
default: "24569079"
target-testplan-name:
description: "For example: CY230919. Sync test result to this test plan."
required: false
type: string
schedule:
- cron: "0 18 * * *"
permissions:
actions: read
jobs:
setup:
runs-on: ubuntu-latest
permissions:
contents: read
env:
AUTO_TEST_PLAN_ID: ${{ github.event.inputs.source-testplan-id }}
TARGET_TEST_PLAN_NAME: ${{ github.event.inputs.target-testplan-name }}
DEVTUNNEL_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
DEVTUNNEL_CLIENT_SECRET: ${{ secrets.TEST_CLEAN_CLIENT_SECRET }}
DEVTUNNEL_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}
steps:
- name: Init GitHub CLI
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
- name: bvt (dispatch)
id: bvt
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "npm-tag=${{ github.event.inputs.target-cli-version }}" >> $GITHUB_OUTPUT
echo "sample-ref=${{ github.event.inputs.target-sample-ref }}" >> $GITHUB_OUTPUT
echo "branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "vsix-run-id=${{ github.event.inputs.target-vsix-run-id }}" >> $GITHUB_ENV
echo "target_cli_version=${{ github.event.inputs.target-cli-version }}" >> $GITHUB_ENV
echo "email-receiver=${{ github.event.inputs.email-receiver }}" >> $GITHUB_OUTPUT
- name: pvt (dev)
id: pvt
if: ${{ github.event.schedule == '0 18 * * *' }}
run: |
echo "npm-tag=alpha" >> $GITHUB_OUTPUT
echo "sample-ref=dev" >> $GITHUB_OUTPUT
echo "branch=dev" >> $GITHUB_OUTPUT
echo "[email protected]" >> $GITHUB_OUTPUT
run_id=`gh run list --workflow cd --repo OfficeDev/TeamsFx --branch dev --json event --json databaseId --json conclusion --jq '[.[] | select(.event=="schedule") | select(.conclusion=="success")][0].databaseId'`
echo "vsix-run-id=$run_id" >> $GITHUB_ENV
echo "target_cli_version=alpha" >> $GITHUB_ENV
- name: Checkout branch
uses: actions/checkout@v3
with:
ref: ${{ steps.bvt.outputs.branch || steps.pvt.outputs.branch }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v4
- name: create pvt file (random platform/node)
if: ${{ github.event.schedule == '0 18 * * *' }} || ${{ github.event.inputs.test-case }} == ''
working-directory: ./packages/tests
run: |
pnpm --filter=@microsoft/teamsfx-test install
npx ts-node ./scripts/createRandomPVT.ts
- name: setup matrix
id: setup-matrix
working-directory: ./packages/tests
run: |
matrix=""
if [ ! -z "${{ github.event.inputs.test-case }}" ]; then
matrix='{"node-version": ${{ github.event.inputs.node-version }}, "test-case": ${{ github.event.inputs.test-case }}, "os": ${{ github.event.inputs.os }} }'
else
bash ./scripts/convert-test-case.sh ./scripts/pvt.json
matrix=$(cat ./scripts/test-case-temp.json)
fi
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
- name: Download TTK
run: |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
gh run download ${{ env.vsix-run-id }} --repo OfficeDev/TeamsFx --name release
- name: Export TTK version
id: ttk
run: |
package=`find . -type f -name "*.vsix" | sed 's|.*/\(.*\)|\1|'`
version=`echo $package | sed 's|ms-teams-vscode-extension-||' | sed 's|\.vsix||'`
echo "package=$package" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
- name: Upload TTK to artifact
uses: actions/upload-artifact@v4
with:
name: ttk
path: |
./${{ steps.ttk.outputs.package }}
- name: clean devtunnel
run: |
wget https://tunnelsassetsprod.blob.core.windows.net/cli/1.0.1249+67b1cd300c/linux-x64-devtunnel -O ./devtunnel
chmod 777 ./devtunnel
./devtunnel user login --sp-tenant-id ${{env.DEVTUNNEL_TENANT_ID}} --sp-client-id ${{env.DEVTUNNEL_CLIENT_ID}} --sp-secret ${{env.DEVTUNNEL_CLIENT_SECRET}}
./devtunnel delete-all -f
outputs:
npm-tag: ${{ steps.bvt.outputs.npm-tag || steps.pvt.outputs.npm-tag }}
sample-ref: ${{ steps.bvt.outputs.sample-ref || steps.pvt.outputs.sample-ref }}
branch: ${{ steps.bvt.outputs.branch || steps.pvt.outputs.branch }}
email-receiver: ${{ steps.bvt.outputs.email-receiver || steps.pvt.outputs.email-receiver }}
vsix-run-id: ${{ env.vsix-run-id }}
matrix: ${{ steps.setup-matrix.outputs.matrix }}
ttk-package: ${{ steps.ttk.outputs.package }}
ttk-version: ${{ steps.ttk.outputs.version }}
target_cli_version: ${{ env.target_cli_version }}
main:
name: ${{ matrix.test-case }}|${{ matrix.os }}|node ${{ matrix.node-version }}|${{ github.ref_name }}
needs: setup
permissions:
contents: read
timeout-minutes: 50
env:
CI_ENABLED: true
NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}
TARGET_CLI_VERSION: ${{ needs.setup.outputs.target_cli_version }}
CLEAN_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
CLEAN_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}
DEVTUNNEL_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
DEVTUNNEL_CLIENT_SECRET: ${{ secrets.TEST_CLEAN_CLIENT_SECRET }}
DEVTUNNEL_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}
M365_ACCOUNT_PASSWORD: ${{ secrets.TEST_M365_PASSWORD }}
M365_USERNAME: "[email protected]"
M365_USERNAME_2: "[email protected]"
M365_USERNAME_3: "[email protected]"
M365_USERNAME_4: "[email protected]"
M365_DISPLAY_NAME: "ttktest"
M365_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}
M365_COLLABORATOR: "[email protected]"
AZURE_TENANT_ID: ${{ secrets.TEST_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.TEST_SUBSCRIPTION_ID }}
AZURE_SUBSCRIPTION_NAME: ${{ secrets.TEST_SUBSCRIPTION_NAME }}
AZURE_ACCOUNT_NAME: ${{ secrets.TEST_USER_NAME }}
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
STORAGE_ACCOUNT_KEY: ${{ secrets.TEST_STORAGE_ACCOUNT_KEY }}
AZURE_OPENAI_DEPLOYMENT_NAME: "gpt-4-32k"
AZURE_OPENAI_ENDPOINT: "https://aoai-jasozdr.openai.azure.com/"
AZURE_OPENAI_EMBEDDING_DEPLOYMENT: "text-embedding-ada-002"
TEAMSFX_DEV_TUNNEL_TEST: true
TEAMSFX_TELEMETRY_TEST: true
strategy:
fail-fast: false
max-parallel: 80
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- name: Set m365 account (unix)
if: matrix.os != 'windows-latest'
run: |
users=("${{ env.M365_USERNAME }}" "${{ env.M365_USERNAME_2 }}" "${{ env.M365_USERNAME_3 }}" "${{ env.M365_USERNAME_4 }}")
count=${#users[@]}
index=$((RANDOM%$count))
echo "account index: $index"
echo "M365_ACCOUNT_NAME=${users[index]}" >> $GITHUB_ENV
- name: Set m365 account (win)
if: matrix.os == 'windows-latest'
run: |
$users=@("${{ env.M365_USERNAME }}","${{ env.M365_USERNAME_2 }}","${{ env.M365_USERNAME_3 }}","${{ env.M365_USERNAME_4 }}")
$index=Get-Random -min 0 -max $users.count
$user=$users[$index]
echo "account index: $index"
echo "M365_ACCOUNT_NAME=$user" >> $env:GITHUB_ENV
- name: Checkout branch
uses: actions/checkout@v3
with:
ref: ${{ needs.setup.outputs.branch }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup Python
if: contains(matrix.test-case, 'py')
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python environment
if: contains(matrix.test-case, 'py')
run: |
pip install python-dotenv aiohttp azure-search azure-search-documents teams-ai~=1.2.0
- name: Install function core tool (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get update
sudo apt-get install azure-functions-core-tools-4
- name: Install devtunnel (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
wget https://tunnelsassetsprod.blob.core.windows.net/cli/1.0.1249+67b1cd300c/linux-x64-devtunnel -O ./devtunnel
chmod +x ./devtunnel
mkdir -p ~/bin
mv ./devtunnel ~/bin/devtunnel
PATH=~/bin:$PATH
~/bin/devtunnel user login --sp-tenant-id ${{env.DEVTUNNEL_TENANT_ID}} --sp-client-id ${{env.DEVTUNNEL_CLIENT_ID}} --sp-secret ${{env.DEVTUNNEL_CLIENT_SECRET}}
- name: Install devtunnel (mac)
if: matrix.os == 'macos-latest'
run: |
curl https://tunnelsassetsprod.blob.core.windows.net/cli/1.0.1249+67b1cd300c/osx-x64-devtunnel-zip -o ./devtunnel.zip
unzip ./devtunnel.zip
chmod +x ./devtunnel
mkdir -p ~/bin
mv ./devtunnel ~/bin/devtunnel
PATH=~/bin:$PATH
~/bin/devtunnel user login --sp-tenant-id ${{env.DEVTUNNEL_TENANT_ID}} --sp-client-id ${{env.DEVTUNNEL_CLIENT_ID}} --sp-secret ${{env.DEVTUNNEL_CLIENT_SECRET}}
- name: Install devtunnel (windows)
if: matrix.os == 'windows-latest'
working-directory: packages/tests
run: |
powershell Invoke-WebRequest -Uri https://tunnelsassetsprod.blob.core.windows.net/cli/1.0.1249+67b1cd300c/devtunnel.exe -OutFile devtunnel.exe
$currentDirectory = (Get-Location).Path
$executablePath = Join-Path $currentDirectory "devtunnel.exe"
[System.Environment]::SetEnvironmentVariable("Path", "$currentPath;$executablePath", [System.EnvironmentVariableTarget]::Machine)
./devtunnel user login --sp-tenant-id ${{env.DEVTUNNEL_TENANT_ID}} --sp-client-id ${{env.DEVTUNNEL_CLIENT_ID}} --sp-secret ${{env.DEVTUNNEL_CLIENT_SECRET}}
- name: Downgrade PowerShell (win)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
set "extractPath=C:\Program Files\PowerShell\7"
curl -sLO https://github.com/PowerShell/PowerShell/releases/download/v7.2.17/PowerShell-7.2.17-win-x64.zip
RMDIR "%extractPath%" /S /Q
7z x PowerShell-7.2.17-win-x64.zip -o"%extractPath%"
pwsh --version
- name: Set cert (win)
if: matrix.os == 'windows-latest'
run: |
Write-Host $home
$filePath = Join-Path -Path $home -ChildPath "certinstall.ps1"
$content = '$cert = New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "Cert:LocalMachine\My" -NotAfter (Get-Date).AddMonths(6) -KeyAlgorithm RSA -KeyLength 4096 -HashAlgorithm "sha256" -FriendlyName "localhost" -TextExtension @("2.5.29.19={text}", "2.5.29.37={text}1.3.6.1.5.5.7.3.1");$mypwd = ConvertTo-SecureString -String "1234" -Force -AsPlainText;$cert | Export-PfxCertificate -FilePath $home/test1.pfx -Password $mypwd;openssl pkcs12 -in $home/test1.pfx -nocerts -out $home/.fx/certificate/localhost.key -passin pass:1234 -nodes;openssl pkcs12 -info -in $home/test1.pfx -nokeys -out $home/.fx/certificate/localhost.crt -passin pass:1234;$filePath = Join-Path -Path $home -ChildPath ".fx/certificate/localhost.crt";Import-Certificate -FilePath $filePath -CertStoreLocation Cert:\\LocalMachine\\Root'
New-Item $filePath -ItemType File -Value $content
$certfolder = Join-Path -Path $home -ChildPath ".fx/certificate"
New-Item -Path $certfolder -ItemType Directory
Start-Process powershell -verb RunAs -ArgumentList $filePath -wait
- name: Update npm packages for UI Test
working-directory: packages/tests
run: |
npm install @microsoft/teamsfx-core@latest @microsoft/teamsfx-api@latest @microsoft/teamsapp-cli@latest
- name: Install npm packages
working-directory: packages/tests
run: |
npm install
- name: Download browsers for playwright
working-directory: packages/tests
run: |
npx playwright install
- name: Download TTK
uses: actions/download-artifact@v4
with:
name: ttk
path: ./packages/tests
- name: Install teamsfx cli
working-directory: packages/tests
run: |
npm install @microsoft/teamsapp-cli@${{ needs.setup.outputs.npm-tag }}
- name: Download samples
if: startsWith(matrix.test-case, 'sample-') && contains(matrix.test-case, 'proactive-message') == false && contains(matrix.test-case, 'reddit-link') == false && contains(matrix.test-case, 'chef-bot') == false && contains(matrix.test-case, 'food-catalog') == false && contains(matrix.test-case, 'outlook-signature') == false
uses: actions/checkout@v3
with:
repository: OfficeDev/TeamsFx-Samples
ref: ${{ needs.setup.outputs.sample-ref }}
path: ./packages/tests/resource
- name: Download samples from another repo
if: contains(matrix.test-case, 'proactive-message') || contains(matrix.test-case, 'reddit-link')
uses: actions/checkout@v3
with:
repository: OfficeDev/Microsoft-Teams-Samples
ref: main
path: ./packages/tests/resource
- name: Download samples chef bot
if: contains(matrix.test-case, 'chef-bot')
uses: actions/checkout@v3
with:
repository: microsoft/teams-ai
ref: main
path: ./packages/tests/resource
- name: Download samples food catalog
if: contains(matrix.test-case, 'food-catalog')
uses: actions/checkout@v3
with:
repository: pnp/graph-connectors-samples
ref: main
path: ./packages/tests/resource
- name: Download samples outlook signature
if: contains(matrix.test-case, 'outlook-signature')
uses: actions/checkout@v3
with:
repository: OfficeDev/Office-Add-in-samples
ref: main
path: ./packages/tests/resource
- name: Get VSCode
working-directory: packages/tests
run: |
npx extest get-vscode --storage .test-resources --type stable
- name: Get chromedriver
working-directory: packages/tests
run: |
npx extest get-chromedriver --storage .test-resources --type stable
- name: M365 Login
working-directory: packages/tests
run: | # rm -r -f ~/.fx/account
npx ts-node src/scripts/m365Login.ts -- '${{ env.M365_ACCOUNT_NAME }}' '${{ env.M365_ACCOUNT_PASSWORD }}'
- name: Build
working-directory: packages/tests
run: |
npm run build
- name: Install python extension
working-directory: packages/tests
run: |
npx extest install-from-marketplace --storage .test-resources --extensions_dir .test-resources --type stable ms-python.python
- name: Install docker extension
if: contains(matrix.test-case, 'docker')
working-directory: packages/tests
run: |
npx extest install-from-marketplace --storage .test-resources --extensions_dir .test-resources --type stable ms-azuretools.vscode-docker
- name: Install vsix(unix)
if: matrix.os != 'windows-latest'
working-directory: packages/tests
run: |
vsix=`find . -type f -name "*.vsix" | sed 's|.*/\(.*\)|\1|'`
npx extest install-vsix --storage .test-resources --extensions_dir .test-resources --type stable --vsix_file $vsix
- name: Install vsix(win)
if: matrix.os == 'windows-latest'
working-directory: packages/tests
run: |
$vsix = (Get-ChildItem *.vsix | Select-Object -ExpandProperty Name)
npx extest install-vsix --storage .test-resources --extensions_dir .test-resources --type stable --vsix_file $vsix
- name: Setup OpenAI key(unix)
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'schedule' }}
uses: alsosee/envset@v1
with:
name: SECRET_AZURE_OPENAI_API_KEY
value: ${{ secrets.SECRET_AZURE_OPENAI_API_KEY }}
- name: Setup OpenAI key(macos)
if: ${{ matrix.os == 'macos-latest' && github.event_name != 'schedule' }}
run: |
echo "SECRET_AZURE_OPENAI_API_KEY=${{ secrets.SECRET_AZURE_OPENAI_API_KEY }}" >> $GITHUB_ENV
- name: Setup OpenAI key(win)
if: ${{ matrix.os == 'windows-latest' && github.event_name != 'schedule' }}
run: |
echo "SECRET_AZURE_OPENAI_API_KEY=${{ secrets.SECRET_AZURE_OPENAI_API_KEY }}" >> $env:GITHUB_ENV
- name: Run UI Test(ubuntu)
if: matrix.os == 'ubuntu-latest'
working-directory: packages/tests
run: |
sudo apt-get install xvfb
export DISPLAY=:99.0
Xvfb -ac :99 -screen 0 1920x1080x16 &
npx extest run-tests --storage .test-resources --extensions_dir .test-resources --type stable --code_settings ./settings.json ./out/ui-test/**/${{ matrix.test-case }}.test.js
- name: Run UI Test(mac & win)
if: matrix.os != 'ubuntu-latest'
working-directory: packages/tests
run: |
npx extest run-tests --storage .test-resources --extensions_dir .test-resources --type stable --code_settings ./settings.json ./out/ui-test/**/${{ matrix.test-case }}.test.js
- name: Upload test result json file
uses: actions/upload-artifact@v4
if: ${{ github.event_name != 'schedule' || success() || (failure() && github.run_attempt >= 5) }}
with:
name: test-result-${{ matrix.test-case }}-${{ matrix.os }}
path: ./packages/tests/mochawesome-report/mochawesome.json
- name: Upload screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots ${{ matrix.test-case }} ${{ matrix.os }}
path: ./packages/tests/.test-resources/screenshots/
- name: Upload source code
uses: actions/upload-artifact@v4
if: failure()
with:
name: source code ${{ matrix.test-case }} ${{ matrix.os }}
path: |
./packages/tests/**/teamsfxuitest*/*
!./packages/tests/**/node_modules/*
- name: Upload telemetry
uses: actions/upload-artifact@v4
if: always() && startsWith(matrix.test-case, 'telemetry')
with:
name: telemetry ${{ matrix.test-case }} ${{ matrix.os }}
path: |
~/.fx/telemetryTest.log
test-plan-update:
needs: main
if: ${{ always() && github.event.inputs.target-testplan-name != '' }}
environment: engineering
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
env:
AUTO_TEST_PLAN_ID: ${{ github.event.inputs.source-testplan-id }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v4
- name: setup project
run: |
pnpm --filter=@microsoft/teamsfx-test install
- uses: azure/login@v2
with:
client-id: ${{secrets.DEVOPS_CLIENT_ID}}
tenant-id: ${{secrets.DEVOPS_TENANT_ID}}
subscription-id: ${{secrets.DEVOPS_SUB_ID}}
enable-AzPSSession: true
- name: Archive Test Plan
working-directory: packages/tests
run: |
testplanid=`npx ts-node src/scripts/testPlan.ts obtain vscode ${{ github.event.inputs.target-testplan-name }}`
echo "Testplan id is $testplanid"
npx ts-node src/scripts/testPlan.ts archive $testplanid
- name: Download TestPlan
uses: actions/download-artifact@v4
with:
path: ./packages/tests/mocha-results
- name: Sync to Azure DevOps Test Plan
working-directory: packages/tests
run: |
npx ts-node src/scripts/testPlan.ts report ./testplan.json ./mocha-results
rerun:
permissions:
actions: write
needs: main
if: ${{ github.event_name == 'schedule' && failure() && github.run_attempt < 5 }}
runs-on: ubuntu-latest
steps:
- name: trigger rerun workflow
run: |
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/rerun.yml/dispatches \
-d '{"ref":"${{ github.ref_name }}","inputs":{"run_id":"${{ github.run_id }}", "max_attempts":"5"}}'
report:
if: ${{ (github.event_name == 'workflow_dispatch' && needs.setup.outputs.email-receiver) || (github.event_name == 'schedule' && (success() || (failure() && github.run_attempt >= 5))) }}
needs: [setup, main]
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/tests
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Dateutils
run: |
sudo apt install dateutils
- name: list jobs
id: list-jobs
run: |
page=1
jobs="[]"
while :
do
url=https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs\?per_page\=100\&page\=$page
resp=`curl -H "Accept: application/vnd.github.v3+json" -u:${{ secrets.GITHUB_TOKEN }} $url`
new_jobs=`echo $resp | jq -cr '.jobs'`
jobs=`jq -cr --slurp 'add' <(echo "$jobs") <(echo "$new_jobs")`
has_next=`curl -I -H "Accept: application/vnd.github.v3+json" -u:${{ secrets.GITHUB_TOKEN }} $url | grep -Fi "link:" | grep "rel=\"last\"" || true`
if [ -z "$has_next" ]; then
break
fi
page=$((page+1))
done
cases=`echo $jobs| jq -r '.[] | select(.name | contains("|")) | .name'`
passed=0
failed=0
failedlimit=100
passedlimit=100
failedlist=""
passedlist=""
lists=""
emails="${{ needs.setup.outputs.email-receiver }}"
while IFS= read -r case;
do
if [ -z "$case" ]; then
continue
fi
name=`echo $case | awk -F '|' '{print $1}'`
os=`echo $case | awk -F '|' '{print $2}'`
node=`echo $case | awk -F '|' '{print $3}'`
branch=`echo $case | awk -F '|' '{print $4}'`
file=`find src -name "$name.test.ts"`
email=""
if grep -q "@author" $file; then
email=`grep '@author' $file | grep -i -o '[A-Z0-9._%+-]\+@[A-Z0-9.-]\+\.[A-Z]\{2,4\}'`
fi
status=`echo $jobs | jq --arg case "$case" -r '.[] | select(.name == $case ) | .conclusion'`
if [[ ! -z "$email" && ! "$emails" == *"$email"* && "$status" == "failure" ]]; then
emails="$emails;$email;[email protected];[email protected]"
fi
status=`echo $jobs | jq --arg case "$case" -r '.[] | select(.name == $case ) | .conclusion'`
started_at=`echo $jobs | jq --arg case "$case" -r '.[] | select(.name == $case ) | .started_at'`
completed_at=`echo $jobs | jq --arg case "$case" -r '.[] | select(.name == $case ) | .completed_at'`
duration=`dateutils.ddiff $started_at $completed_at -f "%Mm %Ss"`
author=""
if [ -z "$email" ]; then
author="N/A"
else
author="<a href=\\\"mailto:$email\\\"><span>$email</span></a>"
fi
lable=""
if [ "$status" == "success" ]; then
passed=$((passed+1))
label="<span style=\\\"background-color:#2aa198;color:white;font-weight:bold;\\\">PASSED</span>"
else
failed=$((failed+1))
label="<span style=\\\"background-color: #dc322f;color:white;font-weight:bold;\\\">FAILED</span>"
fi
url=`echo $jobs | jq --arg case "$case" -r '.[] | select(.name == $case ) | .html_url'`
url="<a href=\\\"$url\\\">$name</a>"
row="<tr> <td style=\\\"text-align: left;\\\">$url</td> <td style=\\\"text-align: left;\\\">$os</td> <td style=\\\"text-align: left;\\\">$node</td> <td style=\\\"text-align: center;\\\">$label</td> <td style=\\\"text-align: center;\\\">$author</td> <td style=\\\"text-align: center;\\\">$duration</td> </tr>"
if [[ "$status" == "success" && $passed -lt $passedlimit ]]; then
passedlist="$passedlist $row"
elif [[ "$status" != "success" && $failed -lt $failedlimit ]]; then
failedlist="$failedlist $row"
fi
done <<< $cases
lists="$failedlist $passedlist"
body="Dashboard App: <a href=\\\"https:\/\/teams.microsoft.com\/l\/entity\/c439ae8d-3ab3-4efd-9223-87366d8c170c\/_djb2_msteams_prefix_1252604900?context=%7B%22channelId%22%3A%2219%3A79488ced607f4fbf8d8433e931cad176%40thread.tacv2%22%7D&tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47\\\">Click Here to Open Dashboard App</a> <br/> Release: ${{ needs.setup.outputs.ttk-package }}. <br/> <table class=\\\"w3-table w3-striped w3-bordered\\\"> <tr> <th>CASE</th> <th>OS</th> <th>NODE</th> <th>STATUS</th> <th>AUTHOR</th> <th>DURATION</th> </tr> $lists </table> <br />"
total=$((passed+failed))
subject="TeamsFx UI Test Report ($passed/$total Passed)"
if [ $failed -gt 0 ]; then
subject="[FAILED] $subject"
else
subject="[PASSED] $subject"
fi
echo "body=$body" >> $GITHUB_OUTPUT
echo "to=$emails" >> $GITHUB_OUTPUT
echo "subject=$subject" >> $GITHUB_OUTPUT
- name: Send E-mail
uses: ./.github/actions/send-email-report
env:
TO: ${{ steps.list-jobs.outputs.to }}
BODY: '"${{ steps.list-jobs.outputs.body }}"'
SUBJECT: ${{ steps.list-jobs.outputs.subject }}
MAIL_CLIENT_ID: ${{ secrets.TEST_CLEAN_CLIENT_ID }}
MAIL_CLIENT_SECRET: ${{ secrets.TEST_CLEAN_CLIENT_SECRET }}
MAIL_TENANT_ID: ${{ secrets.TEST_CLEAN_TENANT_ID }}