Skip to content

Commit

Permalink
create Pester test for installing AST
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garriss committed Dec 18, 2024
1 parent 703f157 commit 6676866
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build_sign_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ jobs:
path: repo
- name: Install Azure Signing Tool
run: |
dotnet --version
dotnet tool install --global AzureSignTool --version 5.0.0
# Source the function
. repo/utils/workflow/Build-SignRelease.ps1
Install-AzureSigningTool
# dotnet --version
# dotnet tool install --global AzureSignTool --version 5.0.0
# OIDC Login to Azure Public Cloud with AzPowershell (enableAzPSSession true)
- name: Login to Azure
uses: azure/login@v2
Expand Down Expand Up @@ -94,10 +97,8 @@ jobs:
- name: Quick Check Release
if: ${{ inputs.runQuickCheck }}
run: |
# Source the function
# . repo/utils/workflow/Build-SignRelease.ps1
# Test-Release -Version ${{ inputs.version }}
# Note: Cannot move this code to a function in the utils/workflow folder
# because the Sign Module code above relocates that folder
Expand-Archive -Path "ScubaGear-${{ inputs.version }}.zip"
Get-ChildItem
Set-Location -Path "ScubaGear-${{ inputs.version }}"
Expand Down
8 changes: 5 additions & 3 deletions Testing/workflow/Build-SignRelease.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# temp placeholder for a real test
Describe "Build Sign Release Check" {
It "Should Have Trivial Test" {
$false | Should -BeFalse
Describe "Install AST Check" {
It "Should be installed" {
$ToolPath = (Get-Command AzureSignTool).Path
Write-Warning "The path to AzureSignTool is $ToolPath"
Test-Path -Path $TooPath | Should -Be -True
}
}
29 changes: 12 additions & 17 deletions utils/workflow/Build-SignRelease.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
function Install-AzureSigningTool {
<#
.SYNOPSIS
Install Azure Signing Tool
#>

Write-Warning "Installing AST..."

dotnet --version
dotnet tool install --global AzureSignTool --version 5.0.0
}

function New-ModuleSignature {
<#
.SYNOPSIS
Expand Down Expand Up @@ -46,20 +58,3 @@ function New-ModuleSignature {
Move-Item -Path repo -Destination "ScubaGear-$ReleaseVersion" -Force
Compress-Archive -Path "ScubaGear-$ReleaseVersion" -DestinationPath "ScubaGear-$ReleaseVersion.zip"
}

function Test-Release {
<#
.SYNOPSIS
Tests a release of ScubaGear from GitHub by executing it.
.PARAMETER $Version
The version of ScubaGear expand and test.
#>

Write-Warning "Testing the release..."

Expand-Archive -Path "ScubaGear-$Version.zip"
Get-ChildItem
Set-Location -Path "ScubaGear-$Version"
Import-Module -Name .\PowerShell\ScubaGear\ScubaGear.psd1
Invoke-SCuBA -Version
}
2 changes: 1 addition & 1 deletion utils/workflow/Publish-ScubaGear.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function New-FileList {

function Use-AzureSignTool {
<#
.DESCRIPTION
.SYNOPSIS
AzureSignTool is a utility for signing code that is used to secure ScubaGear.
https://github.com/vcsjones/AzureSignTool
Throws an error if there was an error signing the files.
Expand Down

0 comments on commit 6676866

Please sign in to comment.