Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

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
Copilot AI requested a review from TravisEz13 October 28, 2025 23:09
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>
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 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
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>
Copy link
Contributor Author

Copilot AI commented Oct 29, 2025

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 TravisEz13 marked this pull request as ready for review October 29, 2025 22:14
@TravisEz13 TravisEz13 requested review from a team and jshigetomi as code owners October 29, 2025 22:14
@TravisEz13 TravisEz13 merged commit cdeda2a into master Oct 29, 2025
38 checks passed
@TravisEz13 TravisEz13 deleted the copilot/format-logs-in-github-workflows branch October 29, 2025 22:53
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Oct 29, 2025

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

🔗 https://aka.ms/PSRepoFeedback

pwshBot pushed a commit to pwshBot/PowerShell that referenced this pull request Oct 31, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.4.x-Migrated BackPort-7.5.x-Consider Backport-7.6.x-Migrated 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.

4 participants