Skip to content

Commit de95e05

Browse files
🌟 [Major]: Module folder restructure to support variables (#68)
## Description <!-- Add your description here --> ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [x] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 87ed2b6 commit de95e05

33 files changed

+293
-55
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,3 @@ updates:
99
directory: / # Location of package manifests
1010
schedule:
1111
interval: weekly
12-
- package-ecosystem: nuget # See documentation for possible values
13-
directory: / # Location of package manifests
14-
schedule:
15-
interval: weekly

.github/workflows/Action-Test-Src-Default.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest, macos-latest, windows-latest]
19-
shell: [pwsh]
20-
include:
21-
- os: windows-latest
22-
shell: powershell
23-
name: Action-Test [Src-Default] - [${{ matrix.os }}@${{ matrix.shell }}]
19+
name: Action-Test [Src-Default] - [${{ matrix.os }}]
2420
runs-on: ${{ matrix.os }}
2521
steps:
2622
- name: Checkout repo
2723
uses: actions/checkout@v4
2824

2925
- name: Initialize environment
3026
uses: PSModule/Initialize-PSModule@main
31-
with:
32-
Shell: ${{ matrix.shell }}
3327

3428
- name: Action-Test
3529
uses: ./
@@ -38,5 +32,4 @@ jobs:
3832
with:
3933
Name: PSModuleTest
4034
Path: tests/src
41-
Shell: ${{ matrix.shell }}
4235
TestType: SourceCode

.github/workflows/Action-Test-Src-WithManifest.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest, macos-latest, windows-latest]
19-
shell: [pwsh]
20-
include:
21-
- os: windows-latest
22-
shell: powershell
23-
name: Action-Test [Src-WithManifest] - [${{ matrix.os }}@${{ matrix.shell }}]
19+
name: Action-Test [Src-WithManifest] - [${{ matrix.os }}]
2420
runs-on: ${{ matrix.os }}
2521
steps:
2622
- name: Checkout repo
2723
uses: actions/checkout@v4
2824

2925
- name: Initialize environment
3026
uses: PSModule/Initialize-PSModule@main
31-
with:
32-
Shell: ${{ matrix.shell }}
3327

3428
- name: Action-Test
3529
uses: ./
@@ -38,5 +32,4 @@ jobs:
3832
with:
3933
Name: PSModuleTest
4034
Path: tests/srcWithManifest
41-
Shell: ${{ matrix.shell }}
4235
TestType: SourceCode

.github/workflows/Action-Test-outputs.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os: [ubuntu-latest, macos-latest, windows-latest]
19-
shell: [pwsh]
20-
include:
21-
- os: windows-latest
22-
shell: powershell
23-
name: Action-Test [outputs] - [${{ matrix.os }}@${{ matrix.shell }}]
19+
name: Action-Test [outputs] - [${{ matrix.os }}]
2420
runs-on: ${{ matrix.os }}
2521
steps:
2622
- name: Checkout repo
2723
uses: actions/checkout@v4
2824

2925
- name: Initialize environment
3026
uses: PSModule/Initialize-PSModule@main
31-
with:
32-
Shell: ${{ matrix.shell }}
3327

3428
- name: Action-Test
3529
uses: ./
@@ -38,5 +32,4 @@ jobs:
3832
with:
3933
Name: PSModuleTest
4034
Path: tests/outputs/modules
41-
Shell: ${{ matrix.shell }}
4235
TestType: Module

.github/workflows/Linter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
env:
2929
GITHUB_TOKEN: ${{ github.token }}
3030
VALIDATE_JSCPD: false
31+
VALIDATE_MARKDOWN_PRETTIER: false
32+
VALIDATE_YAML_PRETTIER: false

action.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,22 @@ runs:
3333
using: composite
3434
steps:
3535
- name: Run Test-PSModule
36+
uses: PSModule/GitHub-Script@v1
3637
id: test
37-
shell: ${{ inputs.Shell }}
3838
env:
3939
GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }}
4040
GITHUB_ACTION_INPUT_Path: ${{ inputs.Path }}
4141
GITHUB_ACTION_INPUT_TestType: ${{ inputs.TestType }}
4242
GITHUB_ACTION_INPUT_TestsPath: ${{ inputs.TestsPath }}
43-
run: |
44-
# Test-PSModule
45-
$passed = . "$env:GITHUB_ACTION_PATH\scripts\main.ps1" -Verbose
46-
"passed=$passed" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
43+
with:
44+
Script: |
45+
# Test-PSModule
46+
$passed = . "${{ github.action_path }}\scripts\main.ps1" -Verbose
47+
"passed=$passed" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
4748
48-
if (-not $passed) {
49-
exit 1
50-
}
49+
if (-not $passed) {
50+
exit 1
51+
}
5152
5253
- name: Upload test results
5354
uses: actions/upload-artifact@v4

scripts/helpers/Test-PSModule.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Test-PSModule {
4242
#region Add test - Common - PSScriptAnalyzer
4343
Start-LogGroup 'Add test - Common - PSScriptAnalyzer'
4444
$containers = @()
45-
$PSSATestsPath = Join-Path -Path $env:GITHUB_ACTION_PATH -ChildPath 'scripts\tests\PSScriptAnalyzer'
45+
$PSSATestsPath = Join-Path -Path $PSScriptRoot -ChildPath '..\tests\PSScriptAnalyzer'
4646
$settingsFileName = if ($testModule) { 'Settings.Module.psd1' } else { 'Settings.SourceCode.psd1' }
4747
$settingsFilePath = Join-Path -Path $PSSATestsPath -ChildPath $settingsFileName
4848
$containerParams = @{
@@ -62,7 +62,7 @@ function Test-PSModule {
6262
#region Add test - Common - PSModule
6363
Start-LogGroup 'Add test - Common - PSModule'
6464
$containerParams = @{
65-
Path = Join-Path -Path $env:GITHUB_ACTION_PATH -ChildPath 'scripts\tests\PSModule\Common.Tests.ps1'
65+
Path = Join-Path -Path $PSScriptRoot -ChildPath '..\tests\PSModule\Common.Tests.ps1'
6666
Data = @{
6767
Path = $Path
6868
Verbose = $true
@@ -78,7 +78,7 @@ function Test-PSModule {
7878
if ($testModule) {
7979
Start-LogGroup 'Add test - Module - PSModule'
8080
$containerParams = @{
81-
Path = Join-Path -Path $env:GITHUB_ACTION_PATH -ChildPath 'scripts\tests\PSModule\Module.Tests.ps1'
81+
Path = Join-Path -Path $PSScriptRoot -ChildPath '..\tests\PSModule\Module.Tests.ps1'
8282
Data = @{
8383
Path = $Path
8484
Verbose = $true
@@ -95,7 +95,7 @@ function Test-PSModule {
9595
if ($testSourceCode) {
9696
Start-LogGroup 'Add test - SourceCode - PSModule'
9797
$containerParams = @{
98-
Path = Join-Path -Path $env:GITHUB_ACTION_PATH -ChildPath 'scripts\tests\PSModule\SourceCode.Tests.ps1'
98+
Path = Join-Path -Path $PSScriptRoot -ChildPath '..\tests\PSModule\SourceCode.Tests.ps1'
9999
Data = @{
100100
Path = $Path
101101
TestsPath = $moduleTestsPath

scripts/main.ps1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
#REQUIRES -Modules Utilities
2-
3-
[CmdletBinding()]
1+
[CmdletBinding()]
42
param()
53

6-
Start-LogGroup 'Loading helper scripts'
7-
Get-ChildItem -Path (Join-Path -Path $env:GITHUB_ACTION_PATH -ChildPath 'scripts\helpers') -Filter '*.ps1' -Recurse |
8-
ForEach-Object { Write-Verbose "[$($_.FullName)]"; . $_.FullName }
9-
Stop-LogGroup
4+
$path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers')
5+
LogGroup "Loading helper scripts from [$path]" {
6+
Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | ForEach-Object {
7+
Write-Verbose "[$($_.FullName)]"
8+
. $_.FullName
9+
}
10+
}
1011

1112
Start-LogGroup 'Loading inputs'
1213
$moduleName = if ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) { $env:GITHUB_REPOSITORY_NAME } else { $env:GITHUB_ACTION_INPUT_Name }
@@ -26,16 +27,16 @@ if (-not (Test-Path -Path $codeToTest)) {
2627
Write-Verbose "Test type to run: [$env:GITHUB_ACTION_INPUT_TestType]"
2728

2829
$testsPath = $env:GITHUB_ACTION_INPUT_TestsPath
29-
Write-Verbose "Path to tests: [$testsPath]"
30+
Write-Verbose "Path to tests: [$testsPath]"
3031
if (-not (Test-Path -Path $testsPath)) {
3132
throw "Path [$testsPath] does not exist."
3233
}
3334

3435
Stop-LogGroup
3536

3637
$params = @{
37-
Path = $codeToTest
38-
TestType = $env:GITHUB_ACTION_INPUT_TestType
38+
Path = $codeToTest
39+
TestType = $env:GITHUB_ACTION_INPUT_TestType
3940
TestsPath = $testsPath
4041
}
4142
$results = Test-PSModule @params

scripts/tests/PSModule/SourceCode.Tests.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ Param(
1313

1414
BeforeAll {
1515
$scriptFiles = Get-ChildItem -Path $Path -Include *.psm1, *.ps1 -Recurse -File
16-
$functionFiles = Get-ChildItem -Directory -Path $Path |
17-
Where-Object { $_.Name -in 'public', 'private' } |
18-
Get-ChildItem -Filter '*.ps1' -File
19-
20-
$publicFunctionFiles = Get-ChildItem -Directory -Path (Join-Path -Path $Path -ChildPath 'public') -File -Filter '*.ps1'
16+
$functionsPath = Join-Path -Path $Path -ChildPath 'functions'
17+
# $privateFunctionsPath = Join-Path -Path $functionsPath -ChildPath 'private'
18+
$publicFunctionsPath = Join-Path -Path $functionsPath -ChildPath 'public'
19+
# $variablesPath = Join-Path -Path $Path -ChildPath 'variables'
20+
# $privateVariablesPath = Join-Path -Path $variablesPath -ChildPath 'private'
21+
# $publicVariablesPath = Join-Path -Path $variablesPath -ChildPath 'public'
22+
$functionFiles = (Test-Path -Path $functionsPath) ? (Get-ChildItem -Path $functionsPath -Filter '*.ps1' -File) : $null
23+
$publicFunctionFiles = (Test-Path -Path $publicFunctionsPath) ? (Get-ChildItem -Path $publicFunctionsPath -File -Filter '*.ps1' -Recurse) : $null
2124

2225
Write-Verbose "Found $($scriptFiles.Count) script files in $Path"
2326
Write-Verbose "Found $($functionFiles.Count) function files in $Path"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class SecretWriter {
2+
[string] $Alias
3+
[string] $Name
4+
[string] $Secret
5+
6+
SecretWriter([string] $alias, [string] $name, [string] $secret) {
7+
$this.Alias = $alias
8+
$this.Name = $name
9+
$this.Secret = $secret
10+
}
11+
12+
[string] GetAlias() {
13+
return $this.Alias
14+
}
15+
}

0 commit comments

Comments
 (0)