rushstack
rushstack copied to clipboard
[rush] Support CI build log folding using env vars
Summary
Allow monorepo maintainers to fold long build logs in CI using simple header and footer environment variables.
Fixes #2198.
Details
Since this behavior typically doesn't make sense on local machines, going with environment variables makes the most sense.
Although this behavior is called "grouping" by both GitHub and Azure, I think this word is rather ambiguous; log folding is much more specific and better describes the actual functionality you get. I've proposed RUSH_BUILD_FOLDING_HEADER and RUSH_BUILD_FOLDING_FOOTER but am open to alternatives!
Open to ideas on the interpolation -- I used nodejs-style because that seems most obvious, but since this matches Bash and Powershell variable expansion it is potentially needlessly difficult to specify in some situations. An alternate approach used in the build-cache.json property cacheEntryNamePattern is simple square brackets, e.g., [taskName] -- I could switch to that if it makes sense as our "official" env var interpolation format.
How it was tested
- Tested locally to verify output with env vars on and off, verbose on and off.
Incoming changes based on PR feedback:
- I've changed the
${taskName}interpolation to be[taskName], to match our existing interpolated values - Refactored interpolation to happen in a dedicated method
- There is now a single env var that controls log folding style (which defaults to off)
- Your supported log folding styles are configured in
logging.json
Should be ready for another round.
🚀 A prerelease of this branch is published as version 5.86.0-pr3813.0 of the following packages:
@microsoft/rush@microsoft/rush-lib@rushstack/rush-sdk@rushstack/rush-amazon-s3-build-cache-plugin@rushstack/rush-azure-storage-build-cache-plugin
Thanks for that @octogonz!
So I wanted to test out exactly how it looks and feels to collapse all the insides of each operation, and I am worried that perhaps this change is not worth it.
Check out this log output for an operation that is failing:

I can see that this operation is failing in the bottom of the build log, with its summary output; but if I scroll up to find it and view the full log, I basically have to search by operation name, because nothing about the output indicates a problem.
🤔 I'm not sure what improvement would be required. Perhaps if the log is folded, and the task ended in warning or error, an additional line below the fold could print the result of the operation so it's visible when quickly scanning the log output?