Skip to content

Commit d37b827

Browse files
tablackburnclaude
andcommitted
ci(lint): skip PSScriptAnalyzer on un-initialized template
PowerShell's parser splits the literal './{{ModuleName}}' into mismatched script-block delimiters, so Invoke-ScriptAnalyzer fails before it can read the folder: A positional parameter cannot be found that accepts argument '{ModuleName}'. The original PR claimed lint worked on the template; testing post- Actions-re-enable proves otherwise. Apply the same Detect template state guard the unit-tests job uses, gated on Cache PowerShell modules, Install PSScriptAnalyzer, and Run PSScriptAnalyzer. Downstream init's substitution turns './{{ModuleName}}' into a real path so the guard flips off and lint runs normally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c6a35cf commit d37b827

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/CI.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v6
2020

21+
# Skip lint on the un-initialized template — the literal `./{{ModuleName}}`
22+
# path argument can't be parsed by PowerShell (the double braces split into
23+
# mismatched script-block delimiters), so Invoke-ScriptAnalyzer fails with
24+
# a positional-argument error before it ever touches the folder. Same
25+
# marker as the unit-tests job below.
26+
- name: Detect template state
27+
id: template_guard
28+
shell: bash
29+
run: |
30+
if [ -f CHANGELOG.template.md ]; then
31+
echo "is_template=true" >> "$GITHUB_OUTPUT"
32+
else
33+
echo "is_template=false" >> "$GITHUB_OUTPUT"
34+
fi
35+
2136
- name: Cache PowerShell modules
37+
if: steps.template_guard.outputs.is_template == 'false'
2238
id: cache-lint-modules
2339
uses: actions/cache@v5
2440
with:
@@ -28,13 +44,14 @@ jobs:
2844
${{ runner.os }}-psmodules-lint-
2945
3046
- name: Install PSScriptAnalyzer
31-
if: steps.cache-lint-modules.outputs.cache-hit != 'true'
47+
if: steps.template_guard.outputs.is_template == 'false' && steps.cache-lint-modules.outputs.cache-hit != 'true'
3248
shell: pwsh
3349
run: |
3450
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
3551
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
3652
3753
- name: Run PSScriptAnalyzer
54+
if: steps.template_guard.outputs.is_template == 'false'
3855
shell: pwsh
3956
run: |
4057
$results = Invoke-ScriptAnalyzer -Path ./{{ModuleName}} -Recurse -Settings PSGallery -ReportSummary

0 commit comments

Comments
 (0)