Smoke Test #2725
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |