feat(cmd): differentiate exit codes for compliance vs runtime errors#97
Merged
Joseph94m merged 2 commits intogetplumber:mainfrom Mar 13, 2026
Merged
Conversation
Collaborator
|
Hello @sputnik-mac thanks for the contribution, I will review it this week. |
…loses getplumber#61) Introduce a dedicated ComplianceError type so that callers can distinguish between two different failure modes: Exit 0 – analysis passed (compliance >= threshold) Exit 1 – compliance failure (compliance < threshold) Exit 2 – runtime / configuration error Previously both compliance failures and internal errors returned exit code 1, making it impossible for CI systems to handle them differently. Changes: - cmd/errors.go: new ComplianceError struct - cmd/analyze.go: return *ComplianceError when compliance < threshold; update the 'Exit codes' section in the command help text - cmd/root.go: use errors.As to map ComplianceError → exit 1, all other errors → exit 2
18dca64 to
5135081
Compare
Joseph94m
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #61
Previously
plumber analyzeused exit code1for both compliance failures and runtime errors, making it impossible for CI/CD pipelines to distinguish between "not compliant yet" and "something is broken".This PR introduces a dedicated
ComplianceErrortype and maps failures to explicit exit codes:012Changes
cmd/errors.go(new file)ComplianceErrorstruct withComplianceandThresholdfieldserrorinterfacecmd/analyze.go*ComplianceError(instead offmt.Errorf) when compliance is below thresholdExit codes:section in the command long description to document all three codescmd/root.goerrors.Asto detect*ComplianceError→os.Exit(1)os.Exit(2)Why It Matters
CI systems like GitLab CI support
allow_failure: exit_codes: [1]to soft-fail on compliance while still treating internal errors as hard failures. This is a common pattern for linting/quality tools and improves Plumber's ergonomics in automated environments.Testing
go test ./...passesmake embed && go build ./...