Skip to content

Sync PR head with microsoft/typespec main before regeneration#47770

Merged
msyyc merged 3 commits into
mainfrom
typespec-regen-sync-main
Jun 30, 2026
Merged

Sync PR head with microsoft/typespec main before regeneration#47770
msyyc merged 3 commits into
mainfrom
typespec-regen-sync-main

Conversation

@msyyc

@msyyc msyyc commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

When the TypeSpec Python regeneration workflow runs against a microsoft/typespec pull request URL, it now merges microsoft/typespec main into the checked-out PR head before regenerating. This ensures the regenerated diff reflects only the PR's changes on top of current main, rather than including changes the PR is simply behind on.

Changes

  • Added a Sync PR head with microsoft/typespec main step that runs only for PR-sourced runs (typespec_pr_number != '').
  • The step adds microsoft/typespec as an upstream remote (idempotently via set-url/add), fetches its main, and merges it into the PR head.
  • If the PR conflicts with main, the merge is aborted and the workflow fails with a clear, actionable message instructing the user to update the PR branch and resolve conflicts before re-running.

Notes

  • The existing _typespec checkout already uses fetch-depth: 0, so the full history is available for a proper merge base.
  • No behavior change for main-sourced runs (push/schedule/main input).

Test

@msyyc msyyc marked this pull request as ready for review June 30, 2026 09:16
@msyyc msyyc requested a review from tadelesh as a code owner June 30, 2026 09:16
Copilot AI review requested due to automatic review settings June 30, 2026 09:16
@msyyc msyyc requested review from a team, ChenxiJiang333 and iscai-msft as code owners June 30, 2026 09:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the TypeSpec Python Regenerate Tests GitHub Actions workflow so that, when triggered against a microsoft/typespec pull request URL, it merges microsoft/typespec main into the checked-out PR head before regenerating tests. This ensures the regenerated diff reflects only the PR's own changes relative to current main, rather than also surfacing unrelated emitter changes the PR is merely behind on.

Changes:

  • Added a Sync PR head with microsoft/typespec main step gated to PR-sourced runs (typespec_pr_number != '').
  • The step idempotently configures an upstream remote pointing at microsoft/typespec, fetches its main, and merges it into the detached PR head checkout.
  • On merge conflict, it aborts the merge and fails the run with an actionable error message; on success it emits a notice with the resulting short SHA.

@msyyc msyyc merged commit 2d20e22 into main Jun 30, 2026
25 of 27 checks passed
@msyyc msyyc deleted the typespec-regen-sync-main branch June 30, 2026 10:26
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.

3 participants