Skip to content

[typespec-python] Add generated test regeneration workflow#46414

Open
iscai-msft wants to merge 4 commits intoAzure:mainfrom
iscai-msft:python/typespec-generated-tests
Open

[typespec-python] Add generated test regeneration workflow#46414
iscai-msft wants to merge 4 commits intoAzure:mainfrom
iscai-msft:python/typespec-generated-tests

Conversation

@iscai-msft
Copy link
Copy Markdown
Contributor

Summary

Add a GitHub Actions workflow that regenerates Python SDK test code from microsoft/typespec's http-client-python emitter and stores the output in eng/tools/typespec-python-generated-tests/.

Motivation

The TypeSpec Python emitter (@typespec/http-client-python) generates test code against http-specs and azure-http-specs test 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 main
  • workflow_dispatch — manual, with configurable typespec_ref (branch, tag, SHA, or main for latest unreleased code)

Steps

  1. Checks out azure-sdk-for-python and microsoft/typespec (at specified ref)
  2. Builds http-client-python from source (no npm publish required)
  3. Runs npm run regenerate to generate both azure and unbranded flavors
  4. Copies output to eng/tools/typespec-python-generated-tests/{azure,unbranded}/
  5. Creates an auto-merge PR with the changes

Output structure

eng/tools/typespec-python-generated-tests/
├── azure/        # Generated from azure-http-specs
├── unbranded/    # Generated from http-specs
└── README.md

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>
Copilot AI review requested due to automatic review settings April 20, 2026 18:24
@iscai-msft iscai-msft requested review from a team, mccoyp and scbedd as code owners April 20, 2026 18:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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’s http-client-python emitter.
  • 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.

Comment thread .github/workflows/typespec-python-regen.yml Outdated
Comment thread .github/workflows/typespec-python-regenerate.yml
Comment thread .github/workflows/typespec-python-regenerate.yml
Comment thread .github/workflows/typespec-python-regenerate.yml
Comment thread eng/tools/tsp-python-gen/README.md
iscai-msft and others added 2 commits April 20, 2026 14:30
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>
@iscai-msft iscai-msft force-pushed the python/typespec-generated-tests branch from 4d93412 to 66d6d35 Compare April 20, 2026 18:36
- 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>
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.

2 participants