Skip to content

Commit 065089e

Browse files
committed
chore(proto): gate AIP lint in CI and fix buf.yaml accuracy
Add the AIP design linter (api-linter) to the CI proto job with --set-exit-status so design-level regressions buf's STANDARD ruleset doesn't cover actually gate merges; mirror the flag in the proto:api-lint mise task. Pin buf (1.70.0) and api-linter (2.3.1) in dev and CI so local and CI results agree. Fix the stale buf.yaml lint comment (Delete returns the resource tombstone per AIP-164, not google.protobuf.Empty) and drop the now-dead empty.proto breaking-ignore entry. Correct the promotion-path comment to reference the real buf category WIRE_JSON (WIRE_JSON_COMPATIBLE is not a valid category); the WIRE + ignore_unstable_packages alpha strategy is left unchanged.
1 parent ba45f1a commit 065089e

3 files changed

Lines changed: 46 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ jobs:
9999
mapfile -t SH_FILES < <(find . -name '*.sh' -not -path './.git/*' -not -path './.mise/*' -not -path '*/node_modules/*' | sort)
100100
[[ ${#SH_FILES[@]} -gt 0 ]] && shfmt -d -i 0 -ci "${SH_FILES[@]}"
101101
102-
# Lint proto files and check for breaking changes against main.
103-
# buf breaking runs on PRs only (bufbuild/buf-action skips it on push to main
104-
# where the change is already merged). FILE stability level (configured in
105-
# proto/buf.yaml) is appropriate for v1alpha; switch to WIRE_JSON_COMPATIBLE
106-
# when the API graduates to v1.
102+
# Lint proto files, check for breaking changes against main, and run the
103+
# AIP design linter. buf breaking runs on PRs only (bufbuild/buf-action skips
104+
# it on push to main where the change is already merged). buf.yaml uses WIRE
105+
# breaking detection with ignore_unstable_packages while the API is alpha;
106+
# it switches to WIRE_JSON when the first stable (v1) package lands.
107107
proto:
108108
needs: changes
109109
runs-on: ubuntu-latest
@@ -118,11 +118,38 @@ jobs:
118118

119119
- uses: bufbuild/buf-action@v1
120120
with:
121+
version: 1.70.0
121122
input: proto
122123
push: false
123124
pr_comment: false
124125
breaking_against: "https://github.com/${{ github.repository }}.git#branch=main,subdir=proto"
125126

127+
# AIP design lint (googleapis/api-linter) — the design-level rules buf's
128+
# STANDARD ruleset doesn't cover. Mirrors the proto:api-lint mise task.
129+
- name: Set up Go
130+
uses: actions/setup-go@v5
131+
with:
132+
go-version: stable
133+
134+
- name: Install api-linter
135+
run: go install github.com/googleapis/api-linter/v2/cmd/api-linter@v2.3.1
136+
137+
- name: AIP design lint
138+
working-directory: proto
139+
run: |
140+
buf build -o /tmp/cambeerfestival.pb
141+
api-linter \
142+
--config .api-linter.yaml \
143+
--descriptor-set-in=/tmp/cambeerfestival.pb \
144+
--set-exit-status \
145+
cambeerfestival/festival/v1alpha/festival.proto \
146+
cambeerfestival/festival/v1alpha/producer.proto \
147+
cambeerfestival/festival/v1alpha/drink.proto \
148+
cambeerfestival/festival/v1alpha/catalog_service.proto \
149+
cambeerfestival/festival/v1alpha/drink_entry.proto \
150+
cambeerfestival/festival/v1alpha/drink_summary.proto \
151+
cambeerfestival/festival/v1alpha/my_festival_service.proto
152+
126153
# Analyze code in parallel with tests so builds can start sooner
127154
analyze:
128155
needs: changes

mise.dev.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
[tools]
1818
watchexec = "2.5.1"
19-
buf = "latest"
19+
buf = "1.70.0"
2020

2121
# --- Protobuf / OpenAPI (API contract is proto-first; see proto/README.md) ---
22-
# buf and api-linter live here (dev-only) while the API design is still in flux.
23-
# Move both to base mise.toml when the API stabilises and proto tasks enter CI.
24-
# Move it to base mise.toml once the resource shapes and method signatures
25-
# have stabilised and the linter output is expected to stay clean in CI.
26-
"github:googleapis/api-linter" = "latest"
22+
# buf and api-linter live here for local dev. CI runs the equivalent checks in
23+
# the `proto` job (buf-action + api-linter via go install), so these versions
24+
# are pinned to match CI. Move both to base mise.toml if the toolchain is ever
25+
# needed by base (non-dev) tasks.
26+
"github:googleapis/api-linter" = "2.3.1"
2727

2828
[tasks."proto:lint"]
2929
description = "Lint the protobuf API contract (buf STANDARD ruleset)"
@@ -86,6 +86,7 @@ buf build -o /tmp/cambeerfestival.pb
8686
api-linter \
8787
--config .api-linter.yaml \
8888
--descriptor-set-in=/tmp/cambeerfestival.pb \
89+
--set-exit-status \
8990
cambeerfestival/festival/v1alpha/festival.proto \
9091
cambeerfestival/festival/v1alpha/producer.proto \
9192
cambeerfestival/festival/v1alpha/drink.proto \

proto/buf.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ lint:
77
use:
88
- STANDARD
99
except:
10-
# AIP-131/134: Get and Update return the resource itself, and Delete
11-
# returns google.protobuf.Empty — both intentionally diverge from buf's
12-
# "<Method>Response" / unique-response defaults. Google's own APIs do the same.
10+
# AIP-131/134/164: Get, Update, and Delete all return the resource itself
11+
# (Delete is a soft delete that returns the tombstone), so one response
12+
# message is shared across methods and none match buf's "<Method>Response"
13+
# naming default. Google's own APIs do the same.
1314
- RPC_RESPONSE_STANDARD_NAME
1415
- RPC_REQUEST_RESPONSE_UNIQUE
1516
breaking:
@@ -40,9 +41,7 @@ breaking:
4041
# ignore_unstable_packages is true: alpha/beta packages are free to churn
4142
# (rename, move, restructure) without tripping breaking checks while the API
4243
# is still being shaped — only stable (v1+) packages are guarded. When the
43-
# first stable (v1) package lands, switch breaking.use to WIRE_JSON_COMPATIBLE
44-
# (superset of WIRE; also checks JSON field-name stability); the frozen v1 is
45-
# then guarded while alpha stays exempt.
44+
# first stable (v1) package lands, switch breaking.use to WIRE_JSON (superset
45+
# of WIRE; also checks JSON field-name stability); the frozen v1 is then
46+
# guarded while alpha stays exempt.
4647
ignore_unstable_packages: true
47-
ignore:
48-
- google/protobuf/empty.proto

0 commit comments

Comments
 (0)