Skip to content

Add log grouping to build.psm1 for collapsible GitHub Actions logs - #26326

Merged
Travis Plunk (TravisEz13) merged 10 commits into
masterfrom
copilot/format-logs-in-github-workflows
Oct 29, 2025
Merged

Travis Plunk (TravisEz13) merged 10 commits into
masterfrom
copilot/format-logs-in-github-workflows

Conversation

Copilot AI commented Oct 28, 2025 •

Copy link
Copy Markdown
Contributor

GitHub Actions logs for PowerShell builds are difficult to navigate due to verbose, flat output. This wraps major build operations with Write-LogGroupStart/Write-LogGroupEnd to create collapsible sections.

Changes

Modified Functions:

  • Start-PSBuild: Grouped restore, build, module restore, and config generation
  • Start-PSBootstrap: Grouped native dependencies, .NET SDK, Windows dependencies, and global tools installation
  • Install-Dotnet: Wrapped entire SDK installation
  • Show-Environment (new): Created function in tools/ci.psm1 to display environment variables in a log group

Documentation Added:

  • Created .github/instructions/log-grouping-guidelines.instructions.md with best practices for using log groups:
    • Groups cannot be nested
    • Groups should contain substantial output (5+ lines)
    • Each group should represent an independent operation
    • Avoid groups in loops or for small operations

Workflow Fixes:

  • Replaced all instances of Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose with Show-Environment function call (6 locations in workflows and actions)
  • Added buildModuleChanged to outputs in linux-ci.yml, windows-ci.yml, and macos-ci.yml
  • Updated all build and test job conditions to include buildModuleChanged == 'true' so builds and tests are triggered when build.psm1 is modified

Guidelines Applied

Based on review feedback, the implementation follows these principles:

  • No Nesting: Groups are not nested to comply with GitHub Actions limitations
  • Substantial Content: Only operations with meaningful output are grouped (small operations like ResGen/TypeGen use simple logging)
  • Independent Operations: Each group represents a logically independent build phase

Example

Before:

Run dotnet restore /src/powershell-unix ...
Done restoring /src/powershell-unix
Run dotnet restore /src/TypeCatalogGen ...
Done restoring /src/TypeCatalogGen
Run dotnet publish --configuration Release
PowerShell output: /path/to/publish/pwsh

After:

::group::Restore NuGet Packages
Run dotnet restore /src/powershell-unix ...
Done restoring /src/powershell-unix
Run dotnet restore /src/TypeCatalogGen ...
Done restoring /src/TypeCatalogGen
::endgroup::
::group::Build PowerShell
Run dotnet publish --configuration Release
PowerShell output: /path/to/publish/pwsh
::endgroup::

Renders as collapsible sections in GitHub Actions UI.

Original prompt

On build.psm1, Analyze the github workflows and use Write-LogGroupStart and Write-LogGroupEnd to format the logs in a more readable way


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…og formatting

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve log formatting in GitHub workflows Add log grouping to build.psm1 for collapsible GitHub Actions logs Oct 28, 2025
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Per review feedback, individual project restore groups are excessive since
each only logs one line. Keep the outer grouping from parent function call.

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Comment thread build.psm1 Resolved
Comment thread build.psm1 Resolved
Copilot AI and others added 2 commits October 28, 2025 23:35
- Removed outer "Bootstrap PowerShell Build Dependencies" group (groups cannot nest)
- Removed small ResGen and TypeGen groups (too small, only 2-3 lines each)
- Keep sub-groups like "Install Native Dependencies", "Install .NET SDK", etc.

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Document best practices learned from code review:
- Groups cannot be nested
- Groups should be substantial (5+ lines)
- Avoid groups in loops or for small operations
- Each group should be an independent operation

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
@TravisEz13 Travis Plunk (TravisEz13) added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Oct 29, 2025
@TravisEz13

Copy link
Copy Markdown
Member

In github workflows, find where we do Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose and create a function in tools/ci.psm1 that does this, to avoid repeating code, wraps it in a log group and replace the original occurences. Copilot

Also, builds and tests are not being triggered when buildModuleChanged is coming from the path-filters action and it should, for linux-ci, windows-ci and macos-ci

- Created Show-Environment function in tools/ci.psm1 to wrap environment
  variable logging with log group (avoids code repetition)
- Replaced all instances of Get-ChildItem -Path env: | Out-String with
  Show-Environment call in workflows and actions
- Added buildModuleChanged to outputs in linux-ci, windows-ci, macos-ci
- Updated all job conditions to include buildModuleChanged so builds and
  tests trigger when build.psm1 is modified

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>

Copilot AI commented Oct 29, 2025

Copy link
Copy Markdown
Contributor Author

In github workflows, find where we do Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose and create a function in tools/ci.psm1 that does this, to avoid repeating c...

Done in 04b2833:

  1. Created Show-Environment function in tools/ci.psm1 that wraps environment logging with log group
  2. Replaced all 6 occurrences in workflows/actions with the new function
  3. Added buildModuleChanged to outputs in linux-ci.yml, windows-ci.yml, and macos-ci.yml
  4. Updated all build and test job conditions to check buildModuleChanged == 'true' so they trigger when build.psm1 is modified

@TravisEz13
Travis Plunk (TravisEz13) merged commit cdeda2a into master Oct 29, 2025
1 check passed
@TravisEz13
Travis Plunk (TravisEz13) deleted the copilot/format-logs-in-github-workflows branch October 29, 2025 22:53
@microsoft-github-policy-service

microsoft-github-policy-service Bot commented Oct 29, 2025 •

Copy link
Copy Markdown
Contributor

📣 Hey @@Copilot, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Travis Plunk (TravisEz13) added a commit to TravisEz13/PowerShell that referenced this pull request Nov 24, 2025
…owerShell#26326)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request Dec 12, 2025
…owerShell#26326)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Ryan Yates (kilasuit) pushed a commit to kilasuit/PowerShell that referenced this pull request Jan 2, 2026
…owerShell#26326)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Dongbo Wang (daxian-dbw) pushed a commit to daxian-dbw/PowerShell that referenced this pull request Feb 13, 2026
…owerShell#26326)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Justin Grote (JustinGrote) pushed a commit to JustinGrote/PowerShell that referenced this pull request Jun 2, 2026
…owerShell#26326)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…owerShell#26326)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.4.x-Done Backport-7.5.x-Done Backport-7.6.x-Done CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants