-
Notifications
You must be signed in to change notification settings - Fork 230
89 lines (77 loc) · 3.25 KB
/
run_smoke_test.yaml
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
# Purpose: Run smoke tests
name: Smoke Test
on:
workflow_call:
workflow_dispatch:
pull_request:
types: [opened, reopened]
branches:
- "main"
pull_request_review:
types: [submitted]
push:
paths:
- ".github/workflows/run_smoke_test.yaml"
branches:
- "main"
- "*smoke*"
permissions: read-all
jobs:
smoke-tests:
name: Smoke Tests
runs-on: windows-latest
env:
SCUBA_GITHUB_AUTOMATION_CREDS: ${{ secrets.SCUBA_GITHUB_AUTOMATION_CREDS }}
# This condition prevents duplicate runs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
defaults:
run:
shell: powershell
permissions:
contents: read
steps:
- name: Checkout repo code
uses: actions/checkout@v4
- name: Execute ScubaGear and Check Outputs
run: |
. Testing/Functional/SmokeTest/SmokeTestUtils.ps1
##### Install all the dependencies
Install-SmokeTestExternalDependencies
Import-Module -Name .\PowerShell\ScubaGear\ScubaGear.psd1
Initialize-SCuBA
# Workaround for Selenium. Loading psm1 instead of psd1
Import-Module -Name (Get-Module -Name Selenium -ListAvailable).Path -Force
# ScubaGear currently requires the provisioning of a certificate for using a ServicePrinicpal, rather than
# using Workload Identity Federation, which would ordinarily be preferred for calling Microsoft APIs from
# GitHub actions.
$AUTOMATION_CREDS = $env:SCUBA_GITHUB_AUTOMATION_CREDS | ConvertFrom-Json
$TestTenants = $AUTOMATION_CREDS.TestTenants
Write-Output "Identified $($TestTenants.Count) Test Tenants"
$TestContainers = @()
ForEach ($TestTenantObj in $TestTenants){
$Properties = Get-Member -InputObject $TestTenantObj -MemberType NoteProperty
$TestTenant = $TestTenantObj | Select-Object -ExpandProperty $Properties.Name
$OrgName = $TestTenant.DisplayName
$DomainName = $TestTenant.DomainName
$AppId = $TestTenant.AppId
$PlainTextPassword = $TestTenant.CertificatePassword
$CertPwd = ConvertTo-SecureString -String $PlainTextPassword -Force -AsPlainText
$M365Env = $TestTenant.M365Env
try {
$Result = New-ServicePrincipalCertificate `
-EncodedCertificate $TestTenant.CertificateB64 `
-CertificatePassword $CertPwd
$Thumbprint = $Result[-1]
}
catch {
Write-Output "Failed to install certificate for $OrgName"
}
$TestContainers += New-PesterContainer `
-Path "Testing/Functional/SmokeTest/SmokeTest001.Tests.ps1" `
-Data @{ Thumbprint = $Thumbprint; Organization = $DomainName; AppId = $AppId; M365Environment = $M365Env }
$TestContainers += New-PesterContainer `
-Path "Testing/Functional/SmokeTest/SmokeTest002.Tests.ps1" `
-Data @{ OrganizationDomain = $DomainName; OrganizationName = $OrgName }
}
Invoke-Pester -Container $TestContainers -Output Detailed
Remove-MyCertificates