[typespec-python] Add generated test regeneration workflow#46414
[typespec-python] Add generated test regeneration workflow#46414iscai-msft wants to merge 17 commits intoAzure:mainfrom
Conversation
Add typespec-python-regen.yml workflow that regenerates Python SDK test code from microsoft/typespec's http-client-python emitter. Outputs both azure and unbranded flavors to eng/tools/typespec-python-generated-tests/. Triggers: - repository_dispatch (from microsoft/typespec on merge) - workflow_dispatch (manual, with configurable ref) Creates an auto-merge PR when regenerated code changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds automation to keep a canonical, regenerated copy of TypeSpec Python emitter-generated test code in this repo, by introducing a GitHub Actions workflow plus documentation for the generated-test directory.
Changes:
- Introduces a new GitHub Actions workflow to regenerate and PR generated tests from
microsoft/typespec’shttp-client-pythonemitter. - Adds documentation describing the purpose, layout, and regeneration path for
eng/tools/typespec-python-generated-tests/.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
eng/tools/typespec-python-generated-tests/README.md |
Documents what the generated tests are and how regeneration is expected to work. |
.github/workflows/typespec-python-regen.yml |
Implements the automated regeneration + PR creation (and auto-merge) workflow. |
Regenerated from microsoft/typespec@fae1a8f (main) - 116 azure flavor packages - 65 unbranded flavor packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add dispatch sender validation guard - Use fetch-depth: 0 for reliable PR branch creation - Inline ref expression in checkout to avoid GITHUB_OUTPUT injection - Sanitize ref value before writing to GITHUB_OUTPUT for PR metadata - Make auto-merge conditional on workflow_dispatch only (not repository_dispatch) - Update README with full regeneration steps (install, build, prepare) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4d93412 to
66d6d35
Compare
- Rename folder: typespec-python-generated-tests -> tsp-python-gen (fixes path length >260 chars) - Rename workflow: typespec-python-regen.yml -> typespec-python-regenerate.yml (fixes cspell 'regen' errors) - Replace 'Regen' with 'Regenerate' in workflow name and dispatch type - Add CODEOWNERS for tsp-python-gen/ and the workflow file Owners: @tadelesh @msyyc @iscai-msft @lmazuel @lirenhe Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bbd4ecd to
6c16f54
Compare
Use native gh CLI for PR creation instead of third-party action. Commits only eng/tools/tsp-python-gen/ changes, force-pushes to a fixed branch, and creates or updates an existing PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Re-add auto-merge via gh pr merge --auto --squash - Add notify-on-failure job that creates a GitHub issue assigned to @iscai-msft when the workflow fails (triggers email notification) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace repository_dispatch with daily schedule (8:00 UTC) - Add check-version job that compares npm version to .last-version marker - Only regenerate when a new version is detected or manually triggered - Update .last-version marker after each regeneration - Remove dispatch sender validation (no longer applicable) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- repository_dispatch: fired by typespec publish pipeline after npm release - schedule: daily 8:00 UTC fallback to catch any missed dispatches - workflow_dispatch: manual trigger with configurable ref - Checkout uses dispatch sha when available Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| regenerate: | ||
| name: "Regenerate TypeSpec Python tests" | ||
| needs: [check-version] | ||
| if: always() && (github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || needs.check-version.outputs.should_regenerate == 'true') |
There was a problem hiding this comment.
always() && is unnecessary yes? That's just saying true && <the actual thing>
scbedd
left a comment
There was a problem hiding this comment.
Approving the github workflow. Manually triggered. Doesn't use 3P actions. Pins 1P actions to versions.
Nit: please run this script against your action before merging -- just to double check.
Run this with -Path .github/workflows/typespec-python-regenerate.yml and make certain nothing changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…anded/unbranded - Replace repository_dispatch + daily schedule with push trigger on eng/emitter-package.json - Add manual workflow_dispatch with emitter choice (branded/unbranded) and version input - Install target emitter from npm instead of always using built-in - Remove check-version job and .last-version marker file - Pass --emitterName to regeneration script for emitter selection Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move from eng/tools/tsp-python-gen/ to eng/tools/azure-sdk-tools/emitter/generated/ - Add README.md at eng/tools/azure-sdk-tools/emitter/ describing the directory - Update workflow and CODEOWNERS references Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- emitter-package-update skill: add background section, tsp-client generate-config-files step, and automatic regeneration after merge - static_type_checking.md: point to microsoft/typespec for TypeSpec-based SDK generator issues Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Add a GitHub Actions workflow that regenerates Python SDK test code from
microsoft/typespec'shttp-client-pythonemitter and stores the output ineng/tools/typespec-python-generated-tests/.Motivation
The TypeSpec Python emitter (
@typespec/http-client-python) generates test code againsthttp-specsandazure-http-specstest suites. Currently these generated tests aren't tracked anywhere persistent. This workflow keeps a canonical copy in azure-sdk-for-python, updated automatically when the emitter changes.How it works
Triggers
repository_dispatch— automated, triggered from microsoft/typespec when http-client-python merges to mainworkflow_dispatch— manual, with configurabletypespec_ref(branch, tag, SHA, ormainfor latest unreleased code)Steps
npm run regenerateto generate both azure and unbranded flavorseng/tools/typespec-python-generated-tests/{azure,unbranded}/Output structure