Skip to content

Commit

Permalink
Using ModuleTools
Browse files Browse the repository at this point in the history
  • Loading branch information
belibug committed Jun 25, 2024
1 parent 33a85bd commit 0b69b3f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run Tests

# Controls when the workflow will run
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install ModuleTools module form PSGallery
run: |
Install-PSResource -Repository PSGallery -Name ModuleTools -TrustRepository
shell: pwsh

- name: Install ModuleTools module form PSGallery
run: |
Invoke-MTTest
shell: pwsh
7 changes: 5 additions & 2 deletions project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"LicenseUri": "https://github.com/belibug/SecretBackup/blob/main/LICENSE"
},
"Pester": {
"TestResult": false,
"TestResult": {
"Enabled": true,
"OutputFormat": "NUnitXml"
},
"Output": {
"Verbosity": "Detailed"
}
Expand All @@ -35,4 +38,4 @@
"PSAvoidUsingConvertToSecureStringWithPlainText"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
BeforeAll {
Import-Module -Name .\PSPacker
$data = Import-ProjectData
$data = Get-MTProjectInfo
}

Describe 'General Module Control' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
BeforeAll {
Import-Module -Name .\PSPacker
$data = Import-ProjectData
$data = Get-MTProjectInfo
$files = Get-ChildItem $data.OutputModuleDir
}

Expand All @@ -19,8 +18,7 @@ Describe 'Module and Manifest testing' {
$status = (Get-AuthenticodeSignature -FilePath $_).Status
if ($status -eq 'NotSigned') {
Set-TestInconclusive -Message 'Not yet signed'
}
else {
} else {
$status | Should -Be 'Valid'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ BeforeDiscovery {
$files = Get-ChildItem -Path .\src -Filter '*.ps1' -Recurse
}
BeforeAll {
Import-Module -Name .\PSPacker -Force
$data = Import-ProjectData
$ScriptAnalyzerSettings = @{
IncludeDefaultRules = $true
Severity = @('Warning', 'Error')
ExcludeRules = @('PSAvoidUsingWriteHost', 'PSAvoidUsingConvertToSecureStringWithPlainText')
}
}
Describe 'File: <_.basename>' -ForEach $files {
Context 'Code Quality Check' {
Expand All @@ -14,7 +17,7 @@ Describe 'File: <_.basename>' -ForEach $files {
$errors.Count | Should -Be 0
}
It 'passess ScriptAnalyzer' {
$saResults = Invoke-ScriptAnalyzer -Path $_ -Settings $data.PSScriptAnalyzer
$saResults = Invoke-ScriptAnalyzer -Path $_ -Settings $ScriptAnalyzerSettings
$saResults | Should -BeNullOrEmpty -Because $($saResults.Message -join ';')
}
}
Expand Down

0 comments on commit 0b69b3f

Please sign in to comment.