Repository navigation
JSON output for goreleaser check in CI #7184
LionelTrichet
started this conversation in
Ideas, Issue Triage, and General discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I've been using
goreleaser checkin CI, and one thing that would make it much easier to integrate is a structured output mode.Right now the exit codes are already useful: CI can tell the difference between an invalid config and a config that only uses deprecated options. The awkward part is getting the actual findings. For that, consumers still have to parse the human-readable output.
I checked this against commit
27ef66dec8ba76280b449310b4fdaa64d09299c0.checkalready handles multiple config files, but there doesn't seem to be a JSON output option.Would something like this be useful?
goreleaser check --output jsonwith the current text output remaining the default.
I'm not attached to a specific schema. The useful part for CI would be getting one result per config file, with a stable status such as
valid,deprecated, orinvalid, plus the findings for that file.Something roughly like:
{ "schema_version": 1, "files": [ { "path": ".goreleaser.yml", "status": "valid", "findings": [] }, { "path": ".goreleaser.deprecated.yml", "status": "deprecated", "findings": [ { "kind": "deprecation", "message": "A deprecated configuration property is in use." } ] } ], "errors": [] }That's just an example of the shape, not a proposal for an exact schema.
The main thing I'd like to avoid is CI having to match log strings. A structured
statusandkindwould be enough to distinguish deprecations from real errors and group them by config path.I also don't think the JSON needs to invent information GoReleaser doesn't already have. No synthetic rule IDs or line numbers, and definitely no config contents or anything that might expose secrets.
One part I'm less sure about is how this should behave with multiple files when one of them can't be loaded or parsed.
Today that can stop the command early. For normal CLI output that's understandable, but for a JSON report it may be more useful to mark that file as invalid and keep checking the rest, so CI gets one complete report instead of a partial one.
For exit codes, I'd expect the existing behavior to stay intact:
1if anything is invalid;2if there are deprecations but no invalid configs;0if everything is valid.So mixed results would still effectively be
invalid > deprecated > valid.For JSON mode, it would also be nice if stdout stayed machine-readable: one complete JSON document, with human-oriented logs going to stderr. In that model,
--quietcould suppress the logs without suppressing the JSON itself.CLI parsing errors before
checkactually starts can keep the normal Cobra behavior.The cases that seem most important are mixed results across multiple files, malformed YAML, an unreadable file followed by a valid one, exit-code precedence,
--quiet, and making sure the existing text mode doesn't change.I'd also prefer the JSON to come from the underlying validation/deprecation data rather than from parsing or capturing already-formatted log output.
The goal is pretty simple: make
goreleaser checkeasier to plug into CI without depending on console formatting.I'm curious whether this fits the direction maintainers want for
check, especially around continuing after individual file failures in JSON mode.All reactions