Skip to content

[1.0.0-alpha1] Upgrade to psake 5.0.0 with task caching and LLM output#117

Draft
HeyItsGilbert wants to merge 3 commits intomainfrom
feature/psake5-alpha1
Draft

[1.0.0-alpha1] Upgrade to psake 5.0.0 with task caching and LLM output#117
HeyItsGilbert wants to merge 3 commits intomainfrom
feature/psake5-alpha1

Conversation

@HeyItsGilbert
Copy link
Member

Summary

  • Upgrade to psake 5.0.0 with declarative task syntax, content-addressed caching, and structured PsakeBuildResult output
  • LLM-optimized Pester output — new OutputMode setting (Detailed/Minimal/LLM) where LLM mode emits structured JSON with only failure details, suppressing verbose console noise
  • External PesterConfiguration file support$PSBPreference.Test.PesterConfigurationPath loads a .psd1 as the base config with explicit overrides layered on top
  • Task cachingStageFiles, Analyze, Pester, GenerateMarkdown, GenerateMAML, GenerateUpdatableHelp all declare Inputs/Outputs for incremental build skipping
  • Format-PSBuildResult — new public function formatting PsakeBuildResult for Human, JSON, or GitHubActions consumers
  • Invoke-Build parityIB.tasks.ps1 updated with matching Inputs/Outputs caching and new Pester parameter passthrough

Breaking Changes

Change Migration
Minimum PowerShell raised from 3.0 to 5.1 Ensure PS 5.1+ runtime
psake dependency raised from 4.9.0 to 5.0.0 ./build.ps1 -Bootstrap will install
Invoke-psake returns PsakeBuildResult object Replace $psake.build_success with $result.Success

New $PSBPreference Keys

Key Default Purpose
Build.EnableTaskCaching $true Toggle psake 5 content-addressed caching
Test.OutputMode 'Detailed' Detailed / Minimal / LLM output modes
Test.PesterConfigurationPath $null Path to external .psd1 PesterConfiguration

Files Changed (20)

New files (5): ConvertTo-PSBuildLLMOutput.ps1, Format-PSBuildResult.ps1, LLMOutput.tests.ps1, PesterConfig.tests.ps1, FormatBuildResult.tests.ps1

Major rewrites (1): PowerShellBuild/psakeFile.ps1 — all 16 tasks converted to declarative hashtable syntax with Inputs/Outputs caching

Modified (14): manifest, requirements, build.ps1, root psakeFile, build.properties, Test-PSBuildPester, IB.tasks, Messages.psd1, PowerShellBuild.psm1, CI workflow, CHANGELOG, CLAUDE.md, Manifest.tests, TestModule psakeFile

Known Risks

  • PreCondition in declarative syntax — psake 5.0.0's hashtable Task syntax support for PreCondition key is inferred from the commit, not confirmed by docs. If it fails, mitigation is to move precondition logic into guard clauses at the top of Action scriptblocks.
  • $psake.context.Peek().Tasks.Keys — used by the ? task; may need updating if psake 5.0.0 changes this internal API.

Test plan

  • ./build.ps1 -Bootstrap installs psake 5.0.0 successfully
  • ./build.ps1 -Task Build compiles with declarative task syntax
  • ./build.ps1 -Task Test passes all existing + new tests
  • Verify task caching: second ./build.ps1 -Task Build skips cached tasks
  • Verify LLM output mode produces valid JSON with failure schema
  • Verify PesterConfigurationPath loads external config
  • Verify Format-PSBuildResult -Format JSON produces valid structured output
  • Cross-platform CI green (ubuntu, windows pwsh, windows PS 5.1, macOS)
  • TestModule builds with both psake and Invoke-Build

🤖 Generated with Claude Code

HeyItsGilbert and others added 3 commits March 22, 2026 12:34
Breaking changes:
- Minimum PowerShell raised from 3.0 to 5.1
- psake dependency raised from 4.9.0 to 5.0.0
- Invoke-psake now returns PsakeBuildResult (replaces $psake.build_success)

New features:
- Content-addressed task caching via Inputs/Outputs on cacheable tasks
  (StageFiles, Analyze, Pester, GenerateMarkdown, GenerateMAML, GenerateUpdatableHelp)
- LLM-optimized test output mode ($PSBPreference.Test.OutputMode = 'LLM')
  emits structured JSON with only failure details
- External PesterConfiguration file support via $PSBPreference.Test.PesterConfigurationPath
- Direct PesterConfiguration object passthrough via -Configuration parameter
- Format-PSBuildResult function for Human/JSON/GitHubActions build result formatting
- All psakeFile.ps1 tasks rewritten to declarative hashtable syntax
- Invoke-Build IB.tasks.ps1 updated with matching Inputs/Outputs caching
- Windows PowerShell 5.1 CI matrix entry added

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Updated the GitHub Actions workflow to specify 'main' branch for push events, enabled fail-fast strategy, and added a separate job for testing with PowerShell on Windows.

Signed-off-by: Gilbert Sanchez <me@gilbertsanchez.com>
Signed-off-by: Gilbert Sanchez <me@gilbertsanchez.com>
Comment on lines +27 to +41
name: Test
runs-on: windows-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- name: Test
shell: powershell
env:
DEBUG: ${{ runner.debug == '1' }}
run: |
if($env:DEBUG -eq 'true' -or $env:DEBUG -eq '1') {
$DebugPreference = 'Continue'
}
./build.ps1 -Task Test -Bootstrap

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 2 days ago

To fix the problem, explicitly declare the GITHUB_TOKEN permissions in the workflow using the permissions key, granting only the minimal scopes required. Since these jobs just check out code and run tests/build via build.ps1 and do not interact with issues, pull requests, or modify repository contents, they can typically operate with contents: read only.

The best way to fix this without changing existing functionality is to add a top-level permissions block to .github/workflows/test.yml (so it applies to all jobs) with contents: read. This documents the workflow’s intent and ensures least-privilege defaults if org or repo settings change later. Concretely, insert:

permissions:
  contents: read

between the on: block and the jobs: block (i.e., after line 6 and before line 7). No additional imports or methods are needed, as this is purely a YAML configuration change within the workflow file.

Suggested changeset 1
.github/workflows/test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -4,6 +4,8 @@
     branches: [ main ]
   pull_request:
   workflow_dispatch:
+permissions:
+  contents: read
 jobs:
   test:
     name: Test
EOF
@@ -4,6 +4,8 @@
branches: [ main ]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: Test
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant