Skip to content

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

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

[typespec-python] Add generated test regeneration workflow#46414
iscai-msft wants to merge 17 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 Outdated
Comment thread .github/workflows/typespec-python-regenerate.yml Outdated
Comment thread .github/workflows/typespec-python-regenerate.yml Outdated
Comment thread eng/tools/azure-sdk-tools/emitter/generated/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>
@iscai-msft iscai-msft force-pushed the python/typespec-generated-tests branch from bbd4ecd to 6c16f54 Compare April 21, 2026 15:53
Comment thread .github/workflows/typespec-python-regenerate.yml Outdated
iscai-msft and others added 6 commits April 21, 2026 15:29
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>
@iscai-msft iscai-msft enabled auto-merge (squash) April 21, 2026 20:54
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')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

always() && is unnecessary yes? That's just saying true && <the actual thing>

Comment thread .github/workflows/typespec-python-regenerate.yml
Copy link
Copy Markdown
Member

@scbedd scbedd left a comment

Choose a reason for hiding this comment

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

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.

iscai-msft and others added 6 commits April 23, 2026 09:55
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>
@iscai-msft iscai-msft requested a review from l0lawrence as a code owner April 23, 2026 17:20
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.

4 participants