{{ message }}
Repository navigation
Commit 4e87a4a
authored
refactor: reorganize console output (#10876)
* refactor(log): add internal logging package with stackable capture
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.
* refactor(log): stop plugins writing to stdout directly
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.
* refactor(log): migrate from logrus to internal log package
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.
* feat(report): capture full console output per pipeline
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.
* refactor(log): use log/slog as logging backend
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.
* feat(log): style terminal output with lipgloss
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.
* refactor(log): route every console banner through the log package
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.
* refactor(transformer): log transformer steps at debug level
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.
* refactor(source): log source cache hits at debug level
A cache hit is an implementation detail: the source result is the same
either way, so the message is only useful when debugging.
* feat(autodiscovery): show when autodiscovery is disabled
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".
* feat(log): make pipelines the most prominent unit of the console output
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
* feat(log): open pipelines with a full-width band and a position counter
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.
* feat(log): show every step of a run with the same title
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.
* feat(log): show the full pipeline ID in a taller pipeline band
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.
* fix(log): size rules by display width
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 <me@olblak.com>
* fix(scm): use the updatecli HTTP client without the cache for SCM APIs
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 <me@olblak.com>
---------
Signed-off-by: Olblak <me@olblak.com>1 parent a5c7496 commit 4e87a4a
447 files changed
Lines changed: 3880 additions & 2636 deletions
File tree
- cmd
- pkg
- core
- cache
- compose
- config
- engine
- httpclient
- jsonschema
- log
- pipeline
- action
- autodiscovery
- condition
- scm
- source
- target
- registry
- reports
- result
- scaffold
- telemetry
- text
- transformer
- udash
- version
- plugins
- autodiscovery
- argocd
- bazel
- cargo
- dockercompose
- dockerfile
- fleet
- flux
- githubaction
- golang
- helmfile
- helm
- ko
- kubernetes
- maven
- nomad
- npm
- plugin
- precommit
- pyproject
- terraform
- terragrunt
- updatecli
- woodpecker
- changelog
- github/v3
- markdown
- resources
- awsami
- azuredevops
- client
- credential
- pullrequest
- bazelmod
- bazelregistry
- bitbucket
- client
- pullrequest
- cargopackage
- csv
- dockerdigest
- dockerfile
- mobyparser
- simpletextparser
- dockerimage
- file
- gitbranch
- gitcommit
- gitea
- branch
- client
- pullrequest
- release
- tag
- githubrelease
- gitlab
- branch
- client
- mergerequest
- release
- tag
- gittag
- go
- gomod
- language
- module
- hcl
- helm
- jenkins
- json
- maven
- npm
- pypi
- shell
- success
- checksum
- console
- exitcode
- stash
- branch
- client
- pullrequest
- release
- tag
- systemd
- temurin
- terraform
- lock
- provider
- registry
- toml
- toolversions
- updateclihttp
- vulnerability/osv
- xml
- yaml
- scms
- azuredevopssearch
- azuredevops
- bitbucket
- gitea
- githubsearch
- github
- client
- token
- gitlabsearch
- gitlab
- git
- commit
- stash
- utils
- age
- cargo
- dasel
- gitgeneric
- pathresolver
- toolversions
- version
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||

0 commit comments