Skip to content

Commit 95735fd

Browse files
authored
Merge pull request #181 from rulasg/Test-TestingHelperResults
fix(releae): fix deploy workflow
2 parents 8e49d54 + 9aed4af commit 95735fd

11 files changed

Lines changed: 351 additions & 122 deletions

.github/workflows/deploy_module_on_release.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ jobs:
1919
run: |
2020
echo $EVENT_CONTEXT
2121
22+
- name: Run test.ps1
23+
shell: pwsh
24+
run: |
25+
$result = ./test.ps1 -ShowTestErrors
26+
27+
Write-Output $result
28+
29+
import-module ./tools/Test_Helper/
30+
31+
$passed = Test-Result -Result $result
32+
33+
if($passed)
34+
{ "All test passed" | Write-Verbose -verbose ; exit 0 }
35+
else
36+
{ "Not all tests passed" | Write-Verbose -verbose ; exit 1 }
37+
2238
- name: deploy_ps1
2339
shell: pwsh
2440
env:
@@ -27,8 +43,16 @@ jobs:
2743
RELEASE_TAG: ${{ github.event.release.tag_name }}
2844
RELEASE_NAME: ${{ github.event.release.name }}
2945
run: |
30-
$env:EVENT_REF = $env:REF
3146
47+
# Import required modules for deployment
48+
import-module ./tools/Test_Helper/
49+
50+
Get-RequiredModule -Verbose | Import-RequiredModule -AllowPrerelease
51+
52+
# GET TAG NAME
53+
54+
## Ref definition. Branch or Tag
55+
$env:EVENT_REF = $env:REF
3256
If ([string]::IsNullOrEmpty($env:EVENT_REF)) {
3357
# Release published trigger
3458
$tag = $env:RELEASE_TAG
@@ -41,9 +65,9 @@ jobs:
4165
4266
If([string]::IsNullorwhitespace($tag)) {
4367
# Tag name is empty, exit
44-
write-error "Tag name is empty"
45-
exit 1
68+
throw "Tag name is empty"
4669
}
4770
71+
# DEPLOYMENT
4872
./deploy.ps1 -VersionTag $tag -NugetApiKey $env:NUGETAPIKEY
4973

.github/workflows/test_with_TestingHelper.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ jobs:
3333
shell: pwsh
3434
run: |
3535
$result = ./test.ps1 -ShowTestErrors
36-
$result
36+
37+
Write-Output $result
3738
38-
# Allow Not Implemented and Skipped tests to pass
39-
$passed = $result.Tests -eq $result.Pass + $result.NotImplemented + $result.Skipped
40-
# $passed = $result.Tests -eq $result.Pass
39+
import-module ./tools/Test_Helper/
40+
41+
$passed = Test-Result -Result $result
4142
4243
if($passed)
4344
{ "All test passed" | Write-Verbose -verbose ; exit 0 }

Test/mockfiles.log

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@
205205
},
206206
{
207207
"FileName": "invoke-GitHubOrgProjectWithFields-octodemo-700-query-field-text.json",
208-
"Command": "Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields \"\" -afterItems \"\" -query \"updated:<2025-03-15\""
208+
"Command": "Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields \"\" -afterItems \"\" -query \"updated:>=2024-02-18\""
209+
},
210+
{
211+
"FileName": "invoke-GitHubOrgProjectWithFields-octodemo-700-query-field-text.json",
212+
"Command": "Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields \"\" -afterItems \"\" -query \"updated:>=2025-03-15\""
209213
}
210214
]

Test/traceInvoke.log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ Invoke-GetUser -Handle rulasg
7878
Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg=" -Role "WRITER"
7979
Invoke-GetUser -Handle rauldibildos
8080
Invoke-UpdateProjectV2Collaborators -ProjectId PVT_kwDOAlIw4c4BCe3V -collaborators "MDQ6VXNlcjY4ODQ0MDg= U_kgDOC_E3gw" -Role "WRITER"
81-
Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "updated:<2025-03-15"
81+
Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "updated:>=2024-02-18"
82+
Invoke-GitHubOrgProjectWithFields -Owner octodemo -ProjectNumber 700 -afterFields "" -afterItems "" -query "updated:>=2025-03-15"

test.ps1

Lines changed: 2 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -18,121 +18,10 @@ param (
1818
[Parameter()][string]$TestName
1919
)
2020

21-
function Set-TestName{
22-
[CmdletBinding()]
23-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Scope='Function')]
24-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function')]
25-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Scope='Function')]
26-
[Alias("st")]
27-
param (
28-
[Parameter(Position=0,ValueFromPipeline)][string]$TestName
29-
)
30-
31-
process{
32-
$global:TestNameVar = $TestName
33-
}
34-
}
35-
36-
function Get-TestName{
37-
[CmdletBinding()]
38-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Scope='Function')]
39-
[Alias("gt")]
40-
param (
41-
)
42-
43-
process{
44-
$global:TestNameVar
45-
}
46-
}
47-
48-
function Clear-TestName{
49-
[CmdletBinding()]
50-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Scope='Function')]
51-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function')]
52-
[Alias("ct")]
53-
param (
54-
)
55-
56-
$global:TestNameVar = $null
57-
}
58-
59-
function Import-RequiredModule{
60-
[CmdletBinding()]
61-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope='Function')]
62-
param (
63-
[Parameter(ParameterSetName = "HT", ValueFromPipeline)][hashtable]$RequiredModule,
64-
[Parameter(ParameterSetName = "RM",Position = 0)][string]$ModuleName,
65-
[Parameter(ParameterSetName = "RM")][string]$ModuleVersion,
66-
[Parameter(ParameterSetName = "HT")]
67-
[Parameter(ParameterSetName = "RM")]
68-
[switch]$AllowPrerelease,
69-
[Parameter(ParameterSetName = "HT")]
70-
[Parameter(ParameterSetName = "RM")]
71-
[switch]$PassThru
72-
)
73-
74-
process{
75-
# Powershell module manifest does not allow versions with prerelease tags on them.
76-
# Powershell modle manifest does not allow to add a arbitrary field to specify prerelease versions.
77-
# Valid value (ModuleName, ModuleVersion, RequiredVersion, GUID)
78-
# There is no way to specify a prerelease required module.
79-
80-
if($RequiredModule){
81-
$ModuleName = $RequiredModule.ModuleName
82-
$ModuleVersion = [string]::IsNullOrWhiteSpace($RequiredModule.RequiredVersion) ? $RequiredModule.ModuleVersion : $RequiredModule.RequiredVersion
83-
}
84-
85-
"Importing module Name[{0}] Version[{1}] AllowPrerelease[{2}]" -f $ModuleName, $ModuleVersion, $AllowPrerelease | Write-Verbose
86-
87-
# Following semVer we can manually specidy a taged version to specify that is prerelease
88-
# Extract the semVer from it and set AllowPrerelease to true
89-
if ($ModuleVersion) {
90-
$V = $ModuleVersion.Split('-')
91-
$semVer = $V[0]
92-
$AllowPrerelease = ($AllowPrerelease -or ($null -ne $V[1]))
93-
}
94-
95-
$module = Import-Module $ModuleName -PassThru -ErrorAction SilentlyContinue -MinimumVersion:$semVer
96-
97-
if ($null -eq $module) {
98-
"Installing module Name[{0}] Version[{1}] AllowPrerelease[{2}]" -f $ModuleName, $ModuleVersion, $AllowPrerelease | Write-Host -ForegroundColor DarkGray
99-
$installed = Install-Module -Name $ModuleName -Force -AllowPrerelease:$AllowPrerelease -passThru -RequiredVersion:$ModuleVersion
100-
$module = $installed | ForEach-Object {Import-Module -Name $_.Name -RequiredVersion ($_.Version.Split('-')[0]) -Force -PassThru}
101-
}
102-
103-
"Imported module Name[{0}] Version[{1}] PreRelease[{2}]" -f $module.Name, $module.Version, $module.privatedata.psdata.prerelease | Write-Host -ForegroundColor DarkGray
104-
105-
if ($PassThru) {
106-
$module
107-
}
108-
}
109-
}
110-
111-
<#
112-
. SYNOPSIS
113-
Extracts the required modules from the module manifest
114-
#>
115-
function Get-RequiredModule{
116-
[CmdletBinding()]
117-
[OutputType([Object[]])]
118-
param()
119-
120-
# Required Modules
121-
$localPath = $PSScriptRoot
122-
$manifest = $localPath | Join-Path -child "*.psd1" | Get-Item | Import-PowerShellDataFile
123-
$requiredModule = $null -eq $manifest.RequiredModules ? @() : $manifest.RequiredModules
124-
125-
# Convert to hashtable
126-
$ret = @()
127-
$requiredModule | ForEach-Object{
128-
$ret += $_ -is [string] ? @{ ModuleName = $_ } : $_
129-
}
130-
131-
return $ret
132-
}
21+
# Load Test_Helper module
22+
Import-Module ./tools/Test_Helper
13323

13424
# Install and load TestingHelper
135-
# Import-RequiredModule -Name TestingHelper -AllowPrerelease
13625
Import-RequiredModule "TestingHelper" -AllowPrerelease
13726

13827
# Install and Load Module dependencies

tools/Test_Helper/Test_Helper.psd1

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#
2+
# Module manifest for module 'Test_Helper'
3+
#
4+
# Generated by: rulasg
5+
#
6+
# Generated on: 20/1/2026
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'Test_Helper.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.0.1'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
19+
20+
# ID used to uniquely identify this module
21+
GUID = '0be904b3-72c4-4e02-882a-153fa558e074'
22+
23+
# Author of this module
24+
Author = 'rulasg'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Unknown'
28+
29+
# Copyright statement for this module
30+
Copyright = '(c) rulasg. All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
# Description = ''
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
# PowerShellVersion = ''
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# ClrVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
# RequiredModules = @()
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @()
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
# FormatsToProcess = @()
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72+
FunctionsToExport = '*'
73+
74+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75+
CmdletsToExport = '*'
76+
77+
# Variables to export from this module
78+
VariablesToExport = '*'
79+
80+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81+
AliasesToExport = '*'
82+
83+
# DSC resources to export from this module
84+
# DscResourcesToExport = @()
85+
86+
# List of all modules packaged with this module
87+
# ModuleList = @()
88+
89+
# List of all files packaged with this module
90+
# FileList = @()
91+
92+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93+
PrivateData = @{
94+
95+
PSData = @{
96+
97+
# Tags applied to this module. These help with module discovery in online galleries.
98+
# Tags = @()
99+
100+
# A URL to the license for this module.
101+
# LicenseUri = ''
102+
103+
# A URL to the main website for this project.
104+
# ProjectUri = ''
105+
106+
# A URL to an icon representing this module.
107+
# IconUri = ''
108+
109+
# ReleaseNotes of this module
110+
# ReleaseNotes = ''
111+
112+
# Prerelease string of this module
113+
Prerelease = 'dev'
114+
115+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
116+
# RequireLicenseAcceptance = $false
117+
118+
# External dependent modules of this module
119+
# ExternalModuleDependencies = @()
120+
121+
} # End of PSData hashtable
122+
123+
} # End of PrivateData hashtable
124+
125+
# HelpInfo URI of this module
126+
# HelpInfoURI = ''
127+
128+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129+
# DefaultCommandPrefix = ''
130+
131+
}
132+

tools/Test_Helper/Test_Helper.psm1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Write-Information -Message ("Loading {0} ..." -f ($PSCommandPath | Split-Path -LeafBase)) -InformationAction continue
2+
3+
#Module path is where resides the RootModule file. This file. :)
4+
$MODULE_PATH = $PSScriptRoot
5+
6+
#Get public and private function definition files.
7+
$Public = @( Get-ChildItem -Path $MODULE_PATH\public\*.ps1 -ErrorAction SilentlyContinue )
8+
$Private = @( Get-ChildItem -Path $MODULE_PATH\private\*.ps1 -ErrorAction SilentlyContinue )
9+
10+
#Dot source the files
11+
Foreach($import in @($Public + $Private))
12+
{
13+
Try
14+
{
15+
. $import.fullname
16+
}
17+
Catch
18+
{
19+
Write-Error -Message "Failed to import function $($import.fullname): $_"
20+
}
21+
}
22+
23+
# Here I might...
24+
# Read in or create an initial config file and variable
25+
# Export Public functions ($Public.BaseName) for WIP modules
26+
# Set variables visible to the module and its functions only
27+

0 commit comments

Comments
 (0)