Skip to content

Commit 48c329c

Browse files
msyycCopilotCopilot
authored
update emitter-package dependencies (#47613)
* Align emitter-package-update skill workflow with emitter_package_update.py Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix emitter-package-update skill: accurate regenerate workflow description Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify: open a PR for any emitter-package dependency change, not only typespec-python bumps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify scope: update all dependencies and devDependencies, add restricted-network fallbacks Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add restricted-network fallback notes for npm-check-updates and lock-file steps Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address skill dry-run friction: broaden scope wording, fix stale example, handle branch collision and conditional lock-file commit Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * update emitter-package dependencies Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix cspell warning in emitter-package-update skill Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 5509d6c commit 48c329c

3 files changed

Lines changed: 99 additions & 45 deletions

File tree

Lines changed: 83 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
---
22
name: emitter-package-update
3-
description: Automate bumping typespec-python version in emitter-package.json for the Azure SDK for Python repository. Use this skill when the user wants to update @azure-tools/typespec-python to the latest version, create a PR for the version bump, or manage emitter-package.json updates.
3+
description: Automate updating the emitter package dependencies in eng/emitter-package.json for the Azure SDK for Python repository, then open a PR. Use this skill when the user wants to update @azure-tools/typespec-python (or any other dependency in emitter-package.json) to the latest version, create a PR for an emitter-package version bump, or manage emitter-package.json updates.
44
---
55

66
# Emitter Package Update
77

8-
Bump `@azure-tools/typespec-python` to the latest version in `emitter-package.json` and create a PR.
8+
Update the dependencies in `eng/emitter-package.json` to their latest versions — including
9+
`@azure-tools/typespec-python` when a newer release exists — and, if anything changed, open a PR.
910

1011
## Background
1112

1213
The Python emitter ecosystem consists of two packages:
1314
- **Branded emitter** (`@azure-tools/typespec-python`): Lives in [Azure/typespec-azure](https://github.com/Azure/typespec-azure/tree/main/packages/typespec-python). This is the emitter used for Azure SDK generation.
1415
- **Unbranded emitter** (`@typespec/http-client-python`): Lives in [microsoft/typespec](https://github.com/microsoft/typespec/tree/main/packages/http-client-python). The branded emitter wraps this package.
1516

16-
When `eng/emitter-package.json` is updated on `main`, the [TypeSpec Python Regenerate Tests](../../workflows/typespec-python-regenerate.yml) workflow triggers automatically and pushes regenerated test code to the [`typespec-python-generated-tests`](https://github.com/Azure/azure-sdk-for-python/tree/typespec-python-generated-tests/eng/tools/azure-sdk-tools/emitter/generated) branch.
17+
When `eng/emitter-package.json` is updated on `main`, the [TypeSpec Python Regenerate Tests](../../workflows/typespec-python-regenerate.yml) workflow triggers automatically. It regenerates the test code, pushes it to a `regen/typespec-python-main` source branch, and (because GitHub Actions cannot open PRs in this repo) creates/updates a tracking issue with a pre-filled compare link that a maintainer clicks to open the PR against the [`typespec-python-generated-tests`](https://github.com/Azure/azure-sdk-for-python/tree/typespec-python-generated-tests/eng/tools/azure-sdk-tools/emitter/generated) target branch.
1718

1819
## Prerequisites
1920

@@ -39,75 +40,128 @@ If any tool is missing:
3940

4041
### 1. Prepare Repository
4142

42-
Reset and sync the SDK repo to a clean state:
43+
Reset and sync the SDK repo to a clean state.
44+
> **Warning:** this discards all uncommitted changes and switches to `main`. Only run it on
45+
> a clone/worktree dedicated to this task, never on a branch with work you want to keep.
4346
4447
```bash
4548
git reset HEAD && git checkout . && git clean -fd && git checkout origin/main && git pull origin main
4649
```
4750

48-
### 2. Determine Latest Version
51+
Record the current `@azure-tools/typespec-python` version from `eng/emitter-package.json`
52+
(checking both the `dependencies` and `devDependencies` sections) so you can tell later
53+
whether it was bumped.
4954

50-
Run npm-check-updates to find the latest `@azure-tools/typespec-python` version:
55+
### 2. Update Dependencies (still on `main`)
56+
57+
The goal is to update **every** package across **both** the `dependencies` and
58+
`devDependencies` sections of `eng/emitter-package.json` to its latest version — not just
59+
`@azure-tools/typespec-python`. Run `npm-check-updates`, which upgrades all entries in both
60+
sections by default:
5161

5262
```bash
53-
npx npm-check-updates --packageFile eng/emitter-package.json
63+
npx npm-check-updates --packageFile eng/emitter-package.json -u
5464
```
5565

56-
Extract the target version from the output (e.g., `0.61.3`).
66+
> **Restricted-network fallback (e.g. the coding-agent sandbox):** `npm-check-updates`
67+
> needs access to the npm registry, which may be firewalled. If it cannot reach the registry,
68+
> determine the latest `@azure-tools/typespec-python` version from GitHub instead — the
69+
> newest published tag in [Azure/typespec-azure](https://github.com/Azure/typespec-azure/tags)
70+
> (cross-checked against `packages/typespec-python/package.json` on `main`) — and edit
71+
> `eng/emitter-package.json` by hand to that version.
72+
73+
Align `@azure-tools/openai-typespec` and `@typespec/openapi3` with the versions pinned in [azure-rest-api-specs/package.json](https://github.com/Azure/azure-rest-api-specs/blob/main/package.json) to ensure consistency between the emitter and the spec repo. Read the spec repo's current values for those two packages and set them to match in `eng/emitter-package.json` (do not assume specific version numbers — use whatever the spec repo currently pins).
74+
75+
If a specific version was requested, pin `@azure-tools/typespec-python` to that exact
76+
version in `eng/emitter-package.json` (overriding what npm-check-updates picked).
5777

58-
### 3. Create Feature Branch
78+
### 3. Check for Changes
79+
80+
Determine whether anything actually changed:
5981

6082
```bash
61-
git checkout -b bump-typespec-python-{version}
83+
git diff --quiet -- eng/emitter-package.json
6284
```
6385

64-
Replace `{version}` with the actual version number (e.g., `bump-typespec-python-0.61.3`).
65-
66-
### 4. Update Dependencies
86+
**Decision rule:** A PR must be created whenever there is *any* change to `eng/emitter-package.json` — this includes the case where `@azure-tools/typespec-python` itself is unchanged but one or more other dependencies (e.g. `@typespec/*`, `@azure-tools/openai-typespec`) were updated or aligned. Do **not** require a `typespec-python` version bump as a precondition for opening a PR.
6787

68-
Apply the version update:
88+
- If there **is** a diff (exit code `1`), proceed to step 4 and open a PR.
89+
- Only if there is **no** diff at all (exit code `0`) — meaning every dependency is already up to date — discard the working-tree changes and stop, as there is nothing to commit:
6990

7091
```bash
71-
npx npm-check-updates --packageFile eng/emitter-package.json -u
92+
git checkout -- eng/emitter-package.json
7293
```
7394

74-
Align `@azure-tools/openai-typespec` and `@typespec/openapi3` with the versions pinned in [azure-rest-api-specs/package.json](https://github.com/Azure/azure-rest-api-specs/blob/main/package.json) to ensure consistency between the emitter and the spec repo. Check the spec repo's versions and update `eng/emitter-package.json` accordingly (e.g., set `"@azure-tools/openai-typespec": "1.8.0"` and `"@typespec/openapi3": "1.9.0"` to match).
95+
### 4. Create Feature Branch
96+
97+
Read the (possibly updated) `@azure-tools/typespec-python` version and compare it with the
98+
value recorded in step 1 to choose names:
7599

76-
### 5. Regenerate Config Files
100+
- **If typespec-python was bumped** to `{version}`:
101+
- branch: `bump-typespec-python-{version}`
102+
- commit / PR title: `bump typespec-python {version}`
103+
- PR body: `Bump @azure-tools/typespec-python to version {version}`
104+
- **Otherwise** (only other dependencies changed):
105+
- branch: `update-emitter-package-dependencies`
106+
- commit / PR title: `update emitter-package dependencies`
107+
- PR body: `Update emitter-package.json dependencies to their latest aligned versions.`
77108

78-
If you have a local clone of `typespec-azure`, regenerate the lock file using the branded emitter's `package.json` to ensure `devDependencies` are aligned:
109+
Create the branch, carrying over the working-tree changes:
79110

80111
```bash
81-
tsp-client generate-config-files \
82-
--package-json=<path-to-local-typespec-azure>/packages/typespec-python/package.json
112+
git checkout -b {branch_name}
83113
```
84114

85-
Otherwise, regenerate the lock file only:
115+
If a branch with that name already exists locally from a previous run, delete it first
116+
(`git branch -D {branch_name}`) — or, if it holds work you want to keep, choose a different
117+
name — before re-creating it.
118+
119+
### 5. Regenerate Lock File
86120

87121
```bash
88122
tsp-client generate-lock-file
89123
```
90124

125+
This regenerates `eng/emitter-package-lock.json`.
126+
127+
> **Restricted-network note:** `tsp-client generate-lock-file` also resolves packages
128+
> from the npm registry. If the registry is unreachable, the lock file cannot be
129+
> regenerated in the sandbox. In that case commit only the `eng/emitter-package.json`
130+
> change (skip the lock file in step 6), and call out in the PR body that
131+
> `eng/emitter-package-lock.json` still needs to be regenerated in an environment with
132+
> npm-registry access before merge.
133+
91134
### 6. Commit Changes
92135

136+
Stage both files when the lock file was regenerated:
137+
93138
```bash
94139
git add eng/emitter-package.json eng/emitter-package-lock.json
95-
git commit -m "bump typespec-python {version}"
140+
git commit -m "{commit_message}"
141+
```
142+
143+
If the lock file was **not** regenerated (restricted-network case in step 5), stage only the
144+
package file instead:
145+
146+
```bash
147+
git add eng/emitter-package.json
148+
git commit -m "{commit_message}"
96149
```
97150

98151
### 7. Create Pull Request
99152

100-
Push branch and create PR:
153+
Push the branch and create the PR:
101154

102155
```bash
103-
git push -u origin bump-typespec-python-{version}
104-
gh pr create --title "bump typespec-python {version}" --body "Bump @azure-tools/typespec-python to version {version}"
156+
git push -u origin {branch_name}
157+
gh pr create --title "{pr_title}" --body "{pr_body}"
105158
```
106159

107160
### 8. After Merge
108161

109162
Once the PR merges to `main`, the [TypeSpec Python Regenerate Tests](../../workflows/typespec-python-regenerate.yml) workflow triggers automatically because `eng/emitter-package.json` was modified. It will:
110-
1. Install the branded emitter at the version specified in `eng/emitter-package.json`
111-
2. Regenerate all test code
112-
3. Push the updated generated files to the [`typespec-python-generated-tests`](https://github.com/Azure/azure-sdk-for-python/tree/typespec-python-generated-tests/eng/tools/azure-sdk-tools/emitter/generated) branch
113-
4. If the workflow fails, a GitHub issue is created and assigned to @iscai-msft and @msyyc
163+
1. Build `http-client-python` from `microsoft/typespec@main` and regenerate all test code
164+
2. Commit the regenerated files to the `regen/typespec-python-main` source branch and force-push it
165+
3. Create or update a tracking issue containing a pre-filled "compare" link (GitHub Actions cannot open PRs in this repo) so a maintainer can open the PR against the [`typespec-python-generated-tests`](https://github.com/Azure/azure-sdk-for-python/tree/typespec-python-generated-tests/eng/tools/azure-sdk-tools/emitter/generated) target branch. Merging that PR does **not** auto-close the tracking issue — close it manually.
166+
- The tracking issue is assigned to whoever triggered a manual (`workflow_dispatch`) run, or to @iscai-msft and @msyyc for automatic `push`/`schedule` runs.
167+
4. If the workflow fails, a separate failure-notification issue is created (or commented on) and assigned to @iscai-msft and @msyyc

eng/emitter-package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/emitter-package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
"@typespec/streams": "~0.83.0",
1515
"@typespec/xml": "~0.83.0",
1616
"@typespec/openapi3": "1.13.0",
17-
"@typespec/http-client-python": "^0.32.0",
17+
"@typespec/http-client-python": "^0.33.0",
1818
"@azure-tools/openai-typespec": "1.20.1",
1919
"@azure-tools/typespec-autorest": "~0.69.1",
2020
"@azure-tools/typespec-azure-core": "~0.69.0",
2121
"@azure-tools/typespec-azure-resource-manager": "~0.69.1",
2222
"@azure-tools/typespec-azure-rulesets": "~0.69.1",
23-
"@azure-tools/typespec-client-generator-core": "~0.69.0",
23+
"@azure-tools/typespec-client-generator-core": "~0.69.1",
2424
"@azure-tools/typespec-liftr-base": "0.14.0"
2525
}
2626
}

0 commit comments

Comments
 (0)