Skip to content

Test Utility

Test Utility #253

Workflow file for this run

name: 'Test Utility'
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Runs at midnight on sunday
env:
variablesPath: '.github/settings.yml'
jobs:
job_pester_GetVersionList:
runs-on: ubuntu-20.04
name: 'Validate scripts'
steps:
# [Checkout] task(s)
# ---------------
- name: 'Checkout AzureAPICrawler'
uses: actions/checkout@v3
with:
fetch-depth: 0
path: AzureAPICrawler
- name: Checkout CARML # Using the CARML modules to check if we can find all Resource Types they use
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: Azure/ResourceModules
path: ResourceModules
- name: Checkout Azure API specs
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: Azure/azure-rest-api-specs
path: AzureAPICrawler/temp/azure-rest-api-specs
# [Setup] task(s)
# ---------------
- name: 'Setup agent'
shell: pwsh
run: |
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'AzureAPICrawler' '.github' 'scripts' 'Set-EnvironmentOnAgent.ps1')
# Define PS modules to install on the runner
$Modules = @(
@{ Name = 'Az.Accounts' },
@{ Name = 'Az.Resources' }
)
# Set agent up
Set-EnvironmentOnAgent -PSModules $Modules
- name: Azure Login
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
# [Test] task(s)
# ---------------
# Get-AzureAPISpecsVersionList Tests
- name: 'Run [Get-AzureAPISpecsVersionList] tests'
id: pester_run_step_getVersionListTestResults
if: always()
shell: pwsh
run: |
$outputPath = Join-Path $env:GITHUB_WORKSPACE 'getVersionListTestResults.xml'
Write-Verbose "Pester tests output: $outputPath" -Verbose
Write-Output ('{0}={1}' -f 'outputPath', $outputPath) >> $env:GITHUB_OUTPUT
$null = Import-Module (Join-Path $env:GITHUB_WORKSPACE 'AzureAPICrawler' 'AzureAPICrawler.psm1')
# --------------------- #
# Invoke Pester test(s) #
# --------------------- #
Invoke-Pester -Configuration @{
Run = @{
Container = New-PesterContainer -Path (Join-Path $env:GITHUB_WORKSPACE 'AzureAPICrawler' 'tests' 'Get-AzureAPISpecsVersionList.Tests.ps1') -Data @{
ResourceModulesFilePath = Join-Path $env:GITHUB_WORKSPACE 'ResourceModules'
}
}
TestResult = @{
TestSuiteName = 'API Tests'
OutputPath = $outputPath
OutputFormat = 'JUnitXml'
Enabled = $true
}
Output = @{
Verbosity = 'Detailed'
}
}
- name: 'Publish [Get-AzureAPISpecsVersionList] Test Results'
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: '${{ steps.pester_run_step_getVersionListTestResults.outputs.outputPath }}'
# Get-AzureAPISpecsData Tests
- name: 'Run [Get-AzureAPISpecsData] tests'
id: pester_run_step_getDataTestResults
if: always()
shell: pwsh
run: |
$outputPath = Join-Path $env:GITHUB_WORKSPACE 'getDataTestResults.xml'
Write-Verbose "Pester tests output: $outputPath" -Verbose
Write-Output ('{0}={1}' -f 'outputPath', $outputPath) >> $env:GITHUB_OUTPUT
$null = Import-Module (Join-Path $env:GITHUB_WORKSPACE 'AzureAPICrawler' 'AzureAPICrawler.psm1')
# --------------------- #
# Invoke Pester test(s) #
# --------------------- #
Invoke-Pester -Configuration @{
Run = @{
Container = New-PesterContainer -Path (Join-Path $env:GITHUB_WORKSPACE 'AzureAPICrawler' 'tests' 'Get-AzureAPISpecsData.Tests.ps1') -Data @{}
}
TestResult = @{
TestSuiteName = 'Data Tests'
OutputPath = $outputPath
OutputFormat = 'JUnitXml'
Enabled = $true
}
Output = @{
Verbosity = 'Detailed'
}
}
- name: 'Publish [Get-AzureAPISpecsData] Test Results'
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: '${{ steps.pester_run_step_getDataTestResults.outputs.outputPath }}'