Skip to content

Add emitter-diff wiring for typespec-go - #5011

Merged
Chenjie Shi (tadelesh) merged 1 commit into
mainfrom
tadelesh/typespec-go-emitter-diff
Jul 22, 2026
Merged

Chenjie Shi (tadelesh) merged 1 commit into
mainfrom
tadelesh/typespec-go-emitter-diff

Conversation

@tadelesh

Copy link
Copy Markdown
Member

What

Wires typespec-go into the language-agnostic emitter-diff tool (added in microsoft/typespec#11122, already vendored in the core submodule), 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 plain git diff can'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 the diff-regen-code script. Since the tool's presets live in the core submodule, 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 roots tspcompile writes), and --setup steps (submodule init + pnpm install + build:deps) that prepare the fetched baseline tree.
  • .github/workflows/ci-emitter-diff-go.yml — informational PR check modeled on ci-emitter-diff-python.yml, adapted for Go: submodules: recursive checkout, azure-sdk npm registry, build:deps build (matching ci-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 the diff-regen-code workflow for reviewing generated-code changes.

How the diff works

head defaults to the current working tree (built by the workflow, since the tool runs the regenerate command as-is and never builds your checkout); baseline is gh:<merge-base>, fetched into a temp worktree and auto-prepared via the script's --setup. Each side runs tspcompile, the three generated roots are snapshotted, and git diff --no-index renders 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/.npmrc so the out-of-repo baseline install inherits it too.

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
@azure-sdk-automation

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @azure-tools/typespec-go
Show changes

@azure-tools/typespec-go - internal ✏️

Add diff-regen-code script wiring typespec-go into the language-agnostic emitter-diff tool to diff all generated test output (test/http-specs, test/azure-http-specs, and test/local) between emitter versions.

@github-actions

Copy link
Copy Markdown
Contributor

Go emitter diff

Baseline gh:1081f0678431238b3451fdfd82dce3679e572f21 vs this PR.

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.

@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-go@5011

commit: 951a961

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

@tadelesh
Chenjie Shi (tadelesh) added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit 6541343 Jul 22, 2026
40 checks passed
@tadelesh
Chenjie Shi (tadelesh) deleted the tadelesh/typespec-go-emitter-diff branch July 22, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:go Issues for @azure-tools/typespec-go emitter eng

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants