GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing github.com — refactor: reorganize console output by olblak · Pull Request #10876 · updatecli/updatecli Conversation
Member
This pullrequest introduces the following changes
TestTo test this pull request, you can run the following commands: cd <to_package_directory> go test Additional InformationChecklist
TradeoffPotential improvement
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Important Review skippedToo many files! This PR contains 446 files, which is 296 over the limit of 150. To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configuration
⛔ Files ignored due to path filters: 1
📒 Files selected for processing: 446
You can disable this status message by setting the
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@copilot please fix the merge conflicts in this pull request. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Grow pkg/core/log into the logging entry point for Updatecli, still backed by logrus: - level functions mirroring the logrus API used across the code base - Capture(w) copies log lines to w until stopped; captures nest, so a pipeline-wide capture can wrap the per-resource ones - Progress() for transient output that should reach the terminal only - Title and Section keep the meaning of headers instead of building ASCII art at every call site The global logrus logger now writes through the same output, so dependencies logging with logrus still land in captures. Sources, conditions and targets use Capture instead of swapping the global logrus output and resetting it to a hardcoded os.Stdout.
Output written with fmt.Print or to os.Stdout bypasses the logger, so it never reaches the console output attached to reports. - path walking and parsing failures in autodiscovery are now warnings - action and merge errors are logged as errors - drop a stray empty line in the dockerimage source and a duplicate error message in the npm resource, the error is already returned - git push progress goes to log.Progress, terminal only forbidigo now rejects fmt.Print* and os.Stdout/os.Stderr outside cmd/, the log package and tests. The interactive udash token prompt keeps writing to the terminal on purpose.
Mechanical swap of every logrus call for the matching pkg/core/log function, the log package mirrors the logrus API so the console output is unchanged. Tests now assert on log.Capture output instead of swapping the logrus output or installing a logrus test hook. depguard rejects new logrus imports outside pkg/core/log.
Per-resource console output misses why a pipeline failed: resource errors, pipeline errors, git push and pull request output are all logged outside of any source, condition or target. Report gains a ConsoleOutput field holding the console output of the whole pipeline: - the pipeline run, including resource errors and the engine failure message - actions and their cleanup - git push and working branch cleanup, attributed to every pipeline with a target on that repository branch Push and cleanup errors are now logged where they happen so they end up in that output. Only the last 1MiB is kept, the end of a log being where a failure is explained. The per-branch push and cleanup logic moves into pushSCMBranch and pruneSCMBranch so the capture can wrap it.
The log package now logs through a log/slog handler writing the same plain text lines as before, so the console output is unchanged. Messages are only formatted when their level is enabled. logrus is still a dependency of helm, sops, testcontainers and others, so the global logrus logger stays routed through the same output, with the same format and level. It's the only place importing logrus.
Titles, section headers and log levels are now rendered with lipgloss on a color terminal: titles in a rounded box, sections with a colored category and a rule, levels as colored labels. The basic ANSI colors follow the terminal theme. Output to a non-terminal, or with NO_COLOR set, stays the exact same plain text as before, so CI logs don't change. Captures always get plain text. Previously a run on a color terminal stored ANSI codes in the console output of reports. Title and Section are passed to the slog handler as records with a kind, so the handler decides how to render them. lipgloss replaces the direct use of fatih/color.
Banners were built by hand at each call site with strings.Repeat and strings.ToTitle, in five slightly different styles. They now all go through the log package, from the most to the least prominent: - Title: major steps, such as "Pipeline" or "Auto Discovery" - PipelineTitle: the name of the pipeline about to run - Heading: stages such as "Actions", "Pushing Git changes", "Report", "Run Summary", "Version" and every autodiscovery crawler - Section: sources, conditions and targets - Subheading: the errors of a pipeline, the changelog in debug mode Changing the look of the console output now only touches pkg/core/log/format.go. The plain text output keeps the same banners, with the whitespace around headings normalized and the underline matching the heading length. The summary banner of the report template becomes a heading.
Every source, condition and target with transformers logged a header and one line per step at info level, on every run, even when the value didn't change. The header and the per-step lines move to debug. At info level, a single line shows the net transformation, and only when the value changed: it explains why a value differs from its source, so it stays visible in the terminal and in the console output sent to udash, where debug is rarely enabled.
A cache hit is an implementation detail: the source result is the same either way, so the message is only useful when debugging.
When no pipeline defines autodiscovery crawlers, the "Auto Discovery" title was followed by nothing, which looked like a step that ran and silently failed. It's now followed by "disabled".
Step titles such as "Pipeline" or "Auto Discovery" appear once per run but were the most prominent banners, while pipelines, the unit people scan for, were a small badge. - step titles become a dim full-width rule on a color terminal, and a single "== PIPELINE ==" line in plain text - the pipeline title opens with a colored bar, its short ID and the dry run mode folded into a second line; plain text keeps the box and the full ID - each pipeline closes with its result and duration, colored by result on a color terminal, "=> CHANGED (4.2s)" in plain text, so it's clear where a pipeline ends; it's part of the pipeline console output too
The pipeline title was still hard to spot: its bar was one character wide and its bold name weighed the same as the source and target headers repeated around it. On a color terminal, a pipeline now opens with a full-width band, the only line with a background, holding its position in the run, its name, its short ID and the dry run mode. It closes with a rule spanning the full width in the color of its result, so a failure leaves a red line across the screen. In plain text, the box gains the position, such as "[3/12]". The engine now opens a pipeline as well as closing it, since it knows its position.
Actions, Pushing Git changes, Report, Udash, Summary and Version are steps of a run like Prepare, Auto Discovery or Pipeline, but were shown as headings. They now use the same title. Run Summary stays a heading, as part of the Summary step. The summary template no longer adds blank lines around itself, the banners own the spacing.
The band shortened the pipeline ID to 8 characters, but --pipeline-ids only matches complete IDs and a custom pipelineid can be cut in the middle of a meaningful name. On a color terminal, the full ID wasn't printed anywhere anymore. The band becomes a block of colored rows: an empty row, the position, name and dry run mode, the full pipeline ID, and an empty row. Its height makes pipelines even easier to spot when scrolling. On a narrow terminal the "Pipeline ID:" label is dropped so the ID still fits; the band only grows past the terminal width when the ID alone doesn't fit. Plain text is unchanged, it already shows the full ID.
Rules under titles, headings and sections were sized by the byte length of the text in plain output and by rune count in styled output, so they misaligned for names with accents, emoji or wide characters. Both renderers now use the displayed width. Also document that captures are global: a resource capture receives the lines of the resources running at the same time. Signed-off-by: Olblak <[email protected]>
The HTTP cache keys GET responses by URL only and no write invalidates them, so an SCM client reading again after creating a pull request, branch, tag or release in the same run could get the state from before the write. Gitea, Bitbucket and Stash clients went through that cache. httpclient gains NewUncachedRetryClient and UncachedTransport, with the same retry, proxy and tracing as NewRetryClient but never the cache, and UserAgent to share the updatecli User-Agent. Gitea, Bitbucket, Stash and GitHub clients now use it. GitHub only sends GraphQL POST requests, so its behaviour doesn't change. The GitLab client used its own HTTP client so far. It now uses the uncached updatecli one, with its own retries disabled to avoid stacking both, and sends the updatecli User-Agent instead of go-gitlab. Signed-off-by: Olblak <[email protected]>
1921fd7 to
424ad45
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.