Skip to content

[typespec-go] Refine SDK regenerate pipeline - #2021

Closed
Jiaqi Zhang (JiaqiZhang-Dev) wants to merge 13 commits into
mainfrom
refine-regen-pipeline
Closed

[typespec-go] Refine SDK regenerate pipeline#2021
Jiaqi Zhang (JiaqiZhang-Dev) wants to merge 13 commits into
mainfrom
refine-regen-pipeline

Conversation

@JiaqiZhang-Dev

@JiaqiZhang-Dev Jiaqi Zhang (JiaqiZhang-Dev) commented Jun 29, 2026

Copy link
Copy Markdown
Member

Refinements to the SDK regenerate pipeline:

  1. Do not commit regenerate-sdk-result.json to the PR, just print it to logs and publish it as a pipeline artifact.
  2. Create spec PR: Added a new CreateSpecPR parameter. When enabled, the pipeline will open a PR to azure-rest-api-specs to bump the go module suffix in tspconfig.yaml for packages whose module version changed.
  3. Support the metadata.json latest format.

About the module suffix in tspconfig.yaml, there is an existing discussion about it: #1644

Test

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines the SDK regeneration automation to avoid committing regeneration result JSON, preserve Go module paths after regeneration, and optionally open a spec PR to update tspconfig.yaml module suffixes when regeneration bumps module versions.

Changes:

  • Stop committing regenerate-sdk-result.json; instead log it and publish it as a pipeline artifact.
  • Record each package’s original Go module path from go.mod and restore it across package files after regeneration to avoid unintended /vN bumps.
  • Add an optional (CreateSpecPR) workflow to update tspconfig.yaml module entries in azure-rest-api-specs and open an automated PR.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
eng/scripts/sdk_regenerate.py Adds module-path capture/restore, artifact output, and optional spec PR creation logic.
eng/pipelines/sdk-regenerate.yml Adds CreateSpecPR parameter, checks out azure-rest-api-specs, publishes the result JSON artifact, and wires new script flags.

Comment thread eng/scripts/sdk_regenerate.py Outdated
Comment thread eng/scripts/sdk_regenerate.py
Comment thread eng/scripts/sdk_regenerate.py Outdated
Comment thread eng/pipelines/sdk-regenerate.yml
Comment thread eng/pipelines/sdk-regenerate.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@JiaqiZhang-Dev Jiaqi Zhang (JiaqiZhang-Dev) changed the title Refine SDK regenerate pipeline [typespec-go] Refine SDK regenerate pipeline Jun 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread eng/scripts/sdk_regenerate.py
Comment thread eng/scripts/sdk_regenerate.py
Comment thread eng/scripts/sdk_regenerate.py
Comment thread eng/pipelines/sdk-regenerate.yml
Comment thread eng/scripts/sdk_regenerate.py
@tadelesh

Copy link
Copy Markdown
Member

We are working on the repo migration. Could you put the regen pipeline into this PR?

@tadelesh

Copy link
Copy Markdown
Member

Move to Azure/azure-sdk-for-go#27137

Chenjie Shi (tadelesh) pushed a commit to Azure/azure-sdk-for-go that referenced this pull request Jul 20, 2026
Port the metadata parsing refinement from Azure/autorest.go#2021 into the
migrated regeneration script. get_api_version_from_metadata now understands the
current `{"apiVersions": {namespace: version}}` map in addition to the legacy
`{"apiVersion": "..."}` string: it returns a single version when all namespaces
share one, otherwise a compact namespace->version JSON map passed to the emitter
so each service namespace regenerates at its recorded version.

(The result-report-as-artifact change from that PR is already handled here by the
--result-file mechanism; the CreateSpecPR / tspconfig module-suffix bump is
intentionally not ported.)
Chenjie Shi (tadelesh) added a commit to Azure/azure-sdk-for-go that referenced this pull request Jul 20, 2026
* ci: add typespec-go SDK regeneration ADO pipeline

Migrated from the Azure DevOps sdk-regenerate.yml pipeline in Azure/autorest.go
and relocated here, next to the SDK it regenerates. Regenerates the resource
manager SDKs from the @azure-tools/typespec-go emitter and opens a draft PR
via the repo's native create-pull-request template.

Supports both emitter modes from the original pipeline:
- released (default): pin eng/emitter-package.json to the latest published
  @azure-tools/typespec-go from npm.
- dev: build the emitter from an Azure/typespec-azure branch, pnpm pack it,
  and point eng/emitter-package.json at the tarball. Dependency versions are
  read from the packed tarball (where pnpm rewrites workspace: specifiers to
  concrete published ranges) rather than the source package.json.

Compile-time path variables select the correct source layout for released
(self only) vs dev (self + typespec-azure) runs. Branch/commit/push/PR are
handled by the create-pull-request template; sdk_regenerate.py only updates
the emitter package and regenerates the SDKs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: keep regeneration report out of the SDK PR

Write regenerate-sdk-result.json to a --result-file path outside the SDK
working tree (the pipeline points it at ArtifactStagingDirectory and
publishes it as a build artifact) so the create-pull-request template's
git add -A no longer sweeps it into the regeneration PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: support the current _metadata.json apiVersions map format

Port the metadata parsing refinement from Azure/autorest.go#2021 into the
migrated regeneration script. get_api_version_from_metadata now understands the
current `{"apiVersions": {namespace: version}}` map in addition to the legacy
`{"apiVersion": "..."}` string: it returns a single version when all namespaces
share one, otherwise a compact namespace->version JSON map passed to the emitter
so each service namespace regenerates at its recorded version.

(The result-report-as-artifact change from that PR is already handled here by the
--result-file mechanism; the CreateSpecPR / tspconfig module-suffix bump is
intentionally not ported.)

* Use authenticated internal npm feed in regen pipeline

Sync the approach from Azure/typespec-azure#4663: invoke the
create-authenticated-npmrc.yml eng/common step after installing Node so an
authenticated \C:\Users\chenjieshi/.npmrc points npm / pnpm / npx at the azure-sdk-for-js
internal registry. Every subsequent install (corepack, pnpm install,
tsp-client) then resolves packages from the authenticated internal feed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 293999d7-677c-45c7-8ba5-a576210b29cf

* Resolve gen-time deps outside the emitter's dependency closure

emitter-package.json lists gen-time libraries that some specs import directly
but that are not part of @azure-tools/typespec-go's own dependency closure --
notably @azure-tools/typespec-azure-portal-core and @azure-tools/typespec-liftr-base.
update_dev_dependencies only refreshed versions found in the emitter's deps, so
these were left pinned at a stale wave (e.g. portal-core stuck at 0.68.0 while
the rest of the wave moved to 0.70.0), breaking generation.

Now these leftover devDependencies are resolved explicitly: from the checked-out
typespec-azure workspace package version in dev mode, falling back to the latest
published version from the npm registry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 293999d7-677c-45c7-8ba5-a576210b29cf

* Address Copilot review: schedule always:true and skip unused commit lookup

- sdk-regenerate.yml: set always:true on the weekly schedule so it keeps running
  even when main has not changed (the pipeline reacts to external typespec-go
  emitter releases, which are not commits to this repo).
- sdk_regenerate.py: only fetch the latest azure-rest-api-specs commit when
  use_latest_spec is enabled, so released-emitter runs do not depend on an
  unrelated (and otherwise unused) GitHub request.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 293999d7-677c-45c7-8ba5-a576210b29cf

---------

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: tadelesh <chenjieshi@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants