-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from sam-cogan/samcogan/update-023
Update to TTK 0.23
- Loading branch information
Showing
17 changed files
with
3,455 additions
and
1,662 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
arm-ttk-extension-xplatform/arm-ttk/.github/workflows/run-unit-tests.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
name: RunPester | ||
on: | ||
workflow_dispatch: | ||
push: | ||
pull_request: | ||
jobs: | ||
TestPowerShellOnLinux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: InstallPester | ||
id: InstallPester | ||
shell: pwsh | ||
run: | | ||
$Parameters = @{} | ||
$Parameters.PesterMaxVersion = ${env:PesterMaxVersion} | ||
foreach ($k in @($parameters.Keys)) { | ||
if ([String]::IsNullOrEmpty($parameters[$k])) { | ||
$parameters.Remove($k) | ||
} | ||
} | ||
Write-Host "::debug:: InstallPester $(@(foreach ($p in $Parameters.GetEnumerator()) {'-' + $p.Key + ' ' + $p.Value}) -join ' ')" | ||
& './GitHubWorkflow/Steps/InstallPester.ps1' @Parameters | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
- name: RunPester | ||
id: RunPester | ||
shell: pwsh | ||
run: | | ||
$Parameters = @{} | ||
$Parameters.ModulePath = ${env:ModulePath} | ||
$Parameters.PesterMaxVersion = ${env:PesterMaxVersion} | ||
foreach ($k in @($parameters.Keys)) { | ||
if ([String]::IsNullOrEmpty($parameters[$k])) { | ||
$parameters.Remove($k) | ||
} | ||
} | ||
Write-Host "::debug:: RunPester $(@(foreach ($p in $Parameters.GetEnumerator()) {'-' + $p.Key + ' ' + $p.Value}) -join ' ')" | ||
& './GitHubWorkflow/Steps/RunPester.ps1' @Parameters | ||
- name: PublishTestResults | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: PesterResults | ||
path: '**.TestResults.xml' | ||
if: ${{always()}} | ||
env: | ||
ModulePath: .\arm-ttk\arm-ttk.psd1 |
5 changes: 5 additions & 0 deletions
5
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Jobs/RunTTK.psd1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
@{ | ||
"runs-on" = "ubuntu-latest" | ||
steps = @('Checkout','CheckoutTTK', 'RunTTK') | ||
} |
4 changes: 4 additions & 0 deletions
4
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Jobs/TestPowerShellOnLinux.psd1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@{ | ||
"runs-on" = "ubuntu-latest" | ||
steps = @('Checkout','InstallPester', 'RunPester', 'PublishTestResults') | ||
} |
9 changes: 9 additions & 0 deletions
9
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Jobs/UpdateTTKCache.psd1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@{ | ||
"runs-on" = "ubuntu-latest" | ||
steps = @( | ||
'Checkout', | ||
'AzureLogin', | ||
'UpdateTTKCache' | ||
) | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Steps/CheckoutTTK.psd1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@{ | ||
name = 'Checkout TTK' | ||
uses = 'actions/checkout@v2' | ||
id = 'CheckoutTTK' | ||
with = @{ | ||
# Exclude = '*.tests.ps1;*.psdevops.ps1' | ||
repository = 'Azure/arm-ttk' | ||
path = 'ttk' | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Steps/InstallPester.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<# | ||
.Synopsis | ||
Installs Pester | ||
.Description | ||
Installs Pester | ||
#> | ||
param( | ||
# The maximum pester version. Defaults to 4.99.99. | ||
[string] | ||
$PesterMaxVersion = '4.99.99' | ||
) | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
Install-Module -Name Pester -Repository PSGallery -Force -Scope CurrentUser -MaximumVersion $PesterMaxVersion -SkipPublisherCheck -AllowClobber | ||
Import-Module Pester -Force -PassThru -MaximumVersion $PesterMaxVersion |
42 changes: 42 additions & 0 deletions
42
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Steps/RunPester.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<# | ||
.Synopsis | ||
Runs Pester | ||
.Description | ||
Runs Pester tests after importing a PowerShell module | ||
#> | ||
param( | ||
# The module path. If not provided, will default to the second half of the repository ID. | ||
[string] | ||
$ModulePath, | ||
# The Pester max version. By default, this is pinned to 4.99.99. | ||
[string] | ||
$PesterMaxVersion = '4.99.99' | ||
) | ||
|
||
$global:ErrorActionPreference = 'continue' | ||
$global:ProgressPreference = 'silentlycontinue' | ||
|
||
$orgName, $moduleName = $env:GITHUB_REPOSITORY -split "/" | ||
if (-not $ModulePath) { $ModulePath = ".\$moduleName.psd1" } | ||
$importedPester = Import-Module Pester -Force -PassThru -MaximumVersion $PesterMaxVersion | ||
$importedModule = Import-Module $ModulePath -Force -PassThru | ||
$importedPester, $importedModule | Out-Host | ||
|
||
|
||
|
||
$result = | ||
Invoke-Pester -PassThru -Verbose -OutputFile ".\$moduleName.TestResults.xml" -OutputFormat NUnitXml ` | ||
-CodeCoverage "$($importedModule | Split-Path)\*-*.ps1" -CodeCoverageOutputFile ".\$moduleName.Coverage.xml" | ||
|
||
"::set-output name=TotalCount::$($result.TotalCount)", | ||
"::set-output name=PassedCount::$($result.PassedCount)", | ||
"::set-output name=FailedCount::$($result.FailedCount)" | Out-Host | ||
if ($result.FailedCount -gt 0) { | ||
"::debug:: $($result.FailedCount) tests failed" | ||
foreach ($r in $result.TestResult) { | ||
if (-not $r.Passed) { | ||
"::error::$($r.describe, $r.context, $r.name -join ' ') $($r.FailureMessage)" | ||
} | ||
} | ||
throw "::error:: $($result.FailedCount) tests failed" | ||
} |
4 changes: 4 additions & 0 deletions
4
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Steps/RunTTK.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Import-Module ./ttk/arm-ttk/ -Force -PassThru | Out-Host | ||
Get-ChildItem -Recurse -Filter *.json | | ||
Where-Object Path -notlike '*ttk*' | | ||
Test-AzTemplate |
18 changes: 18 additions & 0 deletions
18
arm-ttk-extension-xplatform/arm-ttk/GitHubWorkflow/Steps/UpdateTTKCache.psd1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@{ | ||
name = "Update TTK Cache" | ||
uses = "Azure/powershell@v1" | ||
with = @{ | ||
"inlineScript" = @' | ||
Get-ChildItem -Recurse -Filter arm-ttk.psd1 | Import-Module -Name { $_.FullName} -Force -PassThru | Out-String | ||
Update-TTKCache | ||
'@ | ||
"azPSVersion" = "3.1.0" | ||
} | ||
} | ||
<# | ||
name: Azure PowerShell Action | ||
uses: Azure/powershell@v1 | ||
with: | ||
inlineScript: Get-AzVM -ResourceGroupName "< YOUR RESOURCE GROUP >" | ||
azPSVersion: 3.1.0 | ||
#> |
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
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
Oops, something went wrong.