Stop counting added generated-client methods as API breaks
This PR edits a CI workflow (.github/workflows/test.yml, the api-compat job, which backs the required API Compatibility check). It changes what that check counts as breaking and adds a self-test step to the same job.
Why
Two kinds of routine change fail the gate today, and the printed remedy is the breaking label, which then lands on PRs that broke nothing. That stops the label meaning "a real break was looked at and accepted". It's the same reason the release Version constant was already partitioned out.
- Added operations. Every new endpoint adds methods to
generated.ClientInterfaceandgenerated.ClientWithResponsesInterface: oapi-codegen emits one method per operation, two with a request body. apidiff counts a method added to an exported interface as incompatible.- The interfaces' implementations are
generated.Client/generated.ClientWithResponses, generated beside them.pkg/basecampholds the concrete*generated.ClientWithResponses, and nothing in the module accepts a caller's implementation. - The only route for an outside implementer is the exported
ClientInterfacefieldClientWithResponsesembeds, i.e. a hand-written fake. MIGRATING.md has said since #960 that the generated client is the only intended implementer.
- The interfaces' implementations are
- Provenance repins.
scripts/sync-api-version.shrewritesAPIVersionfrom openapi.json'sinfo.version, andsync-api-version-checkholds the two in step.DefaultUserAgentfollows from it by construction. apidiff counts any exported constant's value change as incompatible. For this constant, changing is its job.
Survey of all 121 breaking-labelled PRs (gate logs read from each PR's head; all 121 still available):
- 83: the gate found nothing in Go (the label was for other SDKs).
- 14: real Go breaks beyond these lines.
- 12: only added methods on the two interfaces. Nine of them broke nothing in any SDK per their MIGRATING notes: #839, #847, #960, #1016, #1019, #1037, #1053, #1062, #1067. The other three carried other-SDK or unkeyed-literal breaks the label was right for: #898, #1057, #1061.
- 7: an
APIVersionrepin. Under both partitions, none had any other Go incompatibility: #827, #883, #1015, #1059, #1068, #1075, #1125.
What changes
In the "Check for breaking API changes" step, these lines leave the verdict. They still print in their own sections and in "All API Changes".
- Generated client interfaces. Only lines matching
That is: only^- \./pkg/generated\.(ClientInterface|ClientWithResponsesInterface)\.[A-Z][A-Za-z0-9_]*: added$added, only an exported method, only those two interfaces, only in./pkg/generated. Removed or changed methods, an unexported method (added unexported method), a method added to any other interface (ingeneratedor elsewhere), and a same-named interface in another package all still fail. - Version constants.
VersionandAPIVersionare exempt only asvalue changed; removing, retyping or renaming either still fails.DefaultUserAgentis exempt only when its old value isbasecamp-sdk-go/<Version> (api:<APIVersion>)with the old values of whichever constant changed.- Its new value must be the same shape with their new values, and the other component unchanged.
- A user-agent change with neither constant changing never passes.
- Before this PR only
Versionwas handled. The section is renamed "Version constants changed".
The reasoning for both is in the workflow comments.
Proof
scripts/test-api-compat-gate (make test-api-compat-gate, run in the api-compat job after apidiff is installed) works like this:
- It pulls the step's own
run:text out of the workflow and runs it with the pinned apidiff against scratch modules shaped like./go. - Each case merges a change with
--no-ff, the wayrefs/pull/N/mergeis cut. PR_NUMBERis empty, so the label is never read.
20 cases:
- pass:
- methods added to both interfaces, with their generated implementations
- a release
Versionbump - an
APIVersionrepin - a release and a repin together
- fail:
- method removed from
ClientInterface - signature changed on
ClientWithResponsesInterface - method added to
generated.HttpRequestDoer - method added to an interface in
pkg/basecamp - method added to
generated.ClientInterfaceV2 - method added to a
ClientInterfacein another package - unexported method added to
ClientInterface - an added operation next to a real break (still fails, and the adds still print in their own section)
APIVersionretypedAPIVersionremoved- a user agent that doesn't follow a repin (wrong api value, rewritten prefix,
(api:...)dropped) - a user-agent change with no constant change
- a user agent whose old api or version component never matched the constant
- method removed from
Failing cases assert the line lands in the Breaking Changes section, not just somewhere in the output.
Mutation checks run locally:
| Mutation | Cases that fail |
|---|---|
| this PR's first head (no repin partition) | 4 |
| main's workflow | 6 |
dropping : added$ | 2 |
widening the package to pkg/[a-z]* | 1 |
matching any : added$ | 5 |
| exempting any user-agent change beside a constant change | 3 |
skipping the old-APIVersion check | 1 |
skipping the old-Version check | 1 |
Two mutations survive because a guard repeats another:
- Removing
[A-Z]. apidiff writes an unexported method asadded unexported method, which the anchor already rejects. - Dropping the "a constant changed" guard on the user-agent check. With neither constant changing, the expected value equals the old one, which a changed line can't match.
On #1125 at bf8621a004375245aa54c1301d7804b8adc82c63, merged onto main 465da12a, this branch's step passes with no label:
### Version constants changed
- ./pkg/basecamp.APIVersion: value changed from "2026-11-05" to "2026-11-29"
- ./pkg/basecamp.DefaultUserAgent: value changed from "basecamp-sdk-go/0.40.0 (api:2026-11-05)" to "basecamp-sdk-go/0.40.0 (api:2026-11-29)"
### Generated client interfaces gained methods
- ./pkg/generated.ClientInterface.DeleteMyAvatar: added
- ./pkg/generated.ClientInterface.UpdateMyAvatarWithBody: added
- ./pkg/generated.ClientWithResponsesInterface.DeleteMyAvatarWithResponse: added
- ./pkg/generated.ClientWithResponsesInterface.UpdateMyAvatarWithBodyWithResponse: added
No breaking changes detected.