From 2ac36339a07a355ef5fc434a0d33dd44ef373853 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 6 Jul 2026 10:05:28 +0800 Subject: [PATCH 1/2] Update TypeSpec Python regenerate workflow sync --- .github/workflows/typespec-python-regenerate.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/typespec-python-regenerate.yml b/.github/workflows/typespec-python-regenerate.yml index ab4e5172397b..7eff6ff8afb1 100644 --- a/.github/workflows/typespec-python-regenerate.yml +++ b/.github/workflows/typespec-python-regenerate.yml @@ -41,6 +41,11 @@ jobs: with: fetch-depth: 0 + - name: Configure git author + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + - name: Resolve TypeSpec repo/ref id: typespec-info env: @@ -109,8 +114,6 @@ jobs: working-directory: _typespec run: | set -euo pipefail - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" # The checkout's "origin" points at the PR head repo (possibly a # fork), so add microsoft/typespec explicitly to fetch its main. if git remote get-url upstream >/dev/null 2>&1; then @@ -180,6 +183,10 @@ jobs: exit 1 fi git checkout -B "$SOURCE_BRANCH" "origin/$TARGET_BRANCH" + if [ -z "$PR_NUMBER" ]; then + git fetch --no-tags origin main + git merge --no-edit origin/main + fi - name: Copy regenerated tests run: | @@ -218,8 +225,6 @@ jobs: run: | set -euo pipefail TARGET_BRANCH="typespec-python-generated-tests" - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" GENERATED_DIR="eng/tools/azure-sdk-tools/emitter/generated" From 94091aaa9048e6f2fea7099caeed2bd87ec58fbc Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 6 Jul 2026 11:14:39 +0800 Subject: [PATCH 2/2] Fix generated tests branch sync merge --- .github/workflows/typespec-python-regenerate.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/typespec-python-regenerate.yml b/.github/workflows/typespec-python-regenerate.yml index 7eff6ff8afb1..1106a6d890d1 100644 --- a/.github/workflows/typespec-python-regenerate.yml +++ b/.github/workflows/typespec-python-regenerate.yml @@ -178,14 +178,18 @@ jobs: else SOURCE_BRANCH="regen/typespec-python-main" fi - if ! git fetch --no-tags --depth=1 origin "$TARGET_BRANCH" 2>/dev/null; then + if ! git fetch --no-tags origin "$TARGET_BRANCH" 2>/dev/null; then echo "::error::Branch $TARGET_BRANCH not found. Initialize it from the generated-tests history before rerunning this workflow." exit 1 fi git checkout -B "$SOURCE_BRANCH" "origin/$TARGET_BRANCH" if [ -z "$PR_NUMBER" ]; then git fetch --no-tags origin main - git merge --no-edit origin/main + if ! git merge --no-edit origin/main; then + git merge --abort || true + echo "::error::Branch $TARGET_BRANCH conflicts with main. Please update $TARGET_BRANCH by merging the latest main and resolving conflicts, then re-run this workflow." + exit 1 + fi fi - name: Copy regenerated tests