Sync eng/common directory with azure-sdk-tools for PR 15278#48926
Sync eng/common directory with azure-sdk-tools for PR 15278#48926
Conversation
Adds an opt-in capability to the shared TypeSpec emitter pipeline template that bundles an emitter package and uploads it to the typespec playground blob storage. The uploaded <pkgName>/latest.json import map is consumed by in-browser playgrounds (e.g. https://azure.github.io/typespec-azure) via their additionalPlaygroundPackages mechanism. Self-contained tooling lives in eng/common/playground-bundle/ and mirrors @typespec/bundle-uploader from microsoft/typespec (which is private and cannot be installed from npm). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR syncs eng/common tooling to add a self-contained TypeSpec emitter bundling + upload utility and wires it into the shared archetype-typespec-emitter.yml pipeline template (opt-in) to publish bundles to the TypeSpec playground storage.
Changes:
- Added a Node-based bundle-and-upload script (
upload.mjs) plus a pinned-depspackage.json/lock for reproducible installs. - Added documentation describing how the bundler is invoked from pipelines.
- Extended
archetype-typespec-emitter.ymlwith anUploadPlaygroundBundleparameter and conditional upload steps for internal non-PR builds.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| eng/common/playground-bundle/upload.mjs | New CLI script to bundle a TypeSpec emitter package and upload bundle assets + manifest + latest.json to blob storage. |
| eng/common/playground-bundle/package.json | Introduces pinned Node dependencies and an engines constraint for the uploader tool. |
| eng/common/playground-bundle/package-lock.json | Locks the dependency graph for deterministic npm ci installs. |
| eng/common/playground-bundle/README.md | Documents purpose and pipeline invocation of the uploader tool. |
| eng/common/pipelines/templates/archetype-typespec-emitter.yml | Adds opt-in parameter and conditional steps to install and run the uploader in pipelines. |
Files not reviewed (1)
- eng/common/playground-bundle/package-lock.json: Language not supported
| const content = JSON.stringify(manifest); | ||
| await blob.upload(content, content.length, { | ||
| blobHTTPHeaders: { blobContentType: "application/json; charset=utf-8" }, | ||
| conditions: { ifNoneMatch: "*" }, | ||
| }); |
There was a problem hiding this comment.
BlobClient.upload(content, content.length, ...) uses JavaScript string length (UTF-16 code units) rather than the byte length the Storage SDK expects. This can lead to incorrect contentLength and upload failures if the JSON ever contains non-ASCII characters. Consider switching to uploadData(Buffer.from(content, 'utf8')) or using Buffer.byteLength(content) for the length argument.
| const content = JSON.stringify(index); | ||
| await blob.upload(content, content.length, { | ||
| blobHTTPHeaders: { blobContentType: "application/json; charset=utf-8" }, | ||
| }); |
There was a problem hiding this comment.
Same issue as above: blob.upload(content, content.length, ...) passes string length instead of byte length. Use uploadData(Buffer.from(content, 'utf8')) or Buffer.byteLength(content) to avoid mismatched content-length on upload.
| - script: npm ci | ||
| displayName: 'Install playground bundle uploader' | ||
| workingDirectory: $(Build.SourcesDirectory)/eng/common/playground-bundle | ||
| env: | ||
| NPM_CONFIG_USERCONFIG: $(emitterNpmrcPath) | ||
|
|
||
| - task: AzureCLI@2 | ||
| displayName: 'Upload playground bundle' | ||
| inputs: | ||
| azureSubscription: "TypeSpec Storage" | ||
| scriptType: "bash" | ||
| scriptLocation: "inlineScript" | ||
| workingDirectory: $(Build.SourcesDirectory) | ||
| inlineScript: > | ||
| node eng/common/playground-bundle/upload.mjs | ||
| --package-path ${{ parameters.EmitterPackagePath }} | ||
| --version $(initialize.emitterVersion) |
There was a problem hiding this comment.
The new steps run npm ci and node eng/common/playground-bundle/upload.mjs, but the Build job doesn’t install/pin a Node.js version. Since eng/common/playground-bundle/package.json requires Node >=20.19.0, this can break depending on the agent’s preinstalled Node. Consider adding a UseNode@1 step (e.g., 22.x) before these steps to make the job deterministic.
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#15278 See eng/common workflow