Skip to content

Commit dcb370a

Browse files
committed
add readme
1 parent 318af54 commit dcb370a

1 file changed

Lines changed: 46 additions & 2 deletions

File tree

eng/tools/emitter/README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,51 @@ This directory holds files related to the TypeSpec Python emitter (`@azure-tools
44

55
## Contents
66

7-
- **`gen/`** — Auto-generated Python SDK test code produced by the emitter.
8-
These files are regenerated automatically by the [typespec-python-regenerate](https://github.com/Azure/azure-sdk-for-python/blob/main/.github/workflows/typespec-python-regenerate.yml) workflow whenever the emitter version in `eng/emitter-package.json` is updated.
7+
- **`gen/`** — Auto-generated Python SDK test code (`gen/azure/` and `gen/unbranded/`) produced by the emitter.
8+
These files are regenerated by the [typespec-python-regenerate](../../../.github/workflows/typespec-python-regenerate.yml) workflow.
99

1010
> **Do not edit files in `gen/` by hand.** They will be overwritten on the next regeneration.
11+
12+
## Regeneration workflow
13+
14+
The [`typespec-python-regenerate`](../../../.github/workflows/typespec-python-regenerate.yml) GitHub Actions workflow regenerates the contents of `gen/`.
15+
16+
### Triggers
17+
18+
- **Automatic (push)** — runs when [`eng/emitter-package.json`](../../emitter-package.json) is updated on `main`. The workflow checks out `microsoft/typespec@main` and regenerates from there.
19+
- **Manual (`workflow_dispatch`)** — runs from the Actions tab with one input:
20+
- **`typespec_ref`** — either:
21+
- `main` (default) — regenerate from `microsoft/typespec@main`, or
22+
- a `microsoft/typespec` pull request URL (e.g. `https://github.com/microsoft/typespec/pull/1234`) — the workflow resolves the PR's head repo and SHA via `gh pr view` and checks out that exact commit (so unmerged PRs and fork branches work).
23+
24+
Any other value is rejected.
25+
26+
### What the workflow does
27+
28+
> **Note:** When triggering from a `microsoft/typespec` pull request URL, make sure the PR is up to date with its `main` branch first — click **Update branch** on the PR before running this workflow. Otherwise the regenerated output will be based on a stale base and may produce a confusing diff that mixes PR changes with unrelated drift from `main`.
29+
30+
1. Checks out `azure-sdk-for-python` and the resolved `microsoft/typespec` source into `_typespec/`.
31+
2. Builds `_typespec/packages/http-client-python` and runs `npm run regenerate`.
32+
3. Copies the regenerated output into `eng/tools/emitter/gen/azure` and `eng/tools/emitter/gen/unbranded`.
33+
4. If anything changed, force-pushes the result to a branch:
34+
- `auto/typespec-python-regenerate` when the source is `main`
35+
- `auto/typespec-python-regenerate-<PR_NUMBER>` when the source is a PR URL
36+
5. Creates or updates a tracking issue (GitHub Actions cannot open PRs directly in this repo):
37+
- **Title** uses a stable source label so retriggering from the same source reuses the existing open issue instead of creating a duplicate:
38+
- `[typespec-python] Regenerate tests from microsoft/typespec@main`
39+
- `[typespec-python] Regenerate tests from microsoft/typespec PR #<N>`
40+
- **Body** behavior:
41+
- If no open PR exists from the branch to `main`, the body contains a prefilled compare URL ("Create pull request from `<branch>`") that opens a PR with the title and body already populated.
42+
- If an open PR already exists from the branch to `main`, the body links directly to that PR and notes that the existing PR has been updated with the new commit (a force-push does not close the PR).
43+
- **Assignees / cc**:
44+
- Manual (`workflow_dispatch`) runs are assigned to the user who triggered the run (`github.actor`).
45+
- Automatic (`push`) runs are assigned to the default maintainers (`@iscai-msft`, `@msyyc`).
46+
47+
48+
### Failure notifications
49+
50+
If the `regenerate` job fails, a separate `notify-on-failure` job opens a new issue titled `[typespec-python] Regeneration workflow failed`, labeled `typespec-python`, and always assigned to `@iscai-msft` and `@msyyc` regardless of trigger.
51+
52+
### Concurrency
53+
54+
The workflow uses `concurrency: { group: <workflow>, cancel-in-progress: true }`, so a newer run cancels any in-flight run.

0 commit comments

Comments
 (0)