Add idempotency_level check plugin - #1
Merged
Conversation
Implement a Buf check plugin that requires read-only RPCs (Get*/List* by default) to explicitly declare an idempotency_level such as NO_SIDE_EFFECTS. The targeted method name prefixes are configurable via the method_prefixes plugin option. Includes table-driven tests, CI (gofmt/vet/test), and a tag-driven release pipeline: GoReleaser publishes prebuilt binaries to GitHub Releases and a Wasm build is pushed to the BSR.
Check plugins are consumed through the BSR (or built locally with go install), so prebuilt release binaries add little value. The release workflow now only pushes the Wasm build to the BSR on v* tags, and the README documents the BSR usage as the single install path.
Check plugins are consumed through the BSR, so prebuilt release binaries add little value. The release workflow now only pushes the Wasm build to the BSR on v* tags. Rewrite the README to cover only consumer-facing content: BSR usage, options, and motivation.
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
Adds a Buf check plugin that requires read-only RPCs (
Get*/List*by default) to explicitly declare anidempotency_levelsuch asNO_SIDE_EFFECTS, so that side-effect-free methods are marked as such (e.g. to enable HTTP GET support and caching in Connect).Changes
main.go: theMETHOD_IDEMPOTENCY_LEVELlint rule built on bufplugin-go. Prefix matching is case-insensitive and respects PascalCase word boundaries (GetmatchesGetUserbut notGettyImages). Targeted prefixes are configurable via themethod_prefixesoption (string list or comma-separated string; setting it replaces the defaults).main_test.go/testdata/: table-driven tests — checktest-based integration tests asserting exact annotation locations and messages, plus unit tests for option parsing and prefix matching..github/workflows/ci.yaml: gofmt / go vet / go test on pushes to main and on PRs..github/workflows/release.yaml: onv*tags, a Wasm build is pushed to the BSR viabuf plugin push, labeled with the tag.renovate.json: keeps SHA-pinned actions and Go modules up to date.README.md: consumer-facing content only — BSR usage, options, and motivation.Notes
buf.build/fchimpan/idempotency-level); no prebuilt binaries.// buf:lint:ignore METHOD_IDEMPOTENCY_LEVEL,lint.ignore_only,lint.ignore) apply to this rule as-is; verified against buf CLI v1.72.0.BUF_TOKENrepository secret (already configured).NO_SIDE_EFFECTSorIDEMPOTENT); only the unset default (IDEMPOTENCY_UNKNOWN) is flagged.Test coverage
go test ./...— integration tests compare rule ID, message, and exact source spans via checktest; unit tests cover option parsing edge cases (defaults, blank entries, comma-separated form, invalid types) and prefix word-boundary matching, including compound prefixes likeBatchGet.