Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

# Self-validation for NWarila/powershell-template. Lints workflows
# (actionlint), runs PSScriptAnalyzer with the PSGallery ruleset, and executes
# (actionlint), runs PSScriptAnalyzer with the house settings, and executes
# the Pester v5 suite with NUnit output and a coverage target. Designed to be
# green out of the box so consumers inherit a passing baseline.

Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path . -Settings PSGallery -Recurse
$results = Invoke-ScriptAnalyzer -Path . -Settings ./PSScriptAnalyzerSettings.psd1 -Recurse
if ($results) {
$results | Format-Table -AutoSize | Out-String | Write-Host
$errors = @($results | Where-Object { $_.Severity -eq 'Error' })
Expand Down
17 changes: 13 additions & 4 deletions PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
IncludeRules = @('*')

ExcludeRules = @(
'PSUseCorrectCasing'
'PSUseShouldProcessForStateChangingFunctions'
)

Expand Down Expand Up @@ -60,10 +61,6 @@
CheckHashtable = $true
}

PSUseCorrectCasing = @{
Enable = $true
}

'Measure-PrivateVariableDeclaration' = @{
Enable = $true
}
Expand All @@ -76,6 +73,10 @@
Enable = $true
}

'Measure-CanonicalNamedBlock' = @{
Enable = $true
}

'Measure-ExplicitCmdletBinding' = @{
Enable = $true
}
Expand All @@ -84,12 +85,20 @@
Enable = $true
}

'Measure-CanonicalKeywordCasing' = @{
Enable = $true
}

'Measure-NoRemoveVariableCleanup' = @{
Enable = $true
}

'Measure-NoNewVariableDeclaration' = @{
Enable = $true
}

'Measure-SoftReturn' = @{
Enable = $true
}
}
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/NWarila/powershell-template/actions/workflows/ci.yaml/badge.svg)](https://github.com/NWarila/powershell-template/actions/workflows/ci.yaml)
[![PowerShell 5.1+ / 7+](https://img.shields.io/badge/PowerShell-5.1%2B%20%7C%207%2B-5391FE?logo=powershell&logoColor=white)](https://learn.microsoft.com/powershell/)
[![PSScriptAnalyzer](https://img.shields.io/badge/lint-PSScriptAnalyzer-blue)](https://github.com/PowerShell/PSScriptAnalyzer)
[![PSScriptAnalyzer](https://img.shields.io/badge/lint-house%20PSScriptAnalyzer-blue)](PSScriptAnalyzerSettings.psd1)
[![Tested with Pester](https://img.shields.io/badge/tested%20with-Pester%20v5-green)](https://pester.dev/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

Expand All @@ -17,8 +17,8 @@ rather than a blank canvas.
(exported) and `Private/` (internal), one per file, with an explicit
`FunctionsToExport` list — no wildcard exports.
- **Publish-ready.** The manifest satisfies the PowerShell Gallery's
requirements and the PSGallery PSScriptAnalyzer ruleset, so a module can be
published without rework.
requirements, and the house PSScriptAnalyzer settings keep the module
reviewable without rework.
- **Cross-edition.** Declares `CompatiblePSEditions = @('Core', 'Desktop')`
with a 5.1 floor; CI exercises PowerShell 7 (Core) on Ubuntu.
- **Safe CI.** Least-privilege permissions, SHA-pinned actions, per-job
Expand Down Expand Up @@ -54,7 +54,7 @@ Then edit:
### 3. Validate locally

```bash
pwsh -c "Invoke-ScriptAnalyzer -Path . -Settings PSGallery -Recurse"
pwsh -c "Invoke-ScriptAnalyzer -Path . -Settings ./PSScriptAnalyzerSettings.psd1 -Recurse"
pwsh -File tests/Invoke-Tests.ps1
```

Expand Down Expand Up @@ -86,7 +86,7 @@ The [CI workflow](.github/workflows/ci.yaml) runs on every push and pull request
| Job | What it does |
| ---------------- | ------------------------------------------------------------ |
| actionlint | Lints GitHub Actions workflows |
| PSScriptAnalyzer | `Invoke-ScriptAnalyzer -Settings PSGallery -Recurse` |
| PSScriptAnalyzer | `Invoke-ScriptAnalyzer -Settings ./PSScriptAnalyzerSettings.psd1 -Recurse` |
| Pester | Pester v5 suite, NUnit output, coverage target (≥ 80%) |

## Documentation
Expand Down
Loading