Repository navigation
Check the public API on every pull request with assembly-differ - #232
Merged
Merged
Conversation
Bump assembly-differ to 1.2.1. The old target ran the diff command and only wrote a markdown file, so it never failed. api writes the public API to api/, verifyapi fails when api/ differs from the Release build. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
assembly-differ reports what a pull request changes against the latest release, labels it for release-drafter and fails on a breaking change until the breaking-allowed label is added. verify-api fails when the committed api/ files differ from the build. The ci.yml step that only wrote a file nobody read is gone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
API changes: suggested version change None✅ All good: the public API is unchanged.
Public API files✅ The committed API files match the build (6 files). |
Public API files match the build |
Both leave GeneratedCode out of the public API files. The attribute held the SDK's System.Text.Json source generator version, so the committed files failed on CI's runner, whose SDK has another patch release. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
dotnet tool restore on the Linux runner reported that release-notes and nupkg-validator, the two tools listed after assembly-differ 1.3.0, are not contained in their packages and that the packages only hold assembly-differ. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
flobernd
approved these changes
Nov 25, 2026
MinVer builds version 0.x without tags, so the libraries differed from the 1.1.0 release in the version of the assemblies they reference and the comment reported a Patch change on unchanged code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The build job already builds Release and has the tags, so the checks run there instead of in a second workflow that built again: assembly-differ reports the change and sets the labels on a pull request, and verifyapi fails when api/ differs from the build. The workflow also runs on labeled and unlabeled, where only the API checks run, so adding breaking-allowed does not run the tests again. The api targets restore the tool manifest themselves. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The workflow-level token had contents, issues, packages and now pull-requests write on every pull request, including for the AOT jobs that publish and run pull request code. The workflow default is now none, the AOT jobs read contents, and the build job keeps what it had plus pull-requests write for the API comment. The assembly-differ action is pinned to the commit of its 1.3.0 release. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
assembly-differ 1.4.0 verifies the committed api/ files in the same action and the same comment, so the two steps become one on a pull request. A push and a tag still run verifyapi. Neither checkout keeps the token in git config, since nothing after it needs git credentials. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…en (#233) Pull request jobs no longer hold a write token or the publishing secrets: the publish steps of `ci.yml` move into a job of their own that runs for a push to main and for a tag only. **Prompt summary:** After reviewing the permissions of the pull request checks in #232, the owner asked for the remaining finding to be fixed: the `build` job ran pull request code, and a third-party action, with `contents`, `issues` and `packages` write, only because the publish steps shared it. The change is its own pull request, apart from the API onboarding. ## Why The `build` job builds and tests the pull request, runs MSBuild tasks and source generators from its dependencies, and runs the assembly-differ action. It also pushed the canary and release packages, so it held `contents`, `issues` and `packages` write for every run, including pull requests from branches of this repository. A compromised dependency or action in that job could write to the repository's releases and packages. ## What #### A publish job `publish` has `needs: build` and `if: github.event_name == 'push'`. It holds `contents`, `issues` and `packages` write, and is the only job that names `FEEDZ_IO_API_KEY`, `NUGET_ORG_API_KEY` or the token for the release. It checks out the same commit, fetches the tags, restores the tools, and runs the same push steps with the same conditions as before: canary packages to GitHub Packages and feedz.io for a push to a branch; release notes, the GitHub release and nuget.org for a tag. #### What it publishes The `build` job already built, tested and validated the packages. On a push it uploads `build/output/*.nupkg` as an artifact that expires after a day, and `publish` downloads it into `build/output`. The packages that are pushed are the ones that were tested, not a rebuild. #### Build job permissions `build` now has `contents: read` and `pull-requests: write`, the comment and labels of the API step. `zizmor` finds nothing about permissions or secrets in `ci.yml`; the remaining findings are the `actions/*` tags that policy allows and three trusted-publishing notes. **Risk:** the publish steps only run for a push to main and for a tag, so a pull request cannot run them. I ran the hand-off on this pull request with a temporary commit, since reverted: both `.nupkg` files reached `build/output` in the `publish` job, which restored the tools and generated release notes. The pushes themselves first run when this merges, as canary packages from main, and the release steps with the next tag. A failed canary run only needs a rerun. **Stack:** 2 of 2, on top of [#232](#232); retarget it to `main` once that merges. ## Verify ```bash git diff feature/assembly-differ -- .github/workflows/ci.yml ``` In the run of this pull request, the `build` job's "GITHUB_TOKEN Permissions" show `Contents: read` and `PullRequests: write`, and the `publish` job does not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Mpdreamz
added a commit
that referenced
this pull request
Nov 25, 2026
… makes (#234) The API check now fails a pull request only for a breaking change the pull request itself makes, not for one that `main`, or a pull request below it in a stack, already has. **Prompt summary:** The API comments on the stacked 2.0 pull requests listed breaking changes that the pull requests did not touch, and would turn every pull request red whenever `main` has an unreleased breaking change. The owner asked for the check to follow only what a pull request itself changes, and for the pull requests that introduced the changes to be listed. ## Why Since #232 the action compared each build with the latest release on nuget.org. A pull request in the middle of a stack therefore showed everything below it: #227 changes nothing in the public API and still listed 32 breaking changes and failed the check. ## What #### assembly-differ 1.5.0 The pinned action, the `version:` input and the tool in `dotnet-tools.json` go from 1.4.0 to 1.5.1 ([nullean/assembly-differ#119](nullean/assembly-differ#119), and the fix of 1.5.0 in [#120](nullean/assembly-differ#120)). 1.5.0 fetched the base branch into the workflow's own checkout with `--depth=1`, which cut the history that MinVer reads in `validatepackages`; 1.5.1 fetches into a repository of its own. With `api-files: api`, the action now compares a pull request's committed `api/` with its base branch's, target framework by target framework, and the check, the release label and `--fail-on` follow that. The comparison with the latest release stays in the comment, collapsed and marked as information, with a table of the pull requests below this one that introduced the changes. A change that is the same in every framework is listed once. No workflow change is needed: the new step reads the base branch and the open pull requests of a stack with the token the job already has. **Out of scope:** the 2.0 stack picks this up once it is rebased onto `main`: a pull request runs the workflow of its base branch, so until then the stack pull requests run the old one. ## Verify ```bash dotnet tool restore ./build.sh verifyapi ``` On this pull request the comment compares with `main` and lists both libraries as having no changes. I ran the steps of the new action on the real stack beforehand: #227 gets `None` and passes, and #220, which does break the API, gets the `breaking` label and fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Every pull request now reports what it changes in the public API of
Elastic.TransportandElastic.Transport.VirtualizedCluster, labels it for release-drafter, and fails on a breaking change until someone addsbreaking-allowed. The approved API is committed inapi/and checked in CI and in a test.Prompt summary: Onboard this repository to nullean/assembly-differ and its new GitHub Action for pull requests, including the verification tests that use Nullean.Snapshots for public API validation, in the existing
ci.ymlinstead of a second workflow, with the permissions of the pull request checks reviewed.Why
The
generateapichangestarget ran the olddiffcommand in CI and only wrote a markdown file, so it never failed and nobody saw the result. A breaking change to the public API reached review with nothing to flag it, and the release label depended on a person noticing.What
Checks in ci.yml
The
buildjob already builds Release and fetches the tags, so one step afterBuildruns the API checks on a pull request:nullean/assembly-differwithapi-files: api. It compares each packable library with its latest release on nuget.org, checks that the committedapi/*.apifiles match the build, and keeps one comment up to date: every library it compared, with a tick when it has no changes, the files check, and the release label (breakingfor a major change,featurefor a minor one). A major change or out-of-date files fail the check; a major change passes once someone addsbreaking-allowed. A push and a tag have no pull request to comment on, so they run./build.sh verifyapiinstead and cannot release out-of-date files. The workflow also runs onlabeledandunlabeled; on those events only the build and the API step run, so addingbreaking-alloweddoes not run the tests again. The action is pinned to the commit of its 1.4.0 release, and the tool to 1.4.0, which ignores unlisted versions (Elastic.Transport8.0.1 is unlisted) and the SDK-specificGeneratedCodeversion in.apifiles.Permissions
The workflow default is now
permissions: {}. The AOT jobs, which publish and run pull request code, getcontents: read; they had a write token before. Thebuildjob keepscontents,issuesandpackageswrite and gainspull-requests: writefor the comment and labels. On a pull request from a fork GitHub gives a read-only token, the action warns and still applies the failure. The action reads the built assemblies as metadata and only its last step has the token. Neither checkout keeps the token in git config (persist-credentials: false); nothing after it needs git credentials, and the tag fetch runs without them.zizmorreports 18 findings on this file against 24 onmain: theexcessive-permissionsandartipackedfindings are gone, and what remains is theactions/*tags that policy allows and three trusted-publishing notes.Committed API
api/*.apiholds the public API, one file per target framework where they differ (six files)../build.sh apiregenerates them and./build.sh verifyapichecks them; both restore the tool manifest themselves. These replacegenerateapichanges,Paths.GenerateApiChangesand the oldci.ymlstep.assembly-differis last indotnet-tools.json: with it earlier,dotnet tool restoreon the Linux runner reported that the two tools listed after it were not contained in their packages.Public API test
Elastic.Transport.PublicApi.Tests(net10.0, xunit) callsMatchApiSnapshot()on both assemblies, with Nullean.Snapshots.PublicApi 0.18.1. A change fails the test with each difference by path, who it breaks and the version bump it calls for. It is a separate project because Nullean.Snapshots builds on AwesomeAssertions and the other tests use FluentAssertions. Its snapshots repeat the net10.0api/files on purpose: the test gives fast feedback in./build.sh test,api/covers every framework.Docs
contributing.mdexplains how to change the public API and what the comment and labels mean.Out of scope: the open 2.0 stack (#219 to #229): once this merges, each of those PRs shows as major and needs
breaking-allowedand regeneratedapi/files. Moving the publish steps into a job of their own, so the pull request jobs drop thecontents,issuesandpackageswrite permissions, is the next pull request. The stale "Public API files match the build" comment on this pull request is from the first version of the workflow and nothing updates it any more.Verify
Make a public member internal (for example
Node.IsResurrected): the test,verifyapianddotnet assembly-differ projects --fail-on major(exit 4) all report a major change. Add a public type instead and all three report minor. On unchanged main the tool compares with 1.1.0 and reportsNone. The comment, the labels and thebreaking-allowedflow can only be seen on a pull request run; the first two are on this one.