Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements #91

Merged
merged 9 commits into from
Aug 8, 2024
Merged
5 changes: 4 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@
"echo": false,
"showReuseMessage": false
},
"group": "test"
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "DevCC",
Expand Down
13 changes: 10 additions & 3 deletions actions_bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ $modulesToInstall = New-Object System.Collections.Generic.List[object]
# https://github.com/pester/Pester
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.1'
}))
# https://github.com/nightroman/Invoke-Build
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.11.1'
ModuleVersion = '5.11.3'
}))
# https://github.com/PowerShell/PSScriptAnalyzer
[void]$modulesToInstall.Add(([PSCustomObject]@{
Expand All @@ -46,7 +46,14 @@ foreach ($module in $modulesToInstall) {
ErrorAction = 'Stop'
}
try {
Install-Module @installSplat
if ($module.ModuleName -eq 'Pester' -and $IsWindows) {
# special case for Pester certificate mismatch with older Pester versions - https://github.com/pester/Pester/issues/2389
# this only affects windows builds
Install-Module @installSplat -SkipPublisherCheck
}
else {
Install-Module @installSplat
}
Import-Module -Name $module.ModuleName -ErrorAction Stop
' - Successfully installed {0}' -f $module.ModuleName
}
Expand Down
22 changes: 22 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.20.0]

- Catesta template module changes
- CI/CD Changes:
- Adjusted all action bootstrap for module installs to include a `SkipPublisherCheck` when installing Pester module on Windows builds. (https://github.com/pester/Pester/issues/2389)
- Pester bumped from `5.5.0` to `5.6.1`
- InvokeBuild bumped from `5.11.1` to `5.11.3`
- **New template question**: Catesta now asks if PowerShell Classes will be used in the module project. If `Yes` is specified a Classes structure will be scaffold.
- Sample pester tests for Pester v5 refactored to follow Pester 5 rules
- Refactored `ExportedFunctions.Tests.ps1` for better efficiency in loops
- Minor spelling correction in sample Pester tests
- `tasks.json`
- `Test` task is now explicitly set as default test task
- Catesta primary module changes
- `tasks.json`
- `Test` task is now explicitly set as default test task
- Pester bumped from `5.5.0` to `5.6.1`
- InvokeBuild bumped from `5.11.1` to `5.11.3`
- Adjusted action bootstrap for module installs to include a `SkipPublisherCheck` when installing Pester module on Windows builds. (https://github.com/pester/Pester/issues/2389)
- Refactored all unit and infra tests to adhere to Pester 5 rules
- Refactored `ExportedFunctions.Tests.ps1` for better efficiency in loops

## [2.12.0]

- Catesta template module changes
Expand Down
3 changes: 3 additions & 0 deletions docs/Catesta-Basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ New-VaultProject -DestinationPath $outPutPath
* **Enter a description for the module:** *Description of what your module does*
* **Enter the version number of the module (0.0.1)**: *Starting version #*
* **Enter your full name**: *Module author name*
* **Will you use classes in your module?**
* [N] No
* [Y] Yes
* **Which CICD tool will you use to build and deploy your project?**: *Choose CI/CD tool for automated project build and deployment.*
* [M] Module Only
* [G] GitHub Actions
Expand Down
9 changes: 9 additions & 0 deletions docs/Catesta-ModuleSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ name : FN
type : user-fullname
default :

name : psClasses
type : choice
choices:
value : No
help : Classes will not be used in this PowerShell module.
value : Yes
help : Classes will be used in this PowerShell module.

name : CICD
type : choice
choices:
Expand Down Expand Up @@ -254,6 +262,7 @@ ModuleName = 'text'
Description = 'text'
Version = '0.0.1'
FN = 'user full name'
psClasses = 'No'
CICD = 'GITHUB'
GitHubAOptions = 'windows','pwshcore','linux','macos'
AWSOptions = 'ps','pwshcore','pwsh'
Expand Down
2 changes: 1 addition & 1 deletion docs/Catesta.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module Name: Catesta
Module Guid: 6796b193-9013-468a-b022-837749af2d06
Download Help Link: NA
Help Version: 2.12.0
Help Version: 2.20.0
Locale: en-US
---

Expand Down
7 changes: 3 additions & 4 deletions src/Catesta.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ Add-BuildTask Test {
if ($env:CI -and $IsMacOS) {
# the MacOS github action does not properly detect the relative path.
Write-Build White " CI: $env:CI and MacOS action detected. Hard coding path."
$pesterConfiguration.CodeCoverage.Path = "/Users/runner/work/Catesta/Catesta/src/Catesta/*/*.ps1"
$pesterConfiguration.CodeCoverage.Path = "/Users/runner/work/$ModuleName/$ModuleName/src/$ModuleName/*/*.ps1"
}
else {
$pesterConfiguration.CodeCoverage.Path = "..\..\..\$ModuleName\*\*.ps1"
$pesterConfiguration.CodeCoverage.Path = "..\..\..\src\$ModuleName\*\*.ps1"
}
$pesterConfiguration.TestResult.Enabled = $true
$pesterConfiguration.TestResult.OutputPath = "$testOutPutPath\PesterTests.xml"
Expand Down Expand Up @@ -472,6 +472,7 @@ Add-BuildTask AssetCopy -Before Build {
Copy-Item -Path "$script:ModuleSourcePath\*" -Destination $script:ArtifactsPath -Exclude *.psd1, *.psm1 -Recurse -ErrorAction Stop
Copy-Item -Path "$script:ModuleSourcePath\Resources\Module\src\PSScriptAnalyzerSettings.psd1" -Destination "$script:ArtifactsPath\Resources\Module\src\PSScriptAnalyzerSettings.psd1" -ErrorAction Stop
Copy-Item -Path "$script:ModuleSourcePath\Resources\Module\src\Module\Module.psm1" -Destination "$script:ArtifactsPath\Resources\Module\src\Module\Module.psm1" -ErrorAction Stop
Copy-Item -Path "$script:ModuleSourcePath\Resources\Module\src\Module\Module_Classes.psm1" -Destination "$script:ArtifactsPath\Resources\Module\src\Module\Module_Classes.psm1" -ErrorAction Stop
# Copy-Item -Path "$script:ModuleSourcePath\Resources\Vault\src\PSVault\PSVault.psd1" -Destination "$script:ArtifactsPath\Resources\Vault\src\PSVault\PSVault.psd1" -ErrorAction Stop
Copy-Item -Path "$script:ModuleSourcePath\Resources\Vault\src\PSVault\PSVault.psm1" -Destination "$script:ArtifactsPath\Resources\Vault\src\PSVault\PSVault.psm1" -ErrorAction Stop
Copy-Item -Path "$script:ModuleSourcePath\Resources\Vault\src\PSVault\PSVault.Extension\PSVault.Extension.psd1" -Destination "$script:ArtifactsPath\Resources\Vault\src\PSVault\PSVault.Extension\PSVault.Extension.psd1" -ErrorAction Stop
Expand Down Expand Up @@ -526,8 +527,6 @@ Add-BuildTask Build {
Write-Build Green ' ...Build Complete!'
} #Build

# TODO: schema generator step

#Synopsis: Invokes all Pester Integration Tests in the Tests\Integration folder (if it exists)
Add-BuildTask IntegrationTest {
if (Test-Path -Path $script:IntegrationTestsPath) {
Expand Down
2 changes: 1 addition & 1 deletion src/Catesta/Catesta.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'Catesta.psm1'

# Version number of this module.
ModuleVersion = '2.12.0'
ModuleVersion = '2.20.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
13 changes: 10 additions & 3 deletions src/Catesta/Resources/AWS/install_modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ elseif ($PLASTER_PARAM_Pester-eq '5') {
# https://github.com/pester/Pester
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.1'
BucketName = '<%=$PLASTER_PARAM_S3Bucket%>'
KeyPrefix = ''
}))
Expand All @@ -68,7 +68,7 @@ elseif ($PLASTER_PARAM_Pester-eq '5') {
%>
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.11.1'
ModuleVersion = '5.11.3'
BucketName = '<%=$PLASTER_PARAM_S3Bucket%>'
KeyPrefix = ''
}))
Expand Down Expand Up @@ -204,7 +204,14 @@ else {
ErrorAction = 'Stop'
}
try {
Install-Module @installSplat
if ($module.ModuleName -eq 'Pester' -and $IsWindows) {
# special case for Pester certificate mismatch with older Pester versions - https://github.com/pester/Pester/issues/2389
# this only affects windows builds
Install-Module @installSplat -SkipPublisherCheck
}
else {
Install-Module @installSplat
}
Import-Module -Name $module.ModuleName -ErrorAction Stop
' - Successfully installed {0}' -f $module.ModuleName
}
Expand Down
4 changes: 2 additions & 2 deletions src/Catesta/Resources/AppVeyor/actions_bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ elseif ($PLASTER_PARAM_Pester-eq '5') {
# https://github.com/pester/Pester
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.1'
}))
'@
}
%>
# https://github.com/nightroman/Invoke-Build
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.11.1'
ModuleVersion = '5.11.3'
}))
# https://github.com/PowerShell/PSScriptAnalyzer
[void]$modulesToInstall.Add(([PSCustomObject]@{
Expand Down
13 changes: 10 additions & 3 deletions src/Catesta/Resources/Azure/actions_bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ elseif ($PLASTER_PARAM_Pester-eq '5') {
# https://github.com/pester/Pester
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.1'
}))
'@
}
%>
# https://github.com/nightroman/Invoke-Build
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.11.1'
ModuleVersion = '5.11.3'
}))
# https://github.com/PowerShell/PSScriptAnalyzer
[void]$modulesToInstall.Add(([PSCustomObject]@{
Expand Down Expand Up @@ -67,7 +67,14 @@ foreach ($module in $modulesToInstall) {
ErrorAction = 'Stop'
}
try {
Install-Module @installSplat
if ($module.ModuleName -eq 'Pester' -and $IsWindows) {
# special case for Pester certificate mismatch with older Pester versions - https://github.com/pester/Pester/issues/2389
# this only affects windows builds
Install-Module @installSplat -SkipPublisherCheck
}
else {
Install-Module @installSplat
}
Import-Module -Name $module.ModuleName -ErrorAction Stop
' - Successfully installed {0}' -f $module.ModuleName
}
Expand Down
13 changes: 10 additions & 3 deletions src/Catesta/Resources/Bitbucket/actions_bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ elseif ($PLASTER_PARAM_Pester-eq '5') {
# https://github.com/pester/Pester
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.1'
}))
'@
}
%>
# https://github.com/nightroman/Invoke-Build
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.11.1'
ModuleVersion = '5.11.3'
}))
# https://github.com/PowerShell/PSScriptAnalyzer
[void]$modulesToInstall.Add(([PSCustomObject]@{
Expand Down Expand Up @@ -67,7 +67,14 @@ foreach ($module in $modulesToInstall) {
ErrorAction = 'Stop'
}
try {
Install-Module @installSplat
if ($module.ModuleName -eq 'Pester' -and $IsWindows) {
# special case for Pester certificate mismatch with older Pester versions - https://github.com/pester/Pester/issues/2389
# this only affects windows builds
Install-Module @installSplat -SkipPublisherCheck
}
else {
Install-Module @installSplat
}
Import-Module -Name $module.ModuleName -ErrorAction Stop
' - Successfully installed {0}' -f $module.ModuleName
}
Expand Down
32 changes: 20 additions & 12 deletions src/Catesta/Resources/Editor/VSCode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@
"echo": false,
"showReuseMessage": false
},
"group": "test"
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "DevCC",
Expand Down Expand Up @@ -212,11 +215,12 @@ if ($PLASTER_PARAM_Pester-eq '4') {
@'
"command": "Import-Module -Name Pester -MaximumVersion 4.99.99;Invoke-Pester '${workspaceFolder}/src/Tests/Unit' -PesterOption @{IncludeVSCodeMarker=$true}",
'@
}
}
elseif ($PLASTER_PARAM_Pester-eq '5') {
@'
"command": "Invoke-Pester '${workspaceFolder}/src/Tests/Unit' -Output Detailed",
'@ }
'@
}
%>
"problemMatcher": "$pester",
"group": "test"
Expand All @@ -229,10 +233,11 @@ if ($PLASTER_PARAM_Pester-eq '4') {
@'
"command": "Import-Module -Name Pester -MaximumVersion 4.99.99;Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/*/${input:functionName}.Tests.ps1' -CodeCoverage '${workspaceFolder}/src/${workspaceFolderBasename}/*/${input:functionName}.ps1'",
'@
}
}
elseif ($PLASTER_PARAM_Pester-eq '5') { @'
"command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';$pesterConfig = New-PesterConfiguration;$pesterConfig.run.Path = '${workspaceFolder}/src/Tests/Unit/*/${input:functionName}.Tests.ps1';$pesterConfig.CodeCoverage.Enabled = $true;$pesterConfig.CodeCoverage.Path = '${workspaceFolder}/src/${workspaceFolderBasename}/*/${input:functionName}.ps1';Invoke-Pester -Configuration $pesterConfig",
'@ }
'@
}
%>
"problemMatcher": "$pester",
"presentation": {
Expand All @@ -249,10 +254,11 @@ if ($PLASTER_PARAM_Pester-eq '4') {
@'
"command": "Import-Module -Name Pester -MaximumVersion 4.99.99;Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/*/${input:functionName}.Tests.ps1'",
'@
}
}
elseif ($PLASTER_PARAM_Pester-eq '5') { @'
"command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Unit/*/${input:functionName}.Tests.ps1' -Output Detailed",
'@ }
'@
}
%>
"problemMatcher": "$pester",
"presentation": {
Expand All @@ -269,11 +275,12 @@ if ($PLASTER_PARAM_Pester-eq '4') {
@'
"command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Import-Module -Name Pester -MaximumVersion 4.99.99;Invoke-Pester '${workspaceFolder}/src/Tests/Unit/*/${input:functionName}.Tests.ps1' -CodeCoverage '${workspaceFolder}/src/${workspaceFolderBasename}/*/${input:functionName}.ps1' -CodeCoverageOutputFile '${workspaceFolder}/cov.xml'",
'@
}
}
elseif ($PLASTER_PARAM_Pester-eq '5') {
@'
"command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';$pesterConfig = New-PesterConfiguration;$pesterConfig.run.Path = '${workspaceFolder}/src/Tests/Unit/*/${input:functionName}.Tests.ps1';$pesterConfig.CodeCoverage.Enabled = $true;$pesterConfig.CodeCoverage.Path = '${workspaceFolder}/src/${workspaceFolderBasename}/*/${input:functionName}.ps1';$pesterConfig.CodeCoverage.OutputPath = '${workspaceFolder}/cov.xml';$pesterConfig.CodeCoverage.OutputFormat = 'CoverageGutters';Invoke-Pester -Configuration $pesterConfig",
'@ }
'@
}
%>
"problemMatcher": "$pester",
"presentation": {
Expand All @@ -290,10 +297,11 @@ if ($PLASTER_PARAM_Pester-eq '4') {
@'
"command": "Import-Module -Name Pester -MaximumVersion 4.99.99;Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Integration/*/${input:functionName}.Tests.ps1'",
'@
}
}
elseif ($PLASTER_PARAM_Pester-eq '5') { @'
"command": "Import-Module -Name '${workspaceFolder}/src/${workspaceFolderBasename}/${workspaceFolderBasename}.psm1';Invoke-Pester '${workspaceFolder}/src/Tests/Integration/*/${input:functionName}.Tests.ps1' -Output Detailed",
'@ }
'@
}
%>
"problemMatcher": "$pester",
"presentation": {
Expand All @@ -310,4 +318,4 @@ elseif ($PLASTER_PARAM_Pester-eq '5') { @'
"description": "Name of PowerShell function you want to test"
}
]
}
}
13 changes: 10 additions & 3 deletions src/Catesta/Resources/GitHubActions/actions_bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ elseif ($PLASTER_PARAM_Pester-eq '5') {
# https://github.com/pester/Pester
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'Pester'
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.1'
}))
'@
}
%>
# https://github.com/nightroman/Invoke-Build
[void]$modulesToInstall.Add(([PSCustomObject]@{
ModuleName = 'InvokeBuild'
ModuleVersion = '5.11.1'
ModuleVersion = '5.11.3'
}))
# https://github.com/PowerShell/PSScriptAnalyzer
[void]$modulesToInstall.Add(([PSCustomObject]@{
Expand Down Expand Up @@ -67,7 +67,14 @@ foreach ($module in $modulesToInstall) {
ErrorAction = 'Stop'
}
try {
Install-Module @installSplat
if ($module.ModuleName -eq 'Pester' -and $IsWindows) {
# special case for Pester certificate mismatch with older Pester versions - https://github.com/pester/Pester/issues/2389
# this only affects windows builds
Install-Module @installSplat -SkipPublisherCheck
}
else {
Install-Module @installSplat
}
Import-Module -Name $module.ModuleName -ErrorAction Stop
' - Successfully installed {0}' -f $module.ModuleName
}
Expand Down
Loading
Loading