-
Notifications
You must be signed in to change notification settings - Fork 16
907 lines (808 loc) · 31.8 KB
/
e2e-testing.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
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
name: End to End Testing
on:
workflow_dispatch:
inputs:
environment:
description: AZD Environment Name
type: string
default: fllm-e2e-aca
deployOpenAi:
description: Deploy a new OpenAI Instance
type: boolean
default: false
openAiName:
description: Shared OpenAI Instance Name
type: string
default: fllm-01
openAiResourceGroup:
description: Shared OpenAI Resource Group
type: string
default: fllm-shared-01
location:
description: AZD Target Location
type: choice
options:
- AustraliaEast
- CanadaEast
- EastUS
- EastUS2
- SwedenCentral
default: EastUS2
notificationsEnabled:
description: Enable Slack Notifications
type: boolean
default: false
enableTeardown:
description: Enable teardown of environment
type: boolean
default: true
bypassAndTeardown:
description: Bypass Tests and Force Teardown
type: boolean
default: false
target:
description: Select target tenant/subscription
type: choice
options:
- sandbox
- e2e
default: e2e
deployAMLResources:
description: Deploy Azure Machine Learning resources & run tests that depend on them
type: boolean
default: false
workflow_call:
inputs:
environment:
description: AZD Environment Name
type: string
deployOpenAi:
description: Deploy a new OpenAI Instance
type: boolean
openAiName:
description: Shared OpenAI Instance Name
type: string
openAiResourceGroup:
description: Shared OpenAI Resource Group
type: string
location:
description: AZD Target Location
type: string
notificationsEnabled:
description: Enable Slack Notifications
type: boolean
enableTeardown:
description: Enable teardown of environment
type: boolean
bypassAndTeardown:
description: Bypass Tests and Force Teardown
type: boolean
target:
description: Select target tenant/subscription
type: string
deployAMLResources:
description: Deploy Azure Machine Learning resources & run tests that depend on them
type: boolean
jobs:
generate_matrix:
name: Generate Configuration Matrix
runs-on: ubuntu-latest
outputs:
registry: ${{ steps.set-registry.outputs.result }}
service_matrix: ${{ steps.set-service-matrix.outputs.result }}
test_matrix: ${{ steps.set-test-matrix.outputs.result }}
docker_tag: ${{ steps.docker-tag.outputs.docker_tag }}
unique_id: ${{ steps.set-unique-id.outputs.digest }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate Unique ID
uses: pplanel/[email protected]
id: set-unique-id
with:
input: ${{ inputs.environment }}
method: SHA3
output_len: 32
- name: Set Service Matrix
uses: actions/github-script@v7
id: set-service-matrix
with:
result-encoding: string
script: |
const fs = require('fs')
const jsonString = fs.readFileSync('./tests/config/e2e-test-manifest.json')
var data = JSON.parse(jsonString)
return JSON.stringify(data.service_matrix)
- name: Set Test Matrix
uses: actions/github-script@v7
id: set-test-matrix
with:
result-encoding: string
script: |
const fs = require('fs')
const jsonString = fs.readFileSync('./tests/config/e2e-test-manifest.json')
var data = JSON.parse(jsonString)
return JSON.stringify(data.test_matrix)
- name: Set Container registry
uses: actions/github-script@v7
id: set-registry
with:
result-encoding: string
script: |
var registries = new Map();
registries['e2e'] = 'crfllme2eops'
registries['sandbox'] = 'cropseastus2svinternal'
return registries['${{ inputs.target }}']
- name: Set Git and Helm Tag
id: docker-tag
run: |
if [ '${{ (startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/poc/')) }}' == 'true' ]; then
DOCKER_TAG=$(echo ${{ github.ref_name }} | cut -d'/' -f 2)
else
DOCKER_TAG=0.0.0-${GITHUB_REF#refs/heads/}
fi
DOCKER_TAG=$DOCKER_TAG-$(date +'%Y%m%dT%H%M%SZ')
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
echo "docker_tag: Latest Tag is : $DOCKER_TAG"
echo "docker_tag=$DOCKER_TAG" >> $GITHUB_OUTPUT
helm_build:
name: Package Helm Charts
if: ${{ !inputs.bypassAndTeardown }}
needs: generate_matrix
strategy:
fail-fast: false
matrix:
object: ${{ fromJson(needs.generate_matrix.outputs.service_matrix) }}
uses: ./.github/workflows/build-helm-chart.yml
with:
chart: ${{ matrix.object.name }}
registry: ${{ needs.generate_matrix.outputs.registry }}.azurecr.io
tag: ${{ needs.generate_matrix.outputs.docker_tag }}
username: e2e-token
target: ${{ inputs.target }}
secrets: inherit
docker_build:
name: Build Docker Images
if: ${{ !inputs.bypassAndTeardown }}
needs: generate_matrix
strategy:
fail-fast: false
matrix:
object: ${{ fromJson(needs.generate_matrix.outputs.service_matrix) }}
uses: ./.github/workflows/build-docker-image.yml
with:
image: ${{ matrix.object.name }}
context: ${{ matrix.object.context }}
dockerfile: ${{ matrix.object.dockerfile }}
registry: ${{ needs.generate_matrix.outputs.registry }}.azurecr.io
tag: ${{ needs.generate_matrix.outputs.docker_tag }}
username: e2e-token
target: ${{ inputs.target }}
secrets: inherit
deploy_quickstart:
if: ${{ !inputs.bypassAndTeardown }}
name: Deploy Quick Start
needs: [generate_matrix, docker_build]
runs-on: ubuntu-latest
env:
AZURE_ENV_NAME: ${{ inputs.environment }}
AZURE_LOCATION: ${{ inputs.location }}
steps:
- name: Sets Credentials for E2E
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_E2E_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'e2e'
env:
FLLM_E2E_AZURE_CREDENTIALS: |
${{ secrets.FLLM_E2E_AZURE_CREDENTIALS }}
- name: Sets Credentials for Sandbox
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_SBX_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'sandbox'
env:
FLLM_SBX_AZURE_CREDENTIALS: |
${{ secrets.FLLM_SBX_AZURE_CREDENTIALS }}
- name: Checkout code
uses: actions/checkout@v4
- name: Install azd
uses: Azure/[email protected]
with:
version: "1.9.3"
- name: Log in with Azure (Client Credentials)
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
cd ./deploy/quick-start
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
az login `
--service-principal `
--username "$($info.clientId)" `
--password "$($info.clientSecret)" `
--tenant "$($info.tenantId)"
$env:AZCOPY_SPA_CLIENT_SECRET="$($info.clientSecret)"
azcopy login `
--login-type=SPN `
--application-id "$($info.clientId)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
- name: Deploy Azure Machine Learning
if: ${{ inputs.deployAMLResources }}
env:
AZURE_ENV_NAME: ext-${{ inputs.environment }}
AZURE_LOCATION: ${{ inputs.location }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Push-Location ./tests/extended-test-env
azd env new ext-${{ inputs.environment }}
azd env set AZURE_SUBSCRIPTION_ID $($info.subscriptionId)
azd up --no-prompt
Pop-Location
shell: pwsh
- name: Provision Admin Group
id: provision-admin-group
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Write-Host "Provision Admin Group and add ObjectId to AZD Environment"
Push-Location ./tests/scripts
$spObjectId = $(az ad sp list --filter "appId eq '$($info.clientId)'" --query '[].id' --output tsv)
Write-Host "SP Object Id: $spObjectId"
./Create-FllmAdminGroup.ps1 `
-groupName FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }}
$spAssignmentExists = $(az ad group member check `
--group FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }} `
--member-id $spObjectId `
--output json | ConvertFrom-Json).value
if (-not $spAssignmentExists)
{
az ad group member add `
--group FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }} `
--member-id $spObjectId `
--output json
}
if ('${{ inputs.target }}' -eq 'sandbox') {
$assignmentExists = $(az ad group member check `
--group FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }} `
--member-id d3bd4e8e-d413-477d-a420-0792b0504adf `
--output json | ConvertFrom-Json).value
if (-not $assignmentExists)
{
az ad group member add `
--group FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }} `
--member-id d3bd4e8e-d413-477d-a420-0792b0504adf `
--output json
}
}
Pop-Location
shell: pwsh
- name: Update AZD Environment
id: update-azd-environment
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
$spObjectId = $(az ad sp list --filter "appId eq '$($info.clientId)'" --query '[].id' --output tsv)
Write-Host "Create new AZD Environment"
Push-Location ./deploy/quick-start
azd env new ${{ inputs.environment }}
azd env set PIPELINE_DEPLOY "$true"
azd env set FLLM_E2E_SP_OBJECT_ID $spObjectId
if ('${{ inputs.deployOpenAi }}' -eq 'false') {
azd env set OPENAI_NAME ${{ inputs.openAiName }}
azd env set OPENAI_RESOURCE_GROUP ${{ inputs.openAiResourceGroup }}
azd env set OPENAI_SUBSCRIPTION_ID $($info.subscriptionId)
}
Pop-Location
Write-Host "Update AZD Environment with Service Docker Image Names"
$configPath = "./tests/config/e2e-test-manifest.json"
$config = Get-content $configPath | ConvertFrom-Json
Push-Location ./deploy/quick-start
foreach ($service in $($config.service_matrix)) {
$imageName = "${{ needs.generate_matrix.outputs.registry }}.azurecr.io/$($service.name):${{ needs.generate_matrix.outputs.docker_tag }}"
Write-Host "Setting $($service.azd_env_key) to $($imageName)..."
azd env set $($service.azd_env_key) "$($imageName)"
if ($LASTEXITCODE -ne 0) {
Write-Error("Failed to set $($value.Key).")
exit 1
}
}
Pop-Location
Write-Host "Update AZD Environment with App Registration Metadata"
Push-Location ./deploy/quick-start
../../tests/scripts/Set-AzdEnv.ps1 `
-tenantId $($info.tenantId) `
-principalType ServicePrincipal `
-instanceId 6fa496ce-d5c0-4e02-9223-06a98c9c0176 `
-fllmApiName FoundationaLLM-Core-API `
-fllmClientName FoundationaLLM-Core-Portal `
-fllmMgmtApiName FoundationaLLM-Management-API `
-fllmMgmtClientName FoundationaLLM-Management-Portal `
-fllmAuthApiName FoundationaLLM-Authorization-API `
-fllmAdminGroupName FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }}
Pop-Location
shell: pwsh
- name: Provision Infrastructure
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
$env:AZURE_SUBSCRIPTION_ID=$($info.subscriptionId)
Push-Location ./deploy/quick-start
azd provision --no-prompt
Pop-Location
shell: pwsh
- name: Deploy Application
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
$env:AZURE_SUBSCRIPTION_ID=$($info.subscriptionId)
Push-Location ./deploy/quick-start
azd deploy --no-prompt
Pop-Location
shell: pwsh
- name: Publish AZD Environment
uses: actions/upload-artifact@v4
with:
name: azd-env
path: ./deploy/quick-start/.azure
- name: Update App Registration OAuth Callbacks
id: update-app-reg-oauth
run: |
Write-Host "Update App Registration OAuth Callbacks"
Push-Location ./deploy/quick-start
pwsh -File ../common/scripts/Update-OAuthCallbackUris.ps1 `
-fllmChatUiName FoundationaLLM-Core-Portal `
-fllmMgmtUiName FoundationaLLM-Management-Portal
Pop-Location
shell: pwsh
- name: Apply MS Graph API Role Assignments
id: apply-ms-graph-api-roles
run: |
Write-Host "Apply MS Graph API Role Assignments"
Push-Location ./deploy/quick-start
pwsh -File ../../tests/scripts/Apply-MSGraphAPIRoles.ps1
Pop-Location
shell: pwsh
- name: Apply Cosmos DB RBAC to Service Principal
id: apply-cosmos-db-rbac
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Push-Location ./deploy/quick-start
(azd env get-values) | foreach {
$name, $value = $_.split('=')
set-content env:\$name $value
}
Pop-Location
Write-Host "Apply Cosmos DB Role to Service Principal"
Push-Location ./tests/scripts
$spObjectId = $(az ad sp list --filter "appId eq '$($info.clientId)'" --query '[].id' --output tsv)
Write-Host "SP Object Id: $spObjectId"
$cosmosDbName = $env:AZURE_COSMOS_DB_NAME | ConvertFrom-Json
$cosmosDbObjectId = $(az cosmosdb show --name $cosmosDbName --resource-group rg-${{ inputs.environment }} --query 'id' --output tsv)
Write-Host "CosmosDB Object Id: $cosmosDbObjectId"
az cosmosdb sql role assignment create `
--account-name $cosmosDbName `
--resource-group rg-${{ inputs.environment }} `
--role-definition-id 00000000-0000-0000-0000-000000000002 `
--scope $cosmosDbObjectId `
--principal-id $spObjectId
Pop-Location
shell: pwsh
add_test_data:
if: ${{ !inputs.bypassAndTeardown }}
name: Add Test Data
needs: [deploy_quickstart]
runs-on: ubuntu-latest # this may need to change to windows
env:
AZURE_ENV_NAME: ${{ inputs.environment }}
AZURE_LOCATION: ${{ inputs.location }}
steps:
- name: Sets Credentials for Source (SBX)
run: |
{
echo 'AZURE_CREDENTIALS_SRC<<EOF'
echo "$FLLM_SBX_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
env:
FLLM_SBX_AZURE_CREDENTIALS: |
${{ secrets.FLLM_SBX_AZURE_CREDENTIALS }}
- name: Sets Credentials for Target (E2E)
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_E2E_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'e2e'
env:
FLLM_E2E_AZURE_CREDENTIALS: |
${{ secrets.FLLM_E2E_AZURE_CREDENTIALS }}
- name: Sets Credentials for Target (Sandbox)
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_SBX_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'sandbox'
env:
FLLM_SBX_AZURE_CREDENTIALS: |
${{ secrets.FLLM_SBX_AZURE_CREDENTIALS }}
- name: Checkout code
uses: actions/checkout@v4
- name: Download AZD Environment
uses: actions/download-artifact@v4
with:
name: azd-env
path: ./deploy/quick-start/.azure
- name: Install azd
uses: Azure/[email protected]
with:
version: "1.9.3"
- name: Log in with Azure (Client Credentials)
shell: pwsh
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Push-Location ./deploy/quick-start
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
Pop-Location
az login `
--service-principal `
--username "$($info.clientId)" `
--password "$($info.clientSecret)" `
--tenant "$($info.tenantId)" `
- name: Copy Test Data
shell: pwsh
run: |
$src = $Env:AZURE_CREDENTIALS_SRC | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($src.clientSecret)"
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Push-Location ./deploy/quick-start
(azd env get-values) | foreach {
$name, $value = $_.split('=')
$value = $value.Trim('"')
set-content env:\$name $value
}
Pop-Location
# Assign “Search Index Data Contributor” on the target resource group
$objectId = (az ad sp list --all --query "[?appId=='$($info.clientId)'].id" --output tsv)
az role assignment create `
--role "Search Index Data Contributor" `
--assignee-object-id $objectId `
--assignee-principal-type ServicePrincipal `
--scope "/subscriptions/${env:AZURE_SUBSCRIPTION_ID}/resourceGroups/${env:RESOURCE_GROUP_NAME_DEFAULT}"
$env:AZCOPY_SPA_CLIENT_SECRET="$($src.clientSecret)"
azcopy login `
--login-type=SPN `
--application-id "$($src.clientId)" `
--tenant-id "$($src.tenantId)"
./deploy/common/scripts/Get-TestData.ps1 -storageAccountName foundationallmdata
$env:AZCOPY_SPA_CLIENT_SECRET="$($info.clientSecret)"
azcopy login `
--login-type=SPN `
--application-id "$($info.clientId)" `
--tenant-id "$($info.tenantId)"
./deploy/common/scripts/Set-TestData.ps1 `
-storageAccountName $env:AZURE_STORAGE_ACCOUNT_NAME `
-aiSearchName $env:AZURE_COGNITIVE_SEARCH_NAME
build_e2e_tests:
name: Build End to End Tests
if: ${{ !inputs.bypassAndTeardown }}
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.x
- name: Sets Credentials for Source (SBX)
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_SBX_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
env:
FLLM_SBX_AZURE_CREDENTIALS: |
${{ secrets.FLLM_SBX_AZURE_CREDENTIALS }}
- name: Pull Build Artifacts
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Push-Location ./deploy/common/scripts
$env:AZCOPY_SPA_CLIENT_SECRET="$($info.clientSecret)"
azcopy login `
--login-type=SPN `
--application-id "$($info.clientId)" `
--tenant-id "$($info.tenantId)"
./Get-TestSettings.ps1 -storageAccountName foundationallmdata
Pop-Location
shell: pwsh
- name: Build Tests
shell: pwsh
run: |
dotnet restore ./src/FoundationaLLM.sln --output ./dist
dotnet build ./tests/dotnet/Common.Tests/Common.Tests.csproj --output ./dist
dotnet build ./tests/dotnet/Core.Examples/Core.Examples.csproj --output ./dist
dotnet build ./tests/dotnet/Core.Test/Core.Tests.csproj --output ./dist
dotnet build ./tests/dotnet/Gatekeeper.Tests/Gatekeeper.Tests.csproj --output ./dist
dotnet build ./tests/dotnet/Orchestration.Tests/Orchestration.Tests.csproj --output ./dist
dotnet build ./tests/dotnet/SemanticKernel.Tests/SemanticKernel.Tests.csproj --output ./dist
dotnet build ./tests/dotnet/Vectorization.Tests/Vectorization.Tests.csproj --output ./dist
- name: Publish Build
uses: actions/upload-artifact@v4
with:
name: build
path: ./dist
run_e2e_tests:
name: Run End to End Tests
if: ${{ !inputs.bypassAndTeardown }}
continue-on-error: true
runs-on: ubuntu-latest
env:
AZURE_ENV_NAME: ${{ inputs.environment }}
AZURE_LOCATION: ${{ inputs.location }}
needs: [generate_matrix, deploy_quickstart, add_test_data, build_e2e_tests]
strategy:
fail-fast: false
max-parallel: 1
matrix:
object: ${{ fromJson(needs.generate_matrix.outputs.test_matrix) }}
steps:
- name: Sets Credentials for E2E
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_E2E_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'e2e'
env:
FLLM_E2E_AZURE_CREDENTIALS: |
${{ secrets.FLLM_E2E_AZURE_CREDENTIALS }}
- name: Sets Credentials for Sandbox
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_SBX_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'sandbox'
env:
FLLM_SBX_AZURE_CREDENTIALS: |
${{ secrets.FLLM_SBX_AZURE_CREDENTIALS }}
- name: Checkout code
uses: actions/checkout@v4
- name: Download Build
uses: actions/download-artifact@v4
with:
name: build
path: ./dist
- name: Download AZD Environment
uses: actions/download-artifact@v4
with:
name: azd-env
path: ./deploy/quick-start/.azure
- name: Install azd
uses: Azure/[email protected]
with:
version: "1.9.3"
- name: Log in with Azure (Client Credentials)
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Push-Location ./deploy/quick-start
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
Pop-Location
az login `
--service-principal `
--username "$($info.clientId)" `
--password "$($info.clientSecret)" `
--tenant "$($info.tenantId)" `
--scope api://FoundationaLLM-Core/.default
shell: pwsh
- name: Running End to End Tests
id: e2e-test-exec
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Push-Location ./deploy/quick-start
(azd env get-values) | foreach {
$name, $value = $_.split('=')
set-content env:\$name $value
}
Pop-Location
$connectionString = $(az appconfig credential list `
--name $($env:AZURE_APP_CONFIG_NAME | ConvertFrom-Json) `
--resource-group rg-$($env:AZURE_ENV_NAME) `
--query "[].{name:name,connectionString:connectionString}[?name=='Primary Read Only'].connectionString" `
--output tsv)
$env:FoundationaLLM_AppConfig_ConnectionString=$connectionString
echo "Running End to End Test: ${{ matrix.object.name }}"
dotnet test `
--output ./dist `
--no-build `
--filter "FullyQualifiedName=${{ matrix.object.namespace }}.${{ matrix.object.task_name }}" `
--logger:"html;verbosity=detailed;LogFileName=${{ github.workspace }}/${{ matrix.object.name }}.html" `
${{ matrix.object.target }}
shell: pwsh
- name: Publish Test Results
if: (success() || failure())
id: publish-results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.object.name }}-results
path: ${{ github.workspace }}/${{ matrix.object.name }}.html
- name: Send Test Failure Notification
if: (inputs.notificationsEnabled && failure())
uses: slackapi/[email protected]
id: notify-failed-test
env:
SLACK_WEBHOOK_URL: ${{ secrets.FLLM_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*End to End Test Failure: ${{ matrix.object.name }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "End to End Test ${{ matrix.object.name }} failed in branch `${{ github.head_ref || github.ref_name }}`"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Download Test Results"
},
"url": "${{ steps.publish-results.outputs.artifact-url }}"
}
]
}
]
}
- name: Output Job Status
if: (success() || failure())
uses: cloudposse/github-action-matrix-outputs-write@v1
id: job-status
with:
matrix-step-name: ${{ github.job }}
matrix-key: ${{ matrix.object.name }}
outputs: |
passed: ${{ steps.e2e-test-exec.outcome }}
teardown_quickstart:
name: Tear Down Quick Start
if: ${{ (cancelled() && inputs.bypassAndTeardown) || inputs.enableTeardown }}
runs-on: ubuntu-latest
env:
AZURE_ENV_NAME: ${{ inputs.environment }}
AZURE_LOCATION: ${{ inputs.location }}
needs: [generate_matrix, run_e2e_tests]
steps:
- name: Sets Credentials for E2E
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_E2E_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'e2e'
env:
FLLM_E2E_AZURE_CREDENTIALS: |
${{ secrets.FLLM_E2E_AZURE_CREDENTIALS }}
- name: Sets Credentials for Sandbox
run: |
{
echo 'AZURE_CREDENTIALS<<EOF'
echo "$FLLM_SBX_AZURE_CREDENTIALS"
echo EOF
} >> "$GITHUB_ENV"
if: inputs.target == 'sandbox'
env:
FLLM_SBX_AZURE_CREDENTIALS: |
${{ secrets.FLLM_SBX_AZURE_CREDENTIALS }}
- name: Checkout code
uses: actions/checkout@v4
- name: Download AZD Environment
uses: actions/download-artifact@v4
with:
name: azd-env
path: ./deploy/quick-start/.azure
- name: Install azd
uses: Azure/[email protected]
with:
version: "1.9.3"
- name: Log in with Azure (Client Credentials)
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
cd ./deploy/quick-start
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
az login `
--service-principal `
--username "$($info.clientId)" `
--password "$($info.clientSecret)" `
--tenant "$($info.tenantId)"
shell: pwsh
- name: Tearing Down Azure Machine Learning
if: ${{ inputs.deployAMLResources }}
env:
AZURE_ENV_NAME: ext-${{ inputs.environment }}
AZURE_LOCATION: ${{ inputs.location }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Push-Location ./tests/extended-test-env
azd env new ext-${{ inputs.environment }}
$env:AZURE_SUBSCRIPTION_ID = $($info.subscriptionId)
azd env refresh --no-prompt
azd down --force --purge --no-prompt
Pop-Location
shell: pwsh
- name: Tearing Down AZD Deployment
id: azd-down
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
Push-Location ./deploy/quick-start
Write-Host "Removing App Registration OAuth Callbacks"
pwsh -File ../common/scripts/Remove-OAuthCallbackUris.ps1 `
-fllmChatUiName FoundationaLLM-Core-Portal `
-fllmMgmtUiName FoundationaLLM-Management-Portal
azd down --force --purge --no-prompt
Pop-Location
Write-Host "Remove Admin Group"
az ad group delete --group FLLM-E2E-Admins-${{ needs.generate_matrix.outputs.unique_id }} --output json
shell: pwsh
- name: Get E2E Test Results
uses: cloudposse/github-action-matrix-outputs-read@v1
id: get-e2e-results
with:
matrix-step-name: run_e2e_tests
- name: Check E2E Test Status
uses: actions/github-script@v7
env:
TEST_RESULTS: ${{ steps.get-e2e-results.outputs.result }}
with:
script: |
const jsonString = process.env.TEST_RESULTS
var data = JSON.parse(jsonString)
var tests = data.passed
for (const testName of Object.keys(tests)) {
if (tests[testName] !== 'success') {
process.exit(1);
}
}