Repository navigation
Add emitter-diff wiring for typespec-go - #5011
Merged
Merged
Conversation
Wire typespec-go into the language-agnostic emitter-diff tool (from the core submodule) so PRs get an informational diff of the generated Go code between the emitter versions. - packages/typespec-go/package.json: add `diff-regen-code` script that calls core/eng/emitter-diff/src/cli.ts with the Go command/paths and baseline --setup (submodule init + install + build:deps). - .github/workflows/ci-emitter-diff-go.yml: informational PR check modeled on ci-emitter-diff-python.yml, adapted for Go (submodule checkout, azure-sdk npm registry, build:deps to match ci-go.yml). Fails only on tool/build error. - packages/typespec-go/docs/development.md: document the `diff-regen-code` workflow for reviewing generated-code changes locally. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 95d2ba8c-8071-4000-a201-7e1be3fd4336
Chenjie Shi (tadelesh)
requested review from
Brian Terlson (bterlson),
Mark Cowlishaw (markcowl) and
Timothee Guerin (timotheeguerin)
as code owners
July 22, 2026 05:08
Contributor
|
All changed packages have been documented.
Show changes
|
Contributor
Go emitter diffBaseline No changes to generated output. Rendered diff: inline on the run summary, or the emitter-diff-go-html artifact. Informational check (core/eng/emitter-diff); does not block the PR. |
commit: |
Contributor
|
You can try these changes here
|
Jiaqi Zhang (JiaqiZhang-Dev)
approved these changes
Jul 22, 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.
What
Wires typespec-go into the language-agnostic
emitter-difftool (added in microsoft/typespec#11122, already vendored in thecoresubmodule), so we can diff the generated Go code produced by two versions of the emitter — locally and as an informational PR check.Because the generated Go fixtures are not committed (
.gitignored), a plaingit diffcan't show how an emitter change affects the output. This tool regenerates a baseline tree and the head (working tree / PR), then renders the difference.Changes
packages/typespec-go/package.json— adds thediff-regen-codescript. Since the tool's presets live in thecoresubmodule, it passes flags directly:--command "npm run tspcompile",--emitter-path packages/typespec-go,--generated-code-path test/http-specs,test/azure-http-specs,test/local(all three rootstspcompilewrites), and--setupsteps (submodule init +pnpm install+build:deps) that prepare the fetched baseline tree..github/workflows/ci-emitter-diff-go.yml— informational PR check modeled onci-emitter-diff-python.yml, adapted for Go:submodules: recursivecheckout, azure-sdk npm registry,build:depsbuild (matchingci-go.yml), diff against the PR merge-base, sticky PR comment + HTML artifact. Fails only on a tool/build error, never on a diff. Skips fork PRs.packages/typespec-go/docs/development.md— documents thediff-regen-codeworkflow for reviewing generated-code changes.How the diff works
headdefaults to the current working tree (built by the workflow, since the tool runs the regenerate command as-is and never builds your checkout);baselineisgh:<merge-base>, fetched into a temp worktree and auto-prepared via the script's--setup. Each side runstspcompile, the three generated roots are snapshotted, andgit diff --no-indexrenders the report.Validation
Ran a filtered self-diff locally (
pnpm diff-regen-code -- --sequential --baseline local:. -- --filter=bytesgroup): the full pipeline regenerated both sides and reported No differences (exit 0), confirming the wiring.Note: CI runners have network access for the two installs; the workflow points npm/pnpm at the azure-sdk public feed via
$HOME/.npmrcso the out-of-repo baseline install inherits it too.